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

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

Issue 2465283004: [modules] Maintain array of cells for imports and local exports. (Closed)
Patch Set: Rename parameter also in header file. Created 4 years, 1 month 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/parsing/scanner.h" // Only for Scanner::Location. 8 #include "src/parsing/scanner.h" // Only for Scanner::Location.
9 #include "src/pending-compilation-error-handler.h" 9 #include "src/pending-compilation-error-handler.h"
10 #include "src/zone/zone-containers.h" 10 #include "src/zone/zone-containers.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const AstRawString* local_name; 79 const AstRawString* local_name;
80 const AstRawString* import_name; 80 const AstRawString* import_name;
81 81
82 // The module_request value records the order in which modules are 82 // The module_request value records the order in which modules are
83 // requested. It also functions as an index into the ModuleInfo's array of 83 // requested. It also functions as an index into the ModuleInfo's array of
84 // module specifiers and into the Module's array of requested modules. A 84 // module specifiers and into the Module's array of requested modules. A
85 // negative value means no module request. 85 // negative value means no module request.
86 int module_request; 86 int module_request;
87 87
88 // Import/export entries that are associated with a MODULE-allocated 88 // Import/export entries that are associated with a MODULE-allocated
89 // variable use the cell_index value to encode the location of their cell. 89 // variable (i.e. regular_imports and regular_exports after Validate) use
90 // Negative values are used for imports and positive values for exports. 90 // the cell_index value to encode the location of their cell. During
91 // For entries that are not associated with a MODULE-allocated variable, 91 // variable allocation, this will be be copied into the variable's index
92 // cell_index is 0. 92 // field.
93 // Entries that are not associated with a MODULE-allocated variable have
94 // GetCellIndexKind(cell_index) == kInvalid.
93 int cell_index; 95 int cell_index;
94 96
95 // TODO(neis): Remove local_name component? 97 // TODO(neis): Remove local_name component?
96 explicit Entry(Scanner::Location loc) 98 explicit Entry(Scanner::Location loc)
97 : location(loc), 99 : location(loc),
98 export_name(nullptr), 100 export_name(nullptr),
99 local_name(nullptr), 101 local_name(nullptr),
100 import_name(nullptr), 102 import_name(nullptr),
101 module_request(-1), 103 module_request(-1),
102 cell_index(0) {} 104 cell_index(0) {}
103 105
104 // (De-)serialization support. 106 // (De-)serialization support.
105 // Note that the location value is not preserved as it's only needed by the 107 // Note that the location value is not preserved as it's only needed by the
106 // parser. (A Deserialize'd entry has an invalid location.) 108 // parser. (A Deserialize'd entry has an invalid location.)
107 Handle<ModuleInfoEntry> Serialize(Isolate* isolate) const; 109 Handle<ModuleInfoEntry> Serialize(Isolate* isolate) const;
108 static Entry* Deserialize(Isolate* isolate, AstValueFactory* avfactory, 110 static Entry* Deserialize(Isolate* isolate, AstValueFactory* avfactory,
109 Handle<ModuleInfoEntry> entry); 111 Handle<ModuleInfoEntry> entry);
110 }; 112 };
111 113
114 enum CellIndexKind { kInvalid, kExport, kImport };
115 static CellIndexKind GetCellIndexKind(int cell_index);
116
112 // Module requests. 117 // Module requests.
113 const ZoneMap<const AstRawString*, int>& module_requests() const { 118 const ZoneMap<const AstRawString*, int>& module_requests() const {
114 return module_requests_; 119 return module_requests_;
115 } 120 }
116 121
117 // Namespace imports. 122 // Namespace imports.
118 const ZoneList<const Entry*>& namespace_imports() const { 123 const ZoneList<const Entry*>& namespace_imports() const {
119 return namespace_imports_; 124 return namespace_imports_;
120 } 125 }
121 126
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 .insert(std::make_pair(specifier, module_requests_.size())) 218 .insert(std::make_pair(specifier, module_requests_.size()))
214 .first; 219 .first;
215 return it->second; 220 return it->second;
216 } 221 }
217 }; 222 };
218 223
219 } // namespace internal 224 } // namespace internal
220 } // namespace v8 225 } // namespace v8
221 226
222 #endif // V8_AST_MODULES_H_ 227 #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