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

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

Issue 2351393003: [base] Revert "Move hashmap allocator to a field" (Closed)
Patch Set: Whoops, patch sets should build 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 | « src/ast/ast.cc ('k') | 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 17 matching lines...) Expand all
28 explicit VariableMap(Zone* zone); 28 explicit VariableMap(Zone* zone);
29 29
30 Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name, 30 Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name,
31 VariableMode mode, VariableKind kind, 31 VariableMode mode, VariableKind kind,
32 InitializationFlag initialization_flag, 32 InitializationFlag initialization_flag,
33 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, 33 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
34 bool* added = nullptr); 34 bool* added = nullptr);
35 35
36 Variable* Lookup(const AstRawString* name); 36 Variable* Lookup(const AstRawString* name);
37 void Remove(Variable* var); 37 void Remove(Variable* var);
38 void Add(Variable* var); 38 void Add(Zone* zone, Variable* var);
39 }; 39 };
40 40
41 41
42 // Sloppy block-scoped function declarations to var-bind 42 // Sloppy block-scoped function declarations to var-bind
43 class SloppyBlockFunctionMap : public ZoneHashMap { 43 class SloppyBlockFunctionMap : public ZoneHashMap {
44 public: 44 public:
45 explicit SloppyBlockFunctionMap(Zone* zone); 45 explicit SloppyBlockFunctionMap(Zone* zone);
46 void Declare(const AstRawString* name, 46 void Declare(Zone* zone, const AstRawString* name,
47 SloppyBlockFunctionStatement* statement); 47 SloppyBlockFunctionStatement* statement);
48 }; 48 };
49 49
50 enum class AnalyzeMode { kRegular, kDebugger }; 50 enum class AnalyzeMode { kRegular, kDebugger };
51 51
52 // Global invariants after AST construction: Each reference (i.e. identifier) 52 // Global invariants after AST construction: Each reference (i.e. identifier)
53 // to a JavaScript variable (including global properties) is represented by a 53 // to a JavaScript variable (including global properties) is represented by a
54 // VariableProxy node. Immediately after AST construction and before variable 54 // VariableProxy node. Immediately after AST construction and before variable
55 // allocation, most VariableProxy nodes are "unresolved", i.e. not bound to a 55 // allocation, most VariableProxy nodes are "unresolved", i.e. not bound to a
56 // corresponding variable (though some are bound during parse time). Variable 56 // corresponding variable (though some are bound during parse time). Variable
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 // initializers. 749 // initializers.
750 void AddLocal(Variable* var) { 750 void AddLocal(Variable* var) {
751 DCHECK(!already_resolved_); 751 DCHECK(!already_resolved_);
752 // Temporaries are only placed in ClosureScopes. 752 // Temporaries are only placed in ClosureScopes.
753 DCHECK_EQ(GetClosureScope(), this); 753 DCHECK_EQ(GetClosureScope(), this);
754 locals_.Add(var, zone()); 754 locals_.Add(var, zone());
755 } 755 }
756 756
757 void DeclareSloppyBlockFunction(const AstRawString* name, 757 void DeclareSloppyBlockFunction(const AstRawString* name,
758 SloppyBlockFunctionStatement* statement) { 758 SloppyBlockFunctionStatement* statement) {
759 sloppy_block_function_map_.Declare(name, statement); 759 sloppy_block_function_map_.Declare(zone(), name, statement);
760 } 760 }
761 761
762 // Go through sloppy_block_function_map_ and hoist those (into this scope) 762 // Go through sloppy_block_function_map_ and hoist those (into this scope)
763 // which should be hoisted. 763 // which should be hoisted.
764 void HoistSloppyBlockFunctions(AstNodeFactory* factory); 764 void HoistSloppyBlockFunctions(AstNodeFactory* factory);
765 765
766 SloppyBlockFunctionMap* sloppy_block_function_map() { 766 SloppyBlockFunctionMap* sloppy_block_function_map() {
767 return &sloppy_block_function_map_; 767 return &sloppy_block_function_map_;
768 } 768 }
769 769
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 void AllocateModuleVariables(); 877 void AllocateModuleVariables();
878 878
879 private: 879 private:
880 ModuleDescriptor* module_descriptor_; 880 ModuleDescriptor* module_descriptor_;
881 }; 881 };
882 882
883 } // namespace internal 883 } // namespace internal
884 } // namespace v8 884 } // namespace v8
885 885
886 #endif // V8_AST_SCOPES_H_ 886 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698