Simplify Scope::AllowsLazyCompilationWithoutContext
Now it just relies on NeedsContext and hence is guaranteed to be in sync. BUG=v8:5209 Review-Url: https://codereview.chromium.org/2262133002 Cr-Commit-Position: refs/heads/master@{#38771}
This commit is contained in:
parent
038be51756
commit
72b784426d
@ -880,30 +880,6 @@ void DeclarationScope::AllocateVariables(ParseInfo* info,
|
||||
}
|
||||
|
||||
|
||||
bool Scope::HasTrivialContext() const {
|
||||
// A function scope has a trivial context if it always is the global
|
||||
// context. We iteratively scan out the context chain to see if
|
||||
// there is anything that makes this scope non-trivial; otherwise we
|
||||
// return true.
|
||||
for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) {
|
||||
if (scope->is_eval_scope()) return false;
|
||||
if (scope->InsideWithScope()) return false;
|
||||
if (scope->ContextLocalCount() > 0) return false;
|
||||
if (scope->ContextGlobalCount() > 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Scope::HasTrivialOuterContext() const {
|
||||
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 !is_with_scope() && outer_scope_->HasTrivialContext();
|
||||
}
|
||||
|
||||
|
||||
bool Scope::AllowsLazyParsing() const {
|
||||
// If we are inside a block scope, we must parse eagerly to find out how
|
||||
// to allocate variables on the block scope. At this point, declarations may
|
||||
@ -919,7 +895,14 @@ bool Scope::AllowsLazyCompilation() const { return !force_eager_compilation_; }
|
||||
|
||||
|
||||
bool Scope::AllowsLazyCompilationWithoutContext() const {
|
||||
return !force_eager_compilation_ && HasTrivialOuterContext();
|
||||
if (force_eager_compilation_) return false;
|
||||
// Disallow lazy compilation without context if any outer scope needs a
|
||||
// context.
|
||||
for (const Scope* scope = outer_scope_; scope != nullptr;
|
||||
scope = scope->outer_scope_) {
|
||||
if (scope->NeedsContext()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1163,9 +1146,6 @@ void Scope::Print(int n) {
|
||||
}
|
||||
|
||||
// Scope info.
|
||||
if (HasTrivialOuterContext()) {
|
||||
Indent(n1, "// scope has trivial outer context\n");
|
||||
}
|
||||
if (is_strict(language_mode())) {
|
||||
Indent(n1, "// strict mode scope\n");
|
||||
}
|
||||
|
@ -382,9 +382,6 @@ class Scope: public ZoneObject {
|
||||
// Determine if we can use lazy compilation for this scope without a context.
|
||||
bool AllowsLazyCompilationWithoutContext() const;
|
||||
|
||||
// True if the outer context of this scope is always the native context.
|
||||
bool HasTrivialOuterContext() const;
|
||||
|
||||
// The number of contexts between this and scope; zero if this == scope.
|
||||
int ContextChainLength(Scope* scope);
|
||||
|
||||
@ -593,17 +590,8 @@ 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;
|
||||
|
||||
// Predicates.
|
||||
bool MustAllocate(Variable* var);
|
||||
|
Loading…
Reference in New Issue
Block a user