Commit 2028c093 authored by adamk's avatar adamk Committed by Commit bot

Remove two more special cases from Scope::MustAllocate(Variable*)

Block scopes don't need any special treatment here (it's unclear
to me why they ever did). And the has_forced_context_allocation() check
seems, according to our tests, to only have been necessary for proper
handling of 'with' scopes. This patch instead uses the "is_used" bit
to keep track of variables that are accessed from within a with.

R=neis@chromium.org

Review-Url: https://codereview.chromium.org/2220293003
Cr-Commit-Position: refs/heads/master@{#38505}
parent 86e141eb
...@@ -1302,7 +1302,7 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy, ...@@ -1302,7 +1302,7 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy,
} else if (outer_scope_ != nullptr && this != max_outer_scope) { } else if (outer_scope_ != nullptr && this != max_outer_scope) {
var = outer_scope_->LookupRecursive(proxy, binding_kind, factory, var = outer_scope_->LookupRecursive(proxy, binding_kind, factory,
max_outer_scope); max_outer_scope);
if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) { if (*binding_kind == BOUND && is_function_scope()) {
var->ForceContextAllocation(); var->ForceContextAllocation();
} }
} else { } else {
...@@ -1321,7 +1321,11 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy, ...@@ -1321,7 +1321,11 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy,
// the associated variable has to be marked as potentially being accessed // the associated variable has to be marked as potentially being accessed
// from inside of an inner with scope (the property may not be in the 'with' // from inside of an inner with scope (the property may not be in the 'with'
// object). // object).
if (var != NULL && proxy->is_assigned()) var->set_maybe_assigned(); if (var != NULL) {
var->set_is_used();
var->ForceContextAllocation();
if (proxy->is_assigned()) var->set_maybe_assigned();
}
*binding_kind = DYNAMIC_LOOKUP; *binding_kind = DYNAMIC_LOOKUP;
return NULL; return NULL;
} else if (calls_sloppy_eval() && is_declaration_scope() && } else if (calls_sloppy_eval() && is_declaration_scope() &&
...@@ -1487,12 +1491,12 @@ bool Scope::MustAllocate(Variable* var) { ...@@ -1487,12 +1491,12 @@ bool Scope::MustAllocate(Variable* var) {
// via an eval() call. This is only possible if the variable has a // via an eval() call. This is only possible if the variable has a
// visible name. // visible name.
if ((var->is_this() || !var->raw_name()->IsEmpty()) && if ((var->is_this() || !var->raw_name()->IsEmpty()) &&
(var->has_forced_context_allocation() || scope_calls_eval_ || (scope_calls_eval_ || inner_scope_calls_eval_ || is_catch_scope() ||
inner_scope_calls_eval_ || is_catch_scope() || is_block_scope() ||
is_script_scope())) { is_script_scope())) {
var->set_is_used(); var->set_is_used();
if (scope_calls_eval_ || inner_scope_calls_eval_) var->set_maybe_assigned(); if (scope_calls_eval_ || inner_scope_calls_eval_) var->set_maybe_assigned();
} }
DCHECK(!var->has_forced_context_allocation() || var->is_used());
// Global variables do not need to be allocated. // Global variables do not need to be allocated.
return !var->IsGlobalObjectProperty() && var->is_used(); return !var->IsGlobalObjectProperty() && var->is_used();
} }
......
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