Commit 33f3262f authored by neis's avatar neis Committed by Commit bot

[modules] Don't force context allocation of variables declared in module scope.

There's no need to do so.

Also simplify NeedsContext(), which doesn't need to check for with-scopes.

R=adamk@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2225683004
Cr-Commit-Position: refs/heads/master@{#38451}
parent 5fc50a91
......@@ -1491,7 +1491,7 @@ bool Scope::MustAllocate(Variable* var) {
if ((var->is_this() || !var->raw_name()->IsEmpty()) &&
(var->has_forced_context_allocation() || scope_calls_eval_ ||
inner_scope_calls_eval_ || is_catch_scope() || is_block_scope() ||
is_module_scope() || is_script_scope())) {
is_script_scope())) {
var->set_is_used();
if (scope_calls_eval_ || inner_scope_calls_eval_) var->set_maybe_assigned();
}
......@@ -1512,7 +1512,7 @@ bool Scope::MustAllocateInContext(Variable* var) {
// always context-allocated.
if (has_forced_context_allocation()) return true;
if (var->mode() == TEMPORARY) return false;
if (is_catch_scope() || is_module_scope()) return true;
if (is_catch_scope()) return true;
if (is_script_scope() && IsLexicalVariableMode(var->mode())) return true;
return var->has_forced_context_allocation() || scope_calls_eval_ ||
inner_scope_calls_eval_;
......
......@@ -331,10 +331,9 @@ class Scope: public ZoneObject {
// Whether this needs to be represented by a runtime context.
bool NeedsContext() const {
// Catch and module scopes always have heap slots.
// Catch scopes always have heap slots.
DCHECK(!is_catch_scope() || num_heap_slots() > 0);
DCHECK(!is_module_scope() || num_heap_slots() > 0);
return is_with_scope() || num_heap_slots() > 0;
return num_heap_slots() > 0;
}
// ---------------------------------------------------------------------------
......
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