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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 return static_cast<const DeclarationScope*>(this); 369 return static_cast<const DeclarationScope*>(this);
370 } 370 }
371 371
372 int Scope::num_parameters() const { 372 int Scope::num_parameters() const {
373 return is_declaration_scope() ? AsDeclarationScope()->num_parameters() : 0; 373 return is_declaration_scope() ? AsDeclarationScope()->num_parameters() : 0;
374 } 374 }
375 375
376 void Scope::Analyze(ParseInfo* info) { 376 void Scope::Analyze(ParseInfo* info) {
377 DCHECK(info->literal() != NULL); 377 DCHECK(info->literal() != NULL);
378 DeclarationScope* scope = info->literal()->scope(); 378 DeclarationScope* scope = info->literal()->scope();
379 DeclarationScope* top = scope;
380 379
381 // Traverse the scope tree up to the first unresolved scope or the global 380 // We are compiling one of three cases:
382 // scope and start scope resolution and variable allocation from that scope. 381 // 1) top-level code,
383 // Such a scope is always a closure-scope, so always skip to the next closure 382 // 2) a function/eval/module on the top-level
384 // scope. 383 // 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
385 while (!top->is_script_scope() && 384 DCHECK(scope->scope_type() == SCRIPT_SCOPE ||
386 !top->outer_scope()->already_resolved()) { 385 scope->outer_scope()->scope_type() == SCRIPT_SCOPE ||
387 top = top->outer_scope()->GetClosureScope(); 386 scope->outer_scope()->already_resolved());
388 }
389 387
390 // Allocate the variables. 388 // Allocate the variables.
391 { 389 {
392 AstNodeFactory ast_node_factory(info->ast_value_factory()); 390 AstNodeFactory ast_node_factory(info->ast_value_factory());
393 top->AllocateVariables(info, &ast_node_factory); 391 scope->AllocateVariables(info, &ast_node_factory);
394 } 392 }
395 393
396 #ifdef DEBUG 394 #ifdef DEBUG
397 if (info->script_is_native() ? FLAG_print_builtin_scopes 395 if (info->script_is_native() ? FLAG_print_builtin_scopes
398 : FLAG_print_scopes) { 396 : FLAG_print_scopes) {
399 scope->Print(); 397 scope->Print();
400 } 398 }
401 scope->CheckScopePositions(); 399 scope->CheckScopePositions();
402 scope->CheckZones(); 400 scope->CheckZones();
403 #endif 401 #endif
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 function != NULL && function->proxy()->var()->IsContextSlot(); 1770 function != NULL && function->proxy()->var()->IsContextSlot();
1773 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1771 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1774 (is_function_var_in_context ? 1 : 0); 1772 (is_function_var_in_context ? 1 : 0);
1775 } 1773 }
1776 1774
1777 1775
1778 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1776 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1779 1777
1780 } // namespace internal 1778 } // namespace internal
1781 } // namespace v8 1779 } // namespace v8
OLDNEW
« 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