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

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

Issue 2379533003: Revert of Don't use different function scopes when parsing with temp zones (Closed)
Patch Set: Created 4 years, 2 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/base/hashmap.h" 8 #include "src/base/hashmap.h"
9 #include "src/globals.h" 9 #include "src/globals.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // --------------------------------------------------------------------------- 67 // ---------------------------------------------------------------------------
68 // Construction 68 // Construction
69 69
70 Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type); 70 Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type);
71 71
72 #ifdef DEBUG 72 #ifdef DEBUG
73 // The scope name is only used for printing/debugging. 73 // The scope name is only used for printing/debugging.
74 void SetScopeName(const AstRawString* scope_name) { 74 void SetScopeName(const AstRawString* scope_name) {
75 scope_name_ = scope_name; 75 scope_name_ = scope_name;
76 } 76 }
77 void set_needs_migration() { needs_migration_ = true; }
78 #endif 77 #endif
79 78
80 // TODO(verwaest): Is this needed on Scope? 79 // TODO(verwaest): Is this needed on Scope?
81 int num_parameters() const; 80 int num_parameters() const;
82 81
83 DeclarationScope* AsDeclarationScope(); 82 DeclarationScope* AsDeclarationScope();
84 const DeclarationScope* AsDeclarationScope() const; 83 const DeclarationScope* AsDeclarationScope() const;
85 ModuleScope* AsModuleScope(); 84 ModuleScope* AsModuleScope();
86 const ModuleScope* AsModuleScope() const; 85 const ModuleScope* AsModuleScope() const;
87 86
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 408
410 // Check that all Scopes in the scope tree use the same Zone. 409 // Check that all Scopes in the scope tree use the same Zone.
411 void CheckZones(); 410 void CheckZones();
412 #endif 411 #endif
413 412
414 // Retrieve `IsSimpleParameterList` of current or outer function. 413 // Retrieve `IsSimpleParameterList` of current or outer function.
415 bool HasSimpleParameters(); 414 bool HasSimpleParameters();
416 void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; } 415 void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; }
417 bool is_debug_evaluate_scope() const { return is_debug_evaluate_scope_; } 416 bool is_debug_evaluate_scope() const { return is_debug_evaluate_scope_; }
418 417
419 bool is_lazily_parsed() const { return is_lazily_parsed_; } 418 void set_is_lazily_parsed(bool is_lazily_parsed) {
419 is_lazily_parsed_ = is_lazily_parsed;
420 }
420 421
421 protected: 422 protected:
422 explicit Scope(Zone* zone); 423 explicit Scope(Zone* zone);
423 424
424 void set_language_mode(LanguageMode language_mode) { 425 void set_language_mode(LanguageMode language_mode) {
425 is_strict_ = is_strict(language_mode); 426 is_strict_ = is_strict(language_mode);
426 } 427 }
427 428
428 private: 429 private:
429 Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name, 430 Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 ZoneList<Declaration*> decls_; 478 ZoneList<Declaration*> decls_;
478 479
479 // Serialized scope info support. 480 // Serialized scope info support.
480 Handle<ScopeInfo> scope_info_; 481 Handle<ScopeInfo> scope_info_;
481 // Debugging support. 482 // Debugging support.
482 #ifdef DEBUG 483 #ifdef DEBUG
483 const AstRawString* scope_name_; 484 const AstRawString* scope_name_;
484 485
485 // True if it doesn't need scope resolution (e.g., if the scope was 486 // True if it doesn't need scope resolution (e.g., if the scope was
486 // constructed based on a serialized scope info or a catch context). 487 // constructed based on a serialized scope info or a catch context).
487 bool already_resolved_; 488 bool already_resolved_ : 1;
488 // True if this scope may contain objects from a temp zone that needs to be
489 // fixed up.
490 bool needs_migration_;
491 #endif 489 #endif
492 490
493 // Source positions. 491 // Source positions.
494 int start_position_; 492 int start_position_;
495 int end_position_; 493 int end_position_;
496 494
497 // Computed via AllocateVariables. 495 // Computed via AllocateVariables.
498 int num_stack_slots_; 496 int num_stack_slots_;
499 int num_heap_slots_; 497 int num_heap_slots_;
500 498
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 MaybeHandle<ScopeInfo> outer_scope); 559 MaybeHandle<ScopeInfo> outer_scope);
562 560
563 // Construct a scope based on the scope info. 561 // Construct a scope based on the scope info.
564 Scope(Zone* zone, ScopeType type, Handle<ScopeInfo> scope_info); 562 Scope(Zone* zone, ScopeType type, Handle<ScopeInfo> scope_info);
565 563
566 // Construct a catch scope with a binding for the name. 564 // Construct a catch scope with a binding for the name.
567 Scope(Zone* zone, const AstRawString* catch_variable_name, 565 Scope(Zone* zone, const AstRawString* catch_variable_name,
568 Handle<ScopeInfo> scope_info); 566 Handle<ScopeInfo> scope_info);
569 567
570 void AddInnerScope(Scope* inner_scope) { 568 void AddInnerScope(Scope* inner_scope) {
571 DCHECK_EQ(!needs_migration_, inner_scope->zone() == zone());
572 inner_scope->sibling_ = inner_scope_; 569 inner_scope->sibling_ = inner_scope_;
573 inner_scope_ = inner_scope; 570 inner_scope_ = inner_scope;
574 inner_scope->outer_scope_ = this; 571 inner_scope->outer_scope_ = this;
575 } 572 }
576 573
577 void RemoveInnerScope(Scope* inner_scope) { 574 void RemoveInnerScope(Scope* inner_scope) {
578 DCHECK_NOT_NULL(inner_scope); 575 DCHECK_NOT_NULL(inner_scope);
579 if (inner_scope == inner_scope_) { 576 if (inner_scope == inner_scope_) {
580 inner_scope_ = inner_scope_->sibling_; 577 inner_scope_ = inner_scope_->sibling_;
581 return; 578 return;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // Compute top scope and allocate variables. For lazy compilation the top 772 // Compute top scope and allocate variables. For lazy compilation the top
776 // scope only contains the single lazily compiled function, so this 773 // scope only contains the single lazily compiled function, so this
777 // doesn't re-allocate variables repeatedly. 774 // doesn't re-allocate variables repeatedly.
778 static void Analyze(ParseInfo* info, AnalyzeMode mode); 775 static void Analyze(ParseInfo* info, AnalyzeMode mode);
779 776
780 // To be called during parsing. Do just enough scope analysis that we can 777 // To be called during parsing. Do just enough scope analysis that we can
781 // discard the Scope for lazily compiled functions. In particular, this 778 // discard the Scope for lazily compiled functions. In particular, this
782 // records variables which cannot be resolved inside the Scope (we don't yet 779 // records variables which cannot be resolved inside the Scope (we don't yet
783 // know what they will resolve to since the outer Scopes are incomplete) and 780 // know what they will resolve to since the outer Scopes are incomplete) and
784 // migrates them into migrate_to. 781 // migrates them into migrate_to.
785 void AnalyzePartially(AstNodeFactory* ast_node_factory); 782 void AnalyzePartially(DeclarationScope* migrate_to,
783 AstNodeFactory* ast_node_factory);
786 784
787 Handle<StringSet> CollectNonLocals(ParseInfo* info, 785 Handle<StringSet> CollectNonLocals(ParseInfo* info,
788 Handle<StringSet> non_locals); 786 Handle<StringSet> non_locals);
789 787
790 // Determine if we can use lazy compilation for this scope. 788 // Determine if we can use lazy compilation for this scope.
791 bool AllowsLazyCompilation() const; 789 bool AllowsLazyCompilation() const;
792 790
793 // Determine if we can use lazy compilation for this scope without a context. 791 // Determine if we can use lazy compilation for this scope without a context.
794 bool AllowsLazyCompilationWithoutContext() const; 792 bool AllowsLazyCompilationWithoutContext() const;
795 793
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 void AllocateModuleVariables(); 881 void AllocateModuleVariables();
884 882
885 private: 883 private:
886 ModuleDescriptor* module_descriptor_; 884 ModuleDescriptor* module_descriptor_;
887 }; 885 };
888 886
889 } // namespace internal 887 } // namespace internal
890 } // namespace v8 888 } // namespace v8
891 889
892 #endif // V8_AST_SCOPES_H_ 890 #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