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

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

Issue 2306413002: Fully deserialize the scope chain after parsing, not before (Closed)
Patch Set: updates 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
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | src/ast/scopes.cc » ('J')
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 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 static Scope* DeserializeScopeChainForTesting(
102 102 Isolate* isolate, Zone* zone, Context* context,
103 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, 103 DeclarationScope* script_scope, AstValueFactory* ast_value_factory);
104 Context* context,
105 DeclarationScope* script_scope,
106 AstValueFactory* ast_value_factory,
107 DeserializationMode deserialization_mode);
108 104
109 // Checks if the block scope is redundant, i.e. it does not contain any 105 // 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 106 // block scoped declarations. In that case it is removed from the scope
111 // tree and its children are reparented. 107 // tree and its children are reparented.
112 Scope* FinalizeBlockScope(); 108 Scope* FinalizeBlockScope();
113 109
114 // Inserts outer_scope into this scope's scope chain (and removes this 110 // Inserts outer_scope into this scope's scope chain (and removes this
115 // from the current outer_scope_'s inner scope list). 111 // from the current outer_scope_'s inner scope list).
116 // Assumes outer_scope_ is non-null. 112 // Assumes outer_scope_ is non-null.
117 void ReplaceOuterScope(Scope* outer_scope); 113 void ReplaceOuterScope(Scope* outer_scope);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 scope = scope->sibling_) { 561 scope = scope->sibling_) {
566 if (scope->sibling_ == inner_scope) { 562 if (scope->sibling_ == inner_scope) {
567 scope->sibling_ = scope->sibling_->sibling_; 563 scope->sibling_ = scope->sibling_->sibling_;
568 return; 564 return;
569 } 565 }
570 } 566 }
571 } 567 }
572 568
573 void SetDefaults(); 569 void SetDefaults();
574 570
575 void DeserializeScopeInfo(Isolate* isolate, 571 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
576 AstValueFactory* ast_value_factory); 572 Context* context,
573 DeclarationScope* script_scope,
574 AstValueFactory* ast_value_factory);
577 575
578 friend class DeclarationScope; 576 friend class DeclarationScope;
579 }; 577 };
580 578
581 class DeclarationScope : public Scope { 579 class DeclarationScope : public Scope {
582 public: 580 public:
583 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type, 581 DeclarationScope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
584 FunctionKind function_kind = kNormalFunction); 582 FunctionKind function_kind = kNormalFunction);
585 DeclarationScope(Zone* zone, ScopeType scope_type, 583 DeclarationScope(Zone* zone, ScopeType scope_type,
586 Handle<ScopeInfo> scope_info); 584 Handle<ScopeInfo> scope_info);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 // processed (parsed) to ensure that unresolved variables can be 795 // processed (parsed) to ensure that unresolved variables can be
798 // resolved properly. 796 // resolved properly.
799 // 797 //
800 // In the case of code compiled and run using 'eval', the context 798 // In the case of code compiled and run using 'eval', the context
801 // parameter is the context in which eval was called. In all other 799 // parameter is the context in which eval was called. In all other
802 // cases the context parameter is an empty handle. 800 // cases the context parameter is an empty handle.
803 void AllocateVariables(ParseInfo* info, AnalyzeMode mode); 801 void AllocateVariables(ParseInfo* info, AnalyzeMode mode);
804 802
805 void SetDefaults(); 803 void SetDefaults();
806 804
805 void DeserializeScopeChain(ParseInfo* parse_info);
806
807 void HoistSloppyBlockFunctionsInternal(AstNodeFactory* factory, bool* ok);
808
807 // If the scope is a function scope, this is the function kind. 809 // If the scope is a function scope, this is the function kind.
808 const FunctionKind function_kind_; 810 const FunctionKind function_kind_;
809 811
810 bool has_simple_parameters_ : 1; 812 bool has_simple_parameters_ : 1;
811 // This scope contains an "use asm" annotation. 813 // This scope contains an "use asm" annotation.
812 bool asm_module_ : 1; 814 bool asm_module_ : 1;
813 // This scope's outer context is an asm module. 815 // This scope's outer context is an asm module.
814 bool asm_function_ : 1; 816 bool asm_function_ : 1;
815 bool force_eager_compilation_ : 1; 817 bool force_eager_compilation_ : 1;
816 // This function scope has a rest parameter. 818 // This function scope has a rest parameter.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 void AllocateModuleVariables(); 857 void AllocateModuleVariables();
856 858
857 private: 859 private:
858 ModuleDescriptor* module_descriptor_; 860 ModuleDescriptor* module_descriptor_;
859 }; 861 };
860 862
861 } // namespace internal 863 } // namespace internal
862 } // namespace v8 864 } // namespace v8
863 865
864 #endif // V8_AST_SCOPES_H_ 866 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | src/ast/scopes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698