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

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

Issue 1598433006: [ast cleanup] Remove unnecessary frozen_ bit from ModuleDescriptor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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/modules.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_MODULES_H_ 5 #ifndef V8_AST_MODULES_H_
6 #define V8_AST_MODULES_H_ 6 #define V8_AST_MODULES_H_
7 7
8 #include "src/zone.h" 8 #include "src/zone.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 13
14 class AstRawString; 14 class AstRawString;
15 15
16 16
17 class ModuleDescriptor : public ZoneObject { 17 class ModuleDescriptor : public ZoneObject {
18 public: 18 public:
19 // --------------------------------------------------------------------------- 19 // ---------------------------------------------------------------------------
20 // Factory methods. 20 // Factory methods.
21 21
22 static ModuleDescriptor* New(Zone* zone) { 22 static ModuleDescriptor* New(Zone* zone) {
23 return new (zone) ModuleDescriptor(zone); 23 return new (zone) ModuleDescriptor(zone);
24 } 24 }
25 25
26 // --------------------------------------------------------------------------- 26 // ---------------------------------------------------------------------------
27 // Mutators. 27 // Mutators.
28 28
29 // Add a name to the list of exports. If it already exists, or this descriptor 29 // Add a name to the list of exports. If it already exists, that's an error.
30 // is frozen, that's an error.
31 void AddLocalExport(const AstRawString* export_name, 30 void AddLocalExport(const AstRawString* export_name,
32 const AstRawString* local_name, Zone* zone, bool* ok); 31 const AstRawString* local_name, Zone* zone, bool* ok);
33 32
34 // Add module_specifier to the list of requested modules, 33 // Add module_specifier to the list of requested modules,
35 // if not already present. 34 // if not already present.
36 void AddModuleRequest(const AstRawString* module_specifier, Zone* zone); 35 void AddModuleRequest(const AstRawString* module_specifier, Zone* zone);
37 36
38 // Do not allow any further refinements, directly or through unification.
39 void Freeze() { frozen_ = true; }
40
41 // Assign an index. 37 // Assign an index.
42 void Allocate(int index) { 38 void Allocate(int index) {
43 DCHECK(IsFrozen() && index_ == -1); 39 DCHECK_EQ(-1, index_);
44 index_ = index; 40 index_ = index;
45 } 41 }
46 42
47 // --------------------------------------------------------------------------- 43 // ---------------------------------------------------------------------------
48 // Accessors. 44 // Accessors.
49 45
50 // Check whether this is closed (i.e. fully determined).
51 bool IsFrozen() { return frozen_; }
52
53 int Length() { 46 int Length() {
54 DCHECK(IsFrozen());
55 ZoneHashMap* exports = exports_; 47 ZoneHashMap* exports = exports_;
56 return exports ? exports->occupancy() : 0; 48 return exports ? exports->occupancy() : 0;
57 } 49 }
58 50
59 // The context slot in the hosting script context pointing to this module. 51 // The context slot in the hosting script context pointing to this module.
60 int Index() { 52 int Index() {
61 DCHECK(IsFrozen());
62 return index_; 53 return index_;
63 } 54 }
64 55
65 const AstRawString* LookupLocalExport(const AstRawString* export_name, 56 const AstRawString* LookupLocalExport(const AstRawString* export_name,
66 Zone* zone); 57 Zone* zone);
67 58
68 const ZoneList<const AstRawString*>& requested_modules() const { 59 const ZoneList<const AstRawString*>& requested_modules() const {
69 return requested_modules_; 60 return requested_modules_;
70 } 61 }
71 62
(...skipping 25 matching lines...) Expand all
97 const ZoneHashMap* exports_; 88 const ZoneHashMap* exports_;
98 ZoneHashMap::Entry* entry_; 89 ZoneHashMap::Entry* entry_;
99 }; 90 };
100 91
101 Iterator iterator() const { return Iterator(this->exports_); } 92 Iterator iterator() const { return Iterator(this->exports_); }
102 93
103 // --------------------------------------------------------------------------- 94 // ---------------------------------------------------------------------------
104 // Implementation. 95 // Implementation.
105 private: 96 private:
106 explicit ModuleDescriptor(Zone* zone) 97 explicit ModuleDescriptor(Zone* zone)
107 : frozen_(false), 98 : exports_(NULL), requested_modules_(1, zone), index_(-1) {}
108 exports_(NULL),
109 requested_modules_(1, zone),
110 index_(-1) {}
111 99
112 bool frozen_;
113 ZoneHashMap* exports_; // Module exports and their types (allocated lazily) 100 ZoneHashMap* exports_; // Module exports and their types (allocated lazily)
114 ZoneList<const AstRawString*> requested_modules_; 101 ZoneList<const AstRawString*> requested_modules_;
115 int index_; 102 int index_;
116 }; 103 };
117 104
118 } // namespace internal 105 } // namespace internal
119 } // namespace v8 106 } // namespace v8
120 107
121 #endif // V8_AST_MODULES_H_ 108 #endif // V8_AST_MODULES_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/modules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698