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

Side by Side Diff: src/objects.h

Issue 2465283004: [modules] Maintain array of cells for imports and local exports. (Closed)
Patch Set: Various changes. 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 8158 matching lines...) Expand 10 before | Expand all | Expand 10 after
8169 DECLARE_CAST(Module) 8169 DECLARE_CAST(Module)
8170 DECLARE_VERIFIER(Module) 8170 DECLARE_VERIFIER(Module)
8171 DECLARE_PRINTER(Module) 8171 DECLARE_PRINTER(Module)
8172 8172
8173 // The code representing this Module, or an abstraction thereof. 8173 // The code representing this Module, or an abstraction thereof.
8174 // This is either a SharedFunctionInfo or a JSFunction or a ModuleInfo 8174 // This is either a SharedFunctionInfo or a JSFunction or a ModuleInfo
8175 // depending on whether the module has been instantiated and evaluated. See 8175 // depending on whether the module has been instantiated and evaluated. See
8176 // Module::ModuleVerify() for the precise invariant. 8176 // Module::ModuleVerify() for the precise invariant.
8177 DECL_ACCESSORS(code, Object) 8177 DECL_ACCESSORS(code, Object)
8178 8178
8179 // The export table. 8179 // The export table.
adamk 2016/11/03 18:30:45 This comment could be further fleshed out too (e.g
neis 2016/11/04 10:14:39 Done.
8180 DECL_ACCESSORS(exports, ObjectHashTable) 8180 DECL_ACCESSORS(exports, ObjectHashTable)
8181 8181
8182 DECL_ACCESSORS(regular_exports, FixedArray)
adamk 2016/11/03 18:30:45 Comments for these? Especially since "exports" and
neis 2016/11/04 10:14:39 Done.
8183 DECL_ACCESSORS(regular_imports, FixedArray)
8184
8182 // Hash for this object (a random non-zero Smi). 8185 // Hash for this object (a random non-zero Smi).
8183 DECL_INT_ACCESSORS(hash) 8186 DECL_INT_ACCESSORS(hash)
8184 8187
8185 // The namespace object (or undefined). 8188 // The namespace object (or undefined).
8186 DECL_ACCESSORS(module_namespace, HeapObject) 8189 DECL_ACCESSORS(module_namespace, HeapObject)
8187 8190
8188 // Modules imported or re-exported by this module. 8191 // Modules imported or re-exported by this module.
8189 // Corresponds 1-to-1 to the module specifier strings in 8192 // Corresponds 1-to-1 to the module specifier strings in
8190 // ModuleInfo::module_requests. 8193 // ModuleInfo::module_requests.
8191 DECL_ACCESSORS(requested_modules, FixedArray) 8194 DECL_ACCESSORS(requested_modules, FixedArray)
8192 8195
8193 // Get the ModuleInfo associated with the code. 8196 // Get the ModuleInfo associated with the code.
8194 inline ModuleInfo* info() const; 8197 inline ModuleInfo* info() const;
8195 8198
8196 inline bool instantiated() const; 8199 inline bool instantiated() const;
8197 inline bool evaluated() const; 8200 inline bool evaluated() const;
8198 inline void set_evaluated(); 8201 inline void set_evaluated();
8199 8202
8200 // Implementation of spec operation ModuleDeclarationInstantiation. 8203 // Implementation of spec operation ModuleDeclarationInstantiation.
8201 // Returns false if an exception occurred during instantiation, true 8204 // Returns false if an exception occurred during instantiation, true
8202 // otherwise. 8205 // otherwise.
8203 static MUST_USE_RESULT bool Instantiate(Handle<Module> module, 8206 static MUST_USE_RESULT bool Instantiate(Handle<Module> module,
8204 v8::Local<v8::Context> context, 8207 v8::Local<v8::Context> context,
8205 v8::Module::ResolveCallback callback); 8208 v8::Module::ResolveCallback callback);
8206 8209
8207 // Implementation of spec operation ModuleEvaluation. 8210 // Implementation of spec operation ModuleEvaluation.
8208 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module); 8211 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module);
8209 8212
8210 static Handle<Object> LoadExport(Handle<Module> module, Handle<String> name); 8213 static Handle<Object> LoadVariable(Handle<Module> module, int index);
8211 static void StoreExport(Handle<Module> module, Handle<String> name, 8214 static void StoreVariable(Handle<Module> module, int index,
8212 Handle<Object> value); 8215 Handle<Object> value);
8213
8214 static Handle<Object> LoadImport(Handle<Module> module, Handle<String> name,
8215 int module_request);
8216 8216
8217 // Get the namespace object for [module_request] of [module]. If it doesn't 8217 // Get the namespace object for [module_request] of [module]. If it doesn't
8218 // exist yet, it is created. 8218 // exist yet, it is created.
8219 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module, 8219 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module,
8220 int module_request); 8220 int module_request);
8221 8221
8222 static const int kCodeOffset = HeapObject::kHeaderSize; 8222 static const int kCodeOffset = HeapObject::kHeaderSize;
8223 static const int kExportsOffset = kCodeOffset + kPointerSize; 8223 static const int kExportsOffset = kCodeOffset + kPointerSize;
8224 static const int kHashOffset = kExportsOffset + kPointerSize; 8224 static const int kRegularExportsOffset = kExportsOffset + kPointerSize;
8225 static const int kRegularImportsOffset = kRegularExportsOffset + kPointerSize;
8226 static const int kHashOffset = kRegularImportsOffset + kPointerSize;
8225 static const int kModuleNamespaceOffset = kHashOffset + kPointerSize; 8227 static const int kModuleNamespaceOffset = kHashOffset + kPointerSize;
8226 static const int kRequestedModulesOffset = 8228 static const int kRequestedModulesOffset =
8227 kModuleNamespaceOffset + kPointerSize; 8229 kModuleNamespaceOffset + kPointerSize;
8228 static const int kSize = kRequestedModulesOffset + kPointerSize; 8230 static const int kSize = kRequestedModulesOffset + kPointerSize;
8229 8231
8230 private: 8232 private:
8231 enum { kEvaluatedBit }; 8233 enum { kEvaluatedBit };
8232 8234
8233 static void CreateExport(Handle<Module> module, Handle<FixedArray> names); 8235 static void CreateExport(Handle<Module> module, int index,
8236 Handle<FixedArray> names);
8234 static void CreateIndirectExport(Handle<Module> module, Handle<String> name, 8237 static void CreateIndirectExport(Handle<Module> module, Handle<String> name,
8235 Handle<ModuleInfoEntry> entry); 8238 Handle<ModuleInfoEntry> entry);
8236 8239
8237 // Get the namespace object for [module]. If it doesn't exist yet, it is 8240 // Get the namespace object for [module]. If it doesn't exist yet, it is
8238 // created. 8241 // created.
8239 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module); 8242 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module);
8240 8243
8241 // The [must_resolve] argument indicates whether or not an exception should be 8244 // The [must_resolve] argument indicates whether or not an exception should be
8242 // thrown in case the module does not provide an export named [name] 8245 // thrown in case the module does not provide an export named [name]
8243 // (including when a cycle is detected). An exception is always thrown in the 8246 // (including when a cycle is detected). An exception is always thrown in the
(...skipping 3541 matching lines...) Expand 10 before | Expand all | Expand 10 after
11785 } 11788 }
11786 return value; 11789 return value;
11787 } 11790 }
11788 }; 11791 };
11789 11792
11790 11793
11791 } // NOLINT, false-positive due to second-order macros. 11794 } // NOLINT, false-positive due to second-order macros.
11792 } // NOLINT, false-positive due to second-order macros. 11795 } // NOLINT, false-positive due to second-order macros.
11793 11796
11794 #endif // V8_OBJECTS_H_ 11797 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698