Commit d814ca8d authored by verwaest's avatar verwaest Committed by Commit bot

Dont track scope_inside_with_ explicitly

This is only needed to set a flag on the SharedFunctionInfo generated for a function literal. Hence we only need it in 1 scope, and only read it once. Recursing in that case will be more efficient than always tracking it.

BUG=v8:5209

Review-Url: https://codereview.chromium.org/2261693002
Cr-Commit-Position: refs/heads/master@{#38761}
parent 561bfcb7
......@@ -91,7 +91,6 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type)
force_context_allocation_ =
!is_function_scope() && outer_scope->has_forced_context_allocation();
outer_scope_->AddInnerScope(this);
scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope();
}
}
......@@ -208,7 +207,6 @@ void Scope::SetDefaults() {
set_language_mode(SLOPPY);
scope_inside_with_ = false;
scope_calls_eval_ = false;
scope_uses_super_property_ = false;
has_arguments_parameter_ = false;
......@@ -256,10 +254,6 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
with_scope->set_is_debug_evaluate_scope();
}
current_scope = with_scope;
// All the inner scopes are inside a with.
for (Scope* s = innermost_scope; s != nullptr; s = s->outer_scope()) {
s->scope_inside_with_ = true;
}
} else if (context->IsScriptContext()) {
Handle<ScopeInfo> scope_info(context->scope_info(), isolate);
DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE);
......@@ -893,7 +887,7 @@ bool Scope::HasTrivialContext() const {
// return true.
for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) {
if (scope->is_eval_scope()) return false;
if (scope->scope_inside_with_) return false;
if (scope->InsideWithScope()) return false;
if (scope->ContextLocalCount() > 0) return false;
if (scope->ContextGlobalCount() > 0) return false;
}
......@@ -902,12 +896,11 @@ bool Scope::HasTrivialContext() const {
bool Scope::HasTrivialOuterContext() const {
Scope* outer = outer_scope_;
if (outer == NULL) return true;
if (outer_scope_ == nullptr) return true;
// Note that the outer context may be trivial in general, but the current
// scope may be inside a 'with' statement in which case the outer context
// for this scope is not trivial.
return !scope_inside_with_ && outer->HasTrivialContext();
return !is_with_scope() && outer_scope_->HasTrivialContext();
}
......@@ -1178,7 +1171,6 @@ void Scope::Print(int 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_)
Indent(n1, "// scope uses 'super' property\n");
......
......@@ -501,8 +501,6 @@ class Scope: public ZoneObject {
// The language mode of this scope.
STATIC_ASSERT(LANGUAGE_END == 2);
bool is_strict_ : 1;
// This scope is inside a 'with' of some outer scope.
bool scope_inside_with_ : 1;
// This scope or a nested catch scope or with scope contain an 'eval' call. At
// the 'eval' call site this scope is the declaration scope.
bool scope_calls_eval_ : 1;
......@@ -595,6 +593,14 @@ class Scope: public ZoneObject {
ParseInfo* info = nullptr,
VariableProxy* stack = nullptr);
bool InsideWithScope() const {
for (const Scope* scope = this; scope != nullptr;
scope = scope->outer_scope()) {
if (scope->is_with_scope()) return true;
}
return false;
}
// Scope analysis.
void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval);
bool HasTrivialContext() const;
......
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