Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: src/ast/scopes.cc

Issue 2263123002: Find the last outer eval scope to check in fullcodegen rather than scope analysis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add ports Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/full-codegen/arm/full-codegen-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 372ab769de518e1aeab8e309116e1bd6c87f69b6..0002fe783ea216877406fa015fbc54e0e4bdb98d 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -214,7 +214,6 @@ void Scope::SetDefaults() {
is_hidden_ = false;
is_debug_evaluate_scope_ = false;
- outer_scope_calls_sloppy_eval_ = false;
inner_scope_calls_eval_ = false;
force_eager_compilation_ = false;
force_context_allocation_ = false;
@@ -297,7 +296,7 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
}
script_scope->AddInnerScope(current_scope);
- script_scope->PropagateScopeInfo(false);
+ script_scope->PropagateScopeInfo();
return (innermost_scope == NULL) ? script_scope : innermost_scope;
}
@@ -864,13 +863,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
void DeclarationScope::AllocateVariables(ParseInfo* info,
AstNodeFactory* factory) {
// 1) Propagate scope information.
- bool outer_scope_calls_sloppy_eval = false;
- if (outer_scope_ != NULL) {
- outer_scope_calls_sloppy_eval =
- outer_scope_->outer_scope_calls_sloppy_eval() |
- outer_scope_->calls_sloppy_eval();
- }
- PropagateScopeInfo(outer_scope_calls_sloppy_eval);
+ PropagateScopeInfo();
// 2) Resolve variables.
ResolveVariablesRecursively(info, factory);
@@ -905,16 +898,27 @@ bool Scope::AllowsLazyCompilationWithoutContext() const {
return true;
}
-
-int Scope::ContextChainLength(Scope* scope) {
+int Scope::ContextChainLength(Scope* scope) const {
int n = 0;
- for (Scope* s = this; s != scope; s = s->outer_scope_) {
+ for (const Scope* s = this; s != scope; s = s->outer_scope_) {
DCHECK(s != NULL); // scope must be in the scope chain
if (s->NeedsContext()) n++;
}
return n;
}
+int Scope::ContextChainLengthUntilOutermostSloppyEval() const {
+ int result = 0;
+ int length = 0;
+
+ for (const Scope* s = this; s != nullptr; s = s->outer_scope()) {
+ if (!s->NeedsContext()) continue;
+ length++;
+ if (s->calls_sloppy_eval()) result = length;
+ }
+
+ return result;
+}
int Scope::MaxNestedContextChainLength() {
int max_context_chain_length = 0;
@@ -976,7 +980,7 @@ Handle<StringSet> DeclarationScope::CollectNonLocals(
void DeclarationScope::AnalyzePartially(DeclarationScope* migrate_to,
AstNodeFactory* ast_node_factory) {
// Gather info from inner scopes.
- PropagateScopeInfo(false);
+ PropagateScopeInfo();
// Try to resolve unresolved variables for this Scope and migrate those which
// cannot be resolved inside. It doesn't make sense to try to resolve them in
@@ -1154,9 +1158,6 @@ void Scope::Print(int n) {
if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
if (scope_uses_super_property_)
Indent(n1, "// scope uses 'super' property\n");
- if (outer_scope_calls_sloppy_eval_) {
- Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
- }
if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
if (num_stack_slots_ > 0) {
Indent(n1, "// ");
@@ -1464,15 +1465,9 @@ VariableProxy* Scope::FetchFreeVariables(DeclarationScope* max_outer_scope,
return stack;
}
-void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval) {
- if (outer_scope_calls_sloppy_eval) {
- outer_scope_calls_sloppy_eval_ = true;
- }
-
- bool calls_sloppy_eval =
- this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_;
+void Scope::PropagateScopeInfo() {
for (Scope* inner = inner_scope_; inner != nullptr; inner = inner->sibling_) {
- inner->PropagateScopeInfo(calls_sloppy_eval);
+ inner->PropagateScopeInfo();
if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) {
inner_scope_calls_eval_ = true;
}
« no previous file with comments | « src/ast/scopes.h ('k') | src/full-codegen/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698