Commit 5dcda5bb authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[parser] Ensure asm.js modules always allocate context.

The deserialization of the {Scope::asm_module} predicate relies on a
context being present for such modules. This ensures we always allocate
such a context, even in cases where no variables are allocated in it.

R=neis@chromium.org
TEST=cctest/test-parsing/AsmModuleFlag
BUG=v8:5653

Review-Url: https://codereview.chromium.org/2561103004
Cr-Commit-Position: refs/heads/master@{#41611}
parent 44c76119
......@@ -445,6 +445,7 @@ int ScopeInfo::ContextLength() {
(scope_type() == BLOCK_SCOPE && CallsSloppyEval() &&
is_declaration_scope()) ||
(scope_type() == FUNCTION_SCOPE && CallsSloppyEval()) ||
(scope_type() == FUNCTION_SCOPE && IsAsmModule()) ||
scope_type() == MODULE_SCOPE;
if (has_context) {
......
......@@ -2061,9 +2061,9 @@ void Scope::AllocateVariablesRecursively() {
// Force allocation of a context for this scope if necessary. For a 'with'
// scope and for a function scope that makes an 'eval' call we need a context,
// even if no local variables were statically allocated in the scope.
// Likewise for modules.
// Likewise for modules and function scopes representing asm.js modules.
bool must_have_context =
is_with_scope() || is_module_scope() ||
is_with_scope() || is_module_scope() || IsAsmModule() ||
(is_function_scope() && calls_sloppy_eval()) ||
(is_block_scope() && is_declaration_scope() && calls_sloppy_eval());
......
......@@ -3446,6 +3446,7 @@ i::Scope* DeserializeFunctionScope(i::Isolate* isolate, i::Zone* zone,
} // namespace
TEST(AsmModuleFlag) {
i::FLAG_validate_asm = false;
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
LocalContext env;
......@@ -3453,8 +3454,7 @@ TEST(AsmModuleFlag) {
const char* src =
"function m() {"
" 'use asm';"
" var x = 0;"
" function f() { return x };"
" function f() { return 0 };"
" return { f:f };"
"}"
"m();";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment