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

Unified Diff: src/ast/scopes.cc

Issue 2224593002: Don't analyze scopes outside of the compiled scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | no next file » | 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 09bb6d4e0507e488e5d853b2341718d33b553ead..a11689f67a6a261717f4d8011a6a4173a46e6deb 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -376,21 +376,19 @@ int Scope::num_parameters() const {
void Scope::Analyze(ParseInfo* info) {
DCHECK(info->literal() != NULL);
DeclarationScope* scope = info->literal()->scope();
- DeclarationScope* top = scope;
- // Traverse the scope tree up to the first unresolved scope or the global
- // scope and start scope resolution and variable allocation from that scope.
- // Such a scope is always a closure-scope, so always skip to the next closure
- // scope.
- while (!top->is_script_scope() &&
- !top->outer_scope()->already_resolved()) {
- top = top->outer_scope()->GetClosureScope();
- }
+ // We are compiling one of three cases:
+ // 1) top-level code,
+ // 2) a function/eval/module on the top-level
+ // 3) a function/eval in a scope that was already resolved.
bradnelson 2016/08/07 03:05:24 You can also be compiling the text of an Asm.js mo
+ DCHECK(scope->scope_type() == SCRIPT_SCOPE ||
+ scope->outer_scope()->scope_type() == SCRIPT_SCOPE ||
+ scope->outer_scope()->already_resolved());
// Allocate the variables.
{
AstNodeFactory ast_node_factory(info->ast_value_factory());
- top->AllocateVariables(info, &ast_node_factory);
+ scope->AllocateVariables(info, &ast_node_factory);
}
#ifdef DEBUG
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698