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

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

Issue 2306413002: Fully deserialize the scope chain after parsing, not before (Closed)
Patch Set: cleanup Created 4 years, 3 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
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void Reparent(DeclarationScope* new_parent) const; 91 void Reparent(DeclarationScope* new_parent) const;
92 92
93 private: 93 private:
94 Scope* outer_scope_; 94 Scope* outer_scope_;
95 Scope* top_inner_scope_; 95 Scope* top_inner_scope_;
96 VariableProxy* top_unresolved_; 96 VariableProxy* top_unresolved_;
97 int top_local_; 97 int top_local_;
98 int top_decl_; 98 int top_decl_;
99 }; 99 };
100 100
101 enum class DeserializationMode { kDeserializeOffHeap, kKeepScopeInfo }; 101 enum class DeserializationMode { kIncludingVariables, kScopesOnly };
102 102
103 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, 103 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
104 Context* context, 104 Context* context,
105 DeclarationScope* script_scope, 105 DeclarationScope* script_scope,
106 AstValueFactory* ast_value_factory, 106 AstValueFactory* ast_value_factory,
107 DeserializationMode deserialization_mode); 107 DeserializationMode deserialization_mode);
108 108
109 // Checks if the block scope is redundant, i.e. it does not contain any 109 // Checks if the block scope is redundant, i.e. it does not contain any
110 // block scoped declarations. In that case it is removed from the scope 110 // block scoped declarations. In that case it is removed from the scope
111 // tree and its children are reparented. 111 // tree and its children are reparented.
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 scope = scope->sibling_) { 568 scope = scope->sibling_) {
569 if (scope->sibling_ == inner_scope) { 569 if (scope->sibling_ == inner_scope) {
570 scope->sibling_ = scope->sibling_->sibling_; 570 scope->sibling_ = scope->sibling_->sibling_;
571 return; 571 return;
572 } 572 }
573 } 573 }
574 } 574 }
575 575
576 void SetDefaults(); 576 void SetDefaults();
577 577
578 void DeserializeScopeInfo(Isolate* isolate,
579 AstValueFactory* ast_value_factory);
580
581 friend class DeclarationScope; 578 friend class DeclarationScope;
582 }; 579 };
583 580
584 class DeclarationScope : public Scope { 581 class DeclarationScope : public Scope {
585 public: 582 public:
586 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, 583 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
587 FunctionKind function_kind = kNormalFunction); 584 FunctionKind function_kind = kNormalFunction);
588 DeclarationScope(Zone* zone, ScopeType scope_type, 585 DeclarationScope(Zone* zone, ScopeType scope_type,
589 Handle<ScopeInfo> scope_info); 586 Handle<ScopeInfo> scope_info);
590 // Creates a script scope. 587 // Creates a script scope.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 locals_.Add(var, zone()); 737 locals_.Add(var, zone());
741 } 738 }
742 739
743 void DeclareSloppyBlockFunction(const AstRawString* name, 740 void DeclareSloppyBlockFunction(const AstRawString* name,
744 SloppyBlockFunctionStatement* statement) { 741 SloppyBlockFunctionStatement* statement) {
745 sloppy_block_function_map_.Declare(zone(), name, statement); 742 sloppy_block_function_map_.Declare(zone(), name, statement);
746 } 743 }
747 744
748 // Go through sloppy_block_function_map_ and hoist those (into this scope) 745 // Go through sloppy_block_function_map_ and hoist those (into this scope)
749 // which should be hoisted. 746 // which should be hoisted.
750 void HoistSloppyBlockFunctions(AstNodeFactory* factory, bool* ok); 747 void HoistSloppyBlockFunctions(AstNodeFactory* factory);
751 748
752 SloppyBlockFunctionMap* sloppy_block_function_map() { 749 SloppyBlockFunctionMap* sloppy_block_function_map() {
753 return &sloppy_block_function_map_; 750 return &sloppy_block_function_map_;
754 } 751 }
755 752
756 // Compute top scope and allocate variables. For lazy compilation the top 753 // Compute top scope and allocate variables. For lazy compilation the top
757 // scope only contains the single lazily compiled function, so this 754 // scope only contains the single lazily compiled function, so this
758 // doesn't re-allocate variables repeatedly. 755 // doesn't re-allocate variables repeatedly.
759 static void Analyze(ParseInfo* info, AnalyzeMode mode); 756 static void Analyze(ParseInfo* info, AnalyzeMode mode);
760 757
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 void AllocateModuleVariables(); 855 void AllocateModuleVariables();
859 856
860 private: 857 private:
861 ModuleDescriptor* module_descriptor_; 858 ModuleDescriptor* module_descriptor_;
862 }; 859 };
863 860
864 } // namespace internal 861 } // namespace internal
865 } // namespace v8 862 } // namespace v8
866 863
867 #endif // V8_AST_SCOPES_H_ 864 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/scopes.cc » ('j') | src/ast/scopes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698