Skip to content

Commit

Permalink
Bug 1662383 - Remove {EmitResult,SmooshResult}.top_level_script. r=nbp
Browse files Browse the repository at this point in the history
  • Loading branch information
arai-a committed Sep 16, 2020
1 parent 2c546aa commit 084f4ff
Show file tree
Hide file tree
Showing 30 changed files with 18,103 additions and 18,054 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rev = "9ba519a5739b1976f1d333923d34b7f4916b9e26"
[source."https://github.com/mozilla-spidermonkey/jsparagus"]
git = "https://github.com/mozilla-spidermonkey/jsparagus"
replace-with = "vendored-sources"
rev = "0b933acac9dc56067e66f26d16ee00194a91e13b"
rev = "66dd1ae63d03fc2191d6c83d72c27b940c6aa4ac"

[source."https://github.com/kvark/spirv_cross"]
branch = "wgpu3"
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 7 additions & 16 deletions js/src/frontend/Frontend2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ bool ConvertScopeStencil(JSContext* cx, const SmooshResult& result,

bool hasParameterExprs = function.has_parameter_exprs;
bool needsEnvironment = function.non_positional_formal_start;
FunctionIndex functionIndex =
FunctionIndex(function.function_index + 1);
FunctionIndex functionIndex = FunctionIndex(function.function_index);
bool isArrow = function.is_arrow;

ScopeIndex enclosingIndex(function.enclosing);
Expand Down Expand Up @@ -367,7 +366,7 @@ bool ConvertGCThings(JSContext* cx, const SmooshResult& result,
}
case SmooshGCThing::Tag::Function: {
gcThings.infallibleAppend(
mozilla::AsVariant(FunctionIndex(item.AsFunction() + 1)));
mozilla::AsVariant(FunctionIndex(item.AsFunction())));
break;
}
case SmooshGCThing::Tag::Scope: {
Expand Down Expand Up @@ -410,7 +409,7 @@ bool ConvertScriptStencil(JSContext* cx, const SmooshResult& result,
script.immutableFlags.setFlag(ImmutableFlags::HasNonSyntacticScope,
options.nonSyntacticScope);

if (&smooshScript == &result.top_level_script) {
if (&smooshScript == &result.scripts.data[0]) {
script.immutableFlags.setFlag(ImmutableFlags::TreatAsRunOnce,
options.isRunOnce);
script.immutableFlags.setFlag(ImmutableFlags::NoScriptRval,
Expand Down Expand Up @@ -553,25 +552,17 @@ bool Smoosh::compileGlobalScriptToStencil(JSContext* cx,
return false;
}

if (!compilationInfo.stencil.scriptData.reserve(result.functions.len + 1)) {
if (!compilationInfo.stencil.scriptData.reserve(result.scripts.len)) {
js::ReportOutOfMemory(cx);
return false;
}

compilationInfo.stencil.scriptData.infallibleEmplaceBack();

if (!ConvertScriptStencil(
cx, result, result.top_level_script, allAtoms, compilationInfo,
compilationInfo.stencil.scriptData[CompilationInfo::TopLevelIndex])) {
return false;
}

for (size_t i = 0; i < result.functions.len; i++) {
for (size_t i = 0; i < result.scripts.len; i++) {
compilationInfo.stencil.scriptData.infallibleEmplaceBack();

if (!ConvertScriptStencil(cx, result, result.functions.data[i], allAtoms,
if (!ConvertScriptStencil(cx, result, result.scripts.data[i], allAtoms,
compilationInfo,
compilationInfo.stencil.scriptData[i + 1])) {
compilationInfo.stencil.scriptData[i])) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/frontend/smoosh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ log = "0.4"
# Disable regex feature for code size.
env_logger = {version = "0.6", default-features = false}
# For non-jsparagus developers.
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "0b933acac9dc56067e66f26d16ee00194a91e13b" }
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "66dd1ae63d03fc2191d6c83d72c27b940c6aa4ac" }
# For local development, replace above with
# jsparagus = { path = "{path to jsparagus}" }

[build-dependencies]
# For non-jsparagus developers.
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "0b933acac9dc56067e66f26d16ee00194a91e13b" }
jsparagus = { git = "https://github.com/mozilla-spidermonkey/jsparagus", rev = "66dd1ae63d03fc2191d6c83d72c27b940c6aa4ac" }
# For local development, replace above with
# jsparagus = { path = "{path to jsparagus}" }
38 changes: 6 additions & 32 deletions js/src/frontend/smoosh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ pub struct SmooshResult {
scopes: CVec<SmooshScopeData>,
regexps: CVec<SmooshRegExpItem>,

top_level_script: SmooshScriptStencil,
functions: CVec<SmooshScriptStencil>,
scripts: CVec<SmooshScriptStencil>,
script_data_list: CVec<SmooshImmutableScriptData>,

all_atoms: *mut c_void,
Expand Down Expand Up @@ -376,27 +375,7 @@ impl SmooshResult {
scopes: CVec::empty(),
regexps: CVec::empty(),

top_level_script: SmooshScriptStencil {
immutable_flags: 0,
gcthings: CVec::empty(),
immutable_script_data: COption::None,
extent: SmooshSourceExtent {
source_start: 0,
source_end: 0,
to_string_start: 0,
to_string_end: 0,
lineno: 0,
column: 0,
},
fun_name: COption::None,
fun_nargs: 0,
fun_flags: 0,
lazy_function_enclosing_scope_index: COption::None,
is_standalone_function: false,
was_function_emitted: false,
is_singleton_function: false,
},
functions: CVec::empty(),
scripts: CVec::empty(),
script_data_list: CVec::empty(),

all_atoms: std::ptr::null_mut(),
Expand Down Expand Up @@ -533,11 +512,9 @@ pub unsafe extern "C" fn smoosh_run(
let scopes = convert_scopes(result.scopes, &mut scope_index_map);
let regexps = CVec::from(result.regexps.into_iter().map(|x| x.into()).collect());

let top_level_script = convert_script(result.top_level_script, &scope_index_map);

let functions = CVec::from(
let scripts = CVec::from(
result
.functions
.scripts
.into_iter()
.map(|x| convert_script(x, &scope_index_map))
.collect(),
Expand Down Expand Up @@ -571,8 +548,7 @@ pub unsafe extern "C" fn smoosh_run(
scopes,
regexps,

top_level_script,
functions,
scripts,
script_data_list,

all_atoms: opaque_all_atoms,
Expand Down Expand Up @@ -721,9 +697,7 @@ pub unsafe extern "C" fn smoosh_free(result: SmooshResult) {
let _ = result.scopes.into();
let _ = result.regexps.into();

free_script(result.top_level_script);

for fun in result.functions.into() {
for fun in result.scripts.into() {
free_script(fun);
}

Expand Down
2 changes: 1 addition & 1 deletion third_party/rust/jsparagus-ast/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"files":{"Cargo.toml":"6691713bda864bda400c97783df5f4bff9202bc61179db79ac01557d6d1a5038","ast.json":"0bf1dfe7ec726f0c26cec875961a3072a7b8d7600ef6d301915a2684ed51a1ad","generate_ast.py":"0c24431d9c07af42d7d17739c2e21465964151562437cfca093ceddde898bc93","src/arena.rs":"03ef07c963556160a6f1a85fd901833d7322f8a5f265c20d3e3543432dd2a96d","src/associated_data.rs":"aad369f45eca0506632d3c6aa2f487debb81d0dbc5a73eda46ee97478d51eaf3","src/dump_generated.rs":"8ca0736952ee41fc932807e8450c6eb68e081b3fd5f7a0f701cae8b35dc0c13e","src/lib.rs":"b35553bedec9f6d88cc5194592f857dc13669559cbc8b206048c35299c4f86be","src/source_atom_set.rs":"24ec99be098cab6aa433d7b2e0a2cbc074204276d6c90b17174e50f8003244ee","src/source_location.rs":"3832440ecec6de726262837072810410bddb45c075288386509511c153f6afd9","src/source_location_accessor_generated.rs":"2669efcc5447229429f8fab6123bbd9dec8ed4c69232992af05aca3a59f1c710","src/source_slice_list.rs":"c82413b3081e091a3c4ce5d2c3624e54ecbeb0bb9952f10d373d10faf589955a","src/type_id_generated.rs":"a1e88f0d9d97d61339d0bedd0f6a8472bd39ea13968531ebce7140ca47edbaeb","src/types_generated.rs":"5e4f2386e76d2e9d2a60fd799430b2d4d628be61fb41200acbd5102403011d0f","src/visit_generated.rs":"630e6a8d1c32148a413d568ad0e6915ebe39a068b2563d1860af74428547801e"},"package":null}
{"files":{"Cargo.toml":"6691713bda864bda400c97783df5f4bff9202bc61179db79ac01557d6d1a5038","ast.json":"e9c358aedb77bf02059f44179140d900c705af592069f269022bc9b52dc30ac4","generate_ast.py":"0c24431d9c07af42d7d17739c2e21465964151562437cfca093ceddde898bc93","src/arena.rs":"03ef07c963556160a6f1a85fd901833d7322f8a5f265c20d3e3543432dd2a96d","src/associated_data.rs":"aad369f45eca0506632d3c6aa2f487debb81d0dbc5a73eda46ee97478d51eaf3","src/dump_generated.rs":"8ca0736952ee41fc932807e8450c6eb68e081b3fd5f7a0f701cae8b35dc0c13e","src/lib.rs":"b35553bedec9f6d88cc5194592f857dc13669559cbc8b206048c35299c4f86be","src/source_atom_set.rs":"24ec99be098cab6aa433d7b2e0a2cbc074204276d6c90b17174e50f8003244ee","src/source_location.rs":"3832440ecec6de726262837072810410bddb45c075288386509511c153f6afd9","src/source_location_accessor_generated.rs":"2669efcc5447229429f8fab6123bbd9dec8ed4c69232992af05aca3a59f1c710","src/source_slice_list.rs":"c82413b3081e091a3c4ce5d2c3624e54ecbeb0bb9952f10d373d10faf589955a","src/type_id_generated.rs":"a1e88f0d9d97d61339d0bedd0f6a8472bd39ea13968531ebce7140ca47edbaeb","src/types_generated.rs":"eda341459f8356dc46a6f8ed993740bcf1536c6b6601d885f2a20f4a7a4d4e4a","src/visit_generated.rs":"90ae82f2db8b33f5b23eae1b1b21f1ce4c14a79719bc46e44a838a04c7d838e4"},"package":null}
6 changes: 3 additions & 3 deletions third_party/rust/jsparagus-ast/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,20 +570,20 @@
},
"Method": {
"_type": "struct",
"name": "PropertyName",
"name": "ClassElementName",
"is_async": "bool",
"is_generator": "bool",
"params": "FormalParameters",
"body": "FunctionBody"
},
"Getter": {
"_type": "struct",
"property_name": "PropertyName",
"property_name": "ClassElementName",
"body": "FunctionBody"
},
"Setter": {
"_type": "struct",
"property_name": "PropertyName",
"property_name": "ClassElementName",
"param": "Parameter",
"body": "FunctionBody"
},
Expand Down
6 changes: 3 additions & 3 deletions third_party/rust/jsparagus-ast/src/types_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ pub struct ExportLocalSpecifier {

#[derive(Debug, PartialEq)]
pub struct Method<'alloc> {
pub name: PropertyName<'alloc>,
pub name: ClassElementName<'alloc>,
pub is_async: bool,
pub is_generator: bool,
pub params: FormalParameters<'alloc>,
Expand All @@ -847,14 +847,14 @@ pub struct Method<'alloc> {

#[derive(Debug, PartialEq)]
pub struct Getter<'alloc> {
pub property_name: PropertyName<'alloc>,
pub property_name: ClassElementName<'alloc>,
pub body: FunctionBody<'alloc>,
pub loc: SourceLocation,
}

#[derive(Debug, PartialEq)]
pub struct Setter<'alloc> {
pub property_name: PropertyName<'alloc>,
pub property_name: ClassElementName<'alloc>,
pub param: Parameter<'alloc>,
pub body: FunctionBody<'alloc>,
pub loc: SourceLocation,
Expand Down
6 changes: 3 additions & 3 deletions third_party/rust/jsparagus-ast/src/visit_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4682,7 +4682,7 @@ pub trait Pass<'alloc> {

fn visit_method(&mut self, ast: &'alloc Method<'alloc>) {
self.enter_method(ast);
self.visit_property_name(&ast.name);
self.visit_class_element_name(&ast.name);
self.visit_formal_parameters(&ast.params);
self.visit_function_body(&ast.body);
self.leave_method(ast);
Expand All @@ -4696,7 +4696,7 @@ pub trait Pass<'alloc> {

fn visit_getter(&mut self, ast: &'alloc Getter<'alloc>) {
self.enter_getter(ast);
self.visit_property_name(&ast.property_name);
self.visit_class_element_name(&ast.property_name);
self.visit_function_body(&ast.body);
self.leave_getter(ast);
}
Expand All @@ -4709,7 +4709,7 @@ pub trait Pass<'alloc> {

fn visit_setter(&mut self, ast: &'alloc Setter<'alloc>) {
self.enter_setter(ast);
self.visit_property_name(&ast.property_name);
self.visit_class_element_name(&ast.property_name);
self.visit_parameter(&ast.param);
self.visit_function_body(&ast.body);
self.leave_setter(ast);
Expand Down
2 changes: 1 addition & 1 deletion third_party/rust/jsparagus-emitter/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"files":{"Cargo.toml":"00c740f44b5681e3277e519d2e143e6edfbff186ca31a07ddce2eb46b803ddd7","src/array_emitter.rs":"bbc6528321f1d11d7c86c4f2bfdcfc9dced8f0b8b1c30c9f0a5355f300d196b6","src/ast_emitter.rs":"0a858e7cec12a3027f1ab5121a7f84f8493c38a7ea32bad4c9f0d8bf88d1cbba","src/block_emitter.rs":"78965260d87a66c5324d6f3bdfea0f1938f8037f70adde148dbb2db599d1b2c0","src/compilation_info.rs":"32ca7cdae514501de0d0d667ff2b27a3abf736ae207a23009c42eacbdffbd5b3","src/control_structures.rs":"bdb186e98c14fa4e769b23b3dee4376683e6c6530af0856d55c055aff4398b84","src/dis.rs":"4a335d813fa965482ca0f20a7b9295a55ce7625b577d42bd8b33b156b81c6306","src/emitter.rs":"1b3e272a30c1e2ddba72db69205c3562afaa21dfa8979251942b6e1b47856556","src/emitter_scope.rs":"ba924ef541742a5c7be39d1b683bf3107241cf3ff5b8ff7f93987abc9f52e9d2","src/expression_emitter.rs":"f8e02785dffb179bbe9fe58e45bbfccc08adc3ad0a071a0073bed0feedc8ed9a","src/function_declaration_emitter.rs":"d76570732fd2d706f7861bf8be559ce998b25c8e028342831b759b17c54f7c13","src/lib.rs":"43285b5ddf164de2d90fc989ac25211e3e716751e6218df45f651ea75137d0f5","src/object_emitter.rs":"998423b3d6ef8797fadef6763803627df72fde292b1b34d6a41b2e66a331a181","src/reference_op_emitter.rs":"87c7e05934718921d72977746b93513850eab69465d33e190003cb86241f62b4","src/script_emitter.rs":"44a6be5ecdcde3c32d78d100a205d38be2591c7c2cc109967579af7393e09fe8"},"package":null}
{"files":{"Cargo.toml":"00c740f44b5681e3277e519d2e143e6edfbff186ca31a07ddce2eb46b803ddd7","src/array_emitter.rs":"bbc6528321f1d11d7c86c4f2bfdcfc9dced8f0b8b1c30c9f0a5355f300d196b6","src/ast_emitter.rs":"8326432205a0c05aa0c2def31a621c70a0365c05278d2392510ad48e782abfe6","src/block_emitter.rs":"78965260d87a66c5324d6f3bdfea0f1938f8037f70adde148dbb2db599d1b2c0","src/compilation_info.rs":"b0d91b0f8d6940cb7087b474c3c814b758c8ce8d9027c415b76ad4af78be6140","src/control_structures.rs":"bdb186e98c14fa4e769b23b3dee4376683e6c6530af0856d55c055aff4398b84","src/dis.rs":"4a335d813fa965482ca0f20a7b9295a55ce7625b577d42bd8b33b156b81c6306","src/emitter.rs":"1b3e272a30c1e2ddba72db69205c3562afaa21dfa8979251942b6e1b47856556","src/emitter_scope.rs":"ba924ef541742a5c7be39d1b683bf3107241cf3ff5b8ff7f93987abc9f52e9d2","src/expression_emitter.rs":"f8e02785dffb179bbe9fe58e45bbfccc08adc3ad0a071a0073bed0feedc8ed9a","src/function_declaration_emitter.rs":"145e4476b387a067736fdf5aac2ca567694b2b0b952d0862bc56bd8e9af4a743","src/lib.rs":"e256eceee1eb7ea66fe855fcc3fa2fff187977f9adca2754872d13e9bb788536","src/object_emitter.rs":"998423b3d6ef8797fadef6763803627df72fde292b1b34d6a41b2e66a331a181","src/reference_op_emitter.rs":"87c7e05934718921d72977746b93513850eab69465d33e190003cb86241f62b4","src/script_emitter.rs":"44a6be5ecdcde3c32d78d100a205d38be2591c7c2cc109967579af7393e09fe8"},"package":null}
7 changes: 4 additions & 3 deletions third_party/rust/jsparagus-emitter/src/ast_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ pub fn emit_program<'alloc>(
}
};

compilation_info.scripts.set_top_level(script);

Ok(EmitResult::new(
compilation_info.atoms.into(),
compilation_info.slices.into(),
compilation_info.scope_data_map.into(),
compilation_info.regexps.into(),
script,
compilation_info.functions.into(),
compilation_info.scripts.into(),
compilation_info.script_data_list.into(),
))
}
Expand Down Expand Up @@ -163,7 +164,7 @@ impl<'alloc, 'opt> AstEmitter<'alloc, 'opt> {

let name = self
.compilation_info
.functions
.scripts
.get(stencil_index)
.fun_name()
.expect("Function declaration should have name");
Expand Down
6 changes: 3 additions & 3 deletions third_party/rust/jsparagus-emitter/src/compilation_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct CompilationInfo<'alloc> {
pub function_declarations: HashMap<ScriptStencilIndex, &'alloc Function<'alloc>>,
pub function_stencil_indices: AssociatedData<ScriptStencilIndex>,
pub function_declaration_properties: FunctionDeclarationPropertyMap,
pub functions: ScriptStencilList,
pub scripts: ScriptStencilList,
pub script_data_list: ImmutableScriptDataList,
}

Expand All @@ -28,7 +28,7 @@ impl<'alloc> CompilationInfo<'alloc> {
function_declarations: HashMap<ScriptStencilIndex, &'alloc Function<'alloc>>,
function_stencil_indices: AssociatedData<ScriptStencilIndex>,
function_declaration_properties: FunctionDeclarationPropertyMap,
functions: ScriptStencilList,
scripts: ScriptStencilList,
) -> Self {
Self {
atoms,
Expand All @@ -38,7 +38,7 @@ impl<'alloc> CompilationInfo<'alloc> {
function_declarations,
function_stencil_indices,
function_declaration_properties,
functions,
scripts,
script_data_list: ImmutableScriptDataList::new(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl LazyFunctionEmitter {
pub fn emit(self, emitter: &mut AstEmitter) -> GCThingIndex {
emitter
.compilation_info
.functions
.scripts
.get_mut(self.stencil_index)
.set_function_emitted();
emitter.emit.get_function_gcthing_index(self.stencil_index)
Expand Down
Loading

0 comments on commit 084f4ff

Please sign in to comment.