Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index 126286444a3fd3d20fb381137fc275714d261727..ac7e09948a2aab8f8c19f7e5c0387727f58214ad 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -87,7 +87,6 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type) |
// scope must be a script scope. |
DCHECK_EQ(SCRIPT_SCOPE, scope_type); |
} else { |
- asm_function_ = outer_scope_->asm_module_; |
// Inherit the language mode from the parent scope unless we're a module |
// scope. |
if (!is_module_scope()) language_mode_ = outer_scope->language_mode_; |
@@ -116,6 +115,8 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* outer_scope, |
if (scope_type == MODULE_SCOPE) { |
module_descriptor_ = new (zone) ModuleDescriptor(zone); |
language_mode_ = STRICT; |
+ } else if (outer_scope != nullptr) { |
+ asm_function_ = outer_scope_->IsAsmModule(); |
} |
} |
@@ -175,6 +176,8 @@ Scope::Scope(Zone* zone, Scope* inner_scope, |
void DeclarationScope::SetDefaults() { |
is_declaration_scope_ = true; |
has_simple_parameters_ = true; |
+ asm_module_ = false; |
+ asm_function_ = false; |
receiver_ = nullptr; |
new_target_ = nullptr; |
function_ = nullptr; |
@@ -209,8 +212,6 @@ void Scope::SetDefaults() { |
scope_calls_eval_ = false; |
scope_uses_super_property_ = false; |
has_arguments_parameter_ = false; |
- asm_module_ = false; |
- asm_function_ = false; |
scope_nonlinear_ = false; |
is_hidden_ = false; |
is_debug_evaluate_scope_ = false; |
@@ -228,6 +229,14 @@ bool Scope::HasSimpleParameters() { |
return !scope->is_function_scope() || scope->has_simple_parameters(); |
} |
+bool Scope::IsAsmModule() const { |
+ return is_function_scope() && AsDeclarationScope()->asm_module(); |
+} |
+ |
+bool Scope::IsAsmFunction() const { |
+ return is_function_scope() && AsDeclarationScope()->asm_function(); |
+} |
+ |
Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, |
Context* context, |
DeclarationScope* script_scope, |
@@ -258,10 +267,11 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, |
} else if (context->IsFunctionContext()) { |
Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(), |
isolate); |
- current_scope = new (zone) |
+ DeclarationScope* function_scope = new (zone) |
DeclarationScope(zone, current_scope, FUNCTION_SCOPE, scope_info); |
- if (scope_info->IsAsmFunction()) current_scope->asm_function_ = true; |
- if (scope_info->IsAsmModule()) current_scope->asm_module_ = true; |
+ if (scope_info->IsAsmFunction()) function_scope->set_asm_function(); |
+ if (scope_info->IsAsmModule()) function_scope->set_asm_module(); |
+ current_scope = function_scope; |
} else if (context->IsBlockContext()) { |
Handle<ScopeInfo> scope_info(context->scope_info(), isolate); |
if (scope_info->is_declaration_scope()) { |
@@ -1149,8 +1159,8 @@ void Scope::Print(int n) { |
if (is_strict(language_mode())) { |
Indent(n1, "// strict mode scope\n"); |
} |
- if (asm_module_) Indent(n1, "// scope is an asm module\n"); |
- if (asm_function_) Indent(n1, "// scope is an asm function\n"); |
+ if (IsAsmModule()) Indent(n1, "// scope is an asm module\n"); |
+ if (IsAsmFunction()) Indent(n1, "// scope is an asm function\n"); |
if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |
if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
if (scope_uses_super_property_) |
@@ -1480,8 +1490,8 @@ void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval) { |
if (inner->force_eager_compilation_) { |
force_eager_compilation_ = true; |
} |
- if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { |
- inner->asm_function_ = true; |
+ if (IsAsmModule() && inner->is_function_scope()) { |
+ inner->AsDeclarationScope()->set_asm_function(); |
} |
} |
} |