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

Side by Side Diff: src/ast/scopes.h

Issue 2229373002: Fix CollectNonLocals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address offline comment 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 | src/ast/scopes.cc » ('j') | 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 #ifndef V8_AST_SCOPES_H_ 5 #ifndef V8_AST_SCOPES_H_
6 #define V8_AST_SCOPES_H_ 6 #define V8_AST_SCOPES_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/base/hashmap.h" 9 #include "src/base/hashmap.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // the scope for which a function prologue allocates a context) or declaring 407 // the scope for which a function prologue allocates a context) or declaring
408 // temporaries. 408 // temporaries.
409 DeclarationScope* GetClosureScope(); 409 DeclarationScope* GetClosureScope();
410 410
411 // Find the first (non-arrow) function or script scope. This is where 411 // Find the first (non-arrow) function or script scope. This is where
412 // 'this' is bound, and what determines the function kind. 412 // 'this' is bound, and what determines the function kind.
413 DeclarationScope* GetReceiverScope(); 413 DeclarationScope* GetReceiverScope();
414 414
415 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate); 415 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate);
416 416
417 Handle<StringSet> CollectNonLocals(Handle<StringSet> non_locals);
418
419 // --------------------------------------------------------------------------- 417 // ---------------------------------------------------------------------------
420 // Strict mode support. 418 // Strict mode support.
421 bool IsDeclared(const AstRawString* name) { 419 bool IsDeclared(const AstRawString* name) {
422 // During formal parameter list parsing the scope only contains 420 // During formal parameter list parsing the scope only contains
423 // two variables inserted at initialization: "this" and "arguments". 421 // two variables inserted at initialization: "this" and "arguments".
424 // "this" is an invalid parameter name and "arguments" is invalid parameter 422 // "this" is an invalid parameter name and "arguments" is invalid parameter
425 // name in strict mode. Therefore looking up with the map which includes 423 // name in strict mode. Therefore looking up with the map which includes
426 // "this" and "arguments" in addition to all formal parameters is safe. 424 // "this" and "arguments" in addition to all formal parameters is safe.
427 return variables_.Lookup(name) != NULL; 425 return variables_.Lookup(name) != NULL;
428 } 426 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 DYNAMIC_LOOKUP 570 DYNAMIC_LOOKUP
573 }; 571 };
574 572
575 // Lookup a variable reference given by name recursively starting with this 573 // Lookup a variable reference given by name recursively starting with this
576 // scope, but only until max_outer_scope (if not nullptr). If the code is 574 // scope, but only until max_outer_scope (if not nullptr). If the code is
577 // executed because of a call to 'eval', the context parameter should be set 575 // executed because of a call to 'eval', the context parameter should be set
578 // to the calling context of 'eval'. 576 // to the calling context of 'eval'.
579 Variable* LookupRecursive(VariableProxy* proxy, BindingKind* binding_kind, 577 Variable* LookupRecursive(VariableProxy* proxy, BindingKind* binding_kind,
580 AstNodeFactory* factory, 578 AstNodeFactory* factory,
581 Scope* max_outer_scope = nullptr); 579 Scope* max_outer_scope = nullptr);
580 void ResolveTo(ParseInfo* info, BindingKind binding_kind,
581 VariableProxy* proxy, Variable* var);
582 void ResolveVariable(ParseInfo* info, VariableProxy* proxy, 582 void ResolveVariable(ParseInfo* info, VariableProxy* proxy,
583 AstNodeFactory* factory); 583 AstNodeFactory* factory);
584 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); 584 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory);
585 585
586 // Tries to resolve local variables inside max_outer_scope; migrates those 586 // Finds free variables of this scope. This mutates the unresolved variables
587 // which cannot be resolved into migrate_to. 587 // list along the way, so full resolution cannot be done afterwards.
588 void MigrateUnresolvableLocals(DeclarationScope* migrate_to, 588 // If a ParseInfo* is passed, non-free variables will be resolved.
589 AstNodeFactory* ast_node_factory, 589 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope,
590 DeclarationScope* max_outer_scope); 590 ParseInfo* info = nullptr,
591 VariableProxy* stack = nullptr);
591 592
592 // Scope analysis. 593 // Scope analysis.
593 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); 594 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval);
594 bool HasTrivialContext() const; 595 bool HasTrivialContext() const;
595 596
596 // Predicates. 597 // Predicates.
597 bool MustAllocate(Variable* var); 598 bool MustAllocate(Variable* var);
598 bool MustAllocateInContext(Variable* var); 599 bool MustAllocateInContext(Variable* var);
599 600
600 // Variable allocation. 601 // Variable allocation.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 void AllocateVariables(ParseInfo* info, AstNodeFactory* factory); 843 void AllocateVariables(ParseInfo* info, AstNodeFactory* factory);
843 844
844 // To be called during parsing. Do just enough scope analysis that we can 845 // To be called during parsing. Do just enough scope analysis that we can
845 // discard the Scope for lazily compiled functions. In particular, this 846 // discard the Scope for lazily compiled functions. In particular, this
846 // records variables which cannot be resolved inside the Scope (we don't yet 847 // records variables which cannot be resolved inside the Scope (we don't yet
847 // know what they will resolve to since the outer Scopes are incomplete) and 848 // know what they will resolve to since the outer Scopes are incomplete) and
848 // migrates them into migrate_to. 849 // migrates them into migrate_to.
849 void AnalyzePartially(DeclarationScope* migrate_to, 850 void AnalyzePartially(DeclarationScope* migrate_to,
850 AstNodeFactory* ast_node_factory); 851 AstNodeFactory* ast_node_factory);
851 852
853 Handle<StringSet> CollectNonLocals(ParseInfo* info,
854 Handle<StringSet> non_locals);
855
852 #ifdef DEBUG 856 #ifdef DEBUG
853 void PrintParameters(); 857 void PrintParameters();
854 #endif 858 #endif
855 859
856 void AllocateLocals(AstValueFactory* ast_value_factory); 860 void AllocateLocals(AstValueFactory* ast_value_factory);
857 void AllocateParameterLocals(); 861 void AllocateParameterLocals();
858 void AllocateReceiver(); 862 void AllocateReceiver();
859 // Set MODULE as VariableLocation for all variables that will live in some 863 // Set MODULE as VariableLocation for all variables that will live in some
860 // module's export table. 864 // module's export table.
861 void AllocateModuleVariables(); 865 void AllocateModuleVariables();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 // Convenience variable; Subclass constructor only 897 // Convenience variable; Subclass constructor only
894 Variable* this_function_; 898 Variable* this_function_;
895 // Module descriptor; module scopes only. 899 // Module descriptor; module scopes only.
896 ModuleDescriptor* module_descriptor_; 900 ModuleDescriptor* module_descriptor_;
897 }; 901 };
898 902
899 } // namespace internal 903 } // namespace internal
900 } // namespace v8 904 } // namespace v8
901 905
902 #endif // V8_AST_SCOPES_H_ 906 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698