diff options
Diffstat (limited to 'deps/v8/src/objects/module.h')
-rw-r--r-- | deps/v8/src/objects/module.h | 113 |
1 files changed, 66 insertions, 47 deletions
diff --git a/deps/v8/src/objects/module.h b/deps/v8/src/objects/module.h index fd9f9ace80..ec63ddb640 100644 --- a/deps/v8/src/objects/module.h +++ b/deps/v8/src/objects/module.h @@ -8,6 +8,7 @@ #include "src/objects.h" #include "src/objects/fixed-array.h" #include "src/objects/js-objects.h" +#include "src/objects/struct.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -26,8 +27,9 @@ class String; class Zone; // The runtime representation of an ECMAScript module. -class Module : public Struct, public NeverReadOnlySpaceObject { +class Module : public Struct { public: + NEVER_READ_ONLY_SPACE DECL_CAST(Module) DECL_VERIFIER(Module) DECL_PRINTER(Module) @@ -66,11 +68,11 @@ class Module : public Struct, public NeverReadOnlySpaceObject { }; // The exception in the case {status} is kErrored. - Object* GetException(); + Object GetException(); // The shared function info in case {status} is not kEvaluating, kEvaluated or // kErrored. - SharedFunctionInfo* GetSharedFunctionInfo() const; + SharedFunctionInfo GetSharedFunctionInfo() const; // The namespace object (or undefined). DECL_ACCESSORS(module_namespace, HeapObject) @@ -89,7 +91,7 @@ class Module : public Struct, public NeverReadOnlySpaceObject { DECL_ACCESSORS(import_meta, Object) // Get the ModuleInfo associated with the code. - inline ModuleInfo* info() const; + inline ModuleInfo info() const; // Implementation of spec operation ModuleDeclarationInstantiation. // Returns false if an exception occurred during instantiation, true @@ -103,7 +105,7 @@ class Module : public Struct, public NeverReadOnlySpaceObject { static V8_WARN_UNUSED_RESULT MaybeHandle<Object> Evaluate( Isolate* isolate, Handle<Module> module); - Cell* GetCell(int cell_index); + Cell GetCell(int cell_index); static Handle<Object> LoadVariable(Isolate* isolate, Handle<Module> module, int cell_index); static void StoreVariable(Handle<Module> module, int cell_index, @@ -123,21 +125,26 @@ class Module : public Struct, public NeverReadOnlySpaceObject { static Handle<JSModuleNamespace> GetModuleNamespace(Isolate* isolate, Handle<Module> module); - static const int kCodeOffset = HeapObject::kHeaderSize; - static const int kExportsOffset = kCodeOffset + kPointerSize; - static const int kRegularExportsOffset = kExportsOffset + kPointerSize; - static const int kRegularImportsOffset = kRegularExportsOffset + kPointerSize; - static const int kHashOffset = kRegularImportsOffset + kPointerSize; - static const int kModuleNamespaceOffset = kHashOffset + kPointerSize; - static const int kRequestedModulesOffset = - kModuleNamespaceOffset + kPointerSize; - static const int kStatusOffset = kRequestedModulesOffset + kPointerSize; - static const int kDfsIndexOffset = kStatusOffset + kPointerSize; - static const int kDfsAncestorIndexOffset = kDfsIndexOffset + kPointerSize; - static const int kExceptionOffset = kDfsAncestorIndexOffset + kPointerSize; - static const int kScriptOffset = kExceptionOffset + kPointerSize; - static const int kImportMetaOffset = kScriptOffset + kPointerSize; - static const int kSize = kImportMetaOffset + kPointerSize; +// Layout description. +#define MODULE_FIELDS(V) \ + V(kCodeOffset, kTaggedSize) \ + V(kExportsOffset, kTaggedSize) \ + V(kRegularExportsOffset, kTaggedSize) \ + V(kRegularImportsOffset, kTaggedSize) \ + V(kHashOffset, kTaggedSize) \ + V(kModuleNamespaceOffset, kTaggedSize) \ + V(kRequestedModulesOffset, kTaggedSize) \ + V(kStatusOffset, kTaggedSize) \ + V(kDfsIndexOffset, kTaggedSize) \ + V(kDfsAncestorIndexOffset, kTaggedSize) \ + V(kExceptionOffset, kTaggedSize) \ + V(kScriptOffset, kTaggedSize) \ + V(kImportMetaOffset, kTaggedSize) \ + /* Total size. */ \ + V(kSize, 0) + + DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, MODULE_FIELDS) +#undef MODULE_FIELDS private: friend class Factory; @@ -210,7 +217,7 @@ class Module : public Struct, public NeverReadOnlySpaceObject { void PrintStatusTransition(Status new_status); #endif // DEBUG - DISALLOW_IMPLICIT_CONSTRUCTORS(Module); + OBJECT_CONSTRUCTORS(Module, Struct); }; // When importing a module namespace (import * as foo from "bar"), a @@ -243,13 +250,20 @@ class JSModuleNamespace : public JSObject { kInObjectFieldCount, }; - static const int kModuleOffset = JSObject::kHeaderSize; - static const int kHeaderSize = kModuleOffset + kPointerSize; +// Layout description. +#define JS_MODULE_NAMESPACE_FIELDS(V) \ + V(kModuleOffset, kTaggedSize) \ + /* Header size. */ \ + V(kHeaderSize, 0) \ + V(kInObjectFieldsOffset, kTaggedSize* kInObjectFieldCount) \ + /* Total size. */ \ + V(kSize, 0) - static const int kSize = kHeaderSize + kPointerSize * kInObjectFieldCount; + DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, + JS_MODULE_NAMESPACE_FIELDS) +#undef JS_MODULE_NAMESPACE_FIELDS - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(JSModuleNamespace); + OBJECT_CONSTRUCTORS(JSModuleNamespace, JSObject); }; // ModuleInfo is to ModuleDescriptor what ScopeInfo is to Scope. @@ -260,21 +274,21 @@ class ModuleInfo : public FixedArray { static Handle<ModuleInfo> New(Isolate* isolate, Zone* zone, ModuleDescriptor* descr); - inline FixedArray* module_requests() const; - inline FixedArray* special_exports() const; - inline FixedArray* regular_exports() const; - inline FixedArray* regular_imports() const; - inline FixedArray* namespace_imports() const; - inline FixedArray* module_request_positions() const; + inline FixedArray module_requests() const; + inline FixedArray special_exports() const; + inline FixedArray regular_exports() const; + inline FixedArray regular_imports() const; + inline FixedArray namespace_imports() const; + inline FixedArray module_request_positions() const; // Accessors for [regular_exports]. int RegularExportCount() const; - String* RegularExportLocalName(int i) const; + String RegularExportLocalName(int i) const; int RegularExportCellIndex(int i) const; - FixedArray* RegularExportExportNames(int i) const; + FixedArray RegularExportExportNames(int i) const; #ifdef DEBUG - inline bool Equals(ModuleInfo* other) const; + inline bool Equals(ModuleInfo other) const; #endif private: @@ -295,7 +309,7 @@ class ModuleInfo : public FixedArray { kRegularExportExportNamesOffset, kRegularExportLength }; - DISALLOW_IMPLICIT_CONSTRUCTORS(ModuleInfo); + OBJECT_CONSTRUCTORS(ModuleInfo, FixedArray); }; class ModuleInfoEntry : public Struct { @@ -319,17 +333,22 @@ class ModuleInfoEntry : public Struct { int module_request, int cell_index, int beg_pos, int end_pos); - static const int kExportNameOffset = HeapObject::kHeaderSize; - static const int kLocalNameOffset = kExportNameOffset + kPointerSize; - static const int kImportNameOffset = kLocalNameOffset + kPointerSize; - static const int kModuleRequestOffset = kImportNameOffset + kPointerSize; - static const int kCellIndexOffset = kModuleRequestOffset + kPointerSize; - static const int kBegPosOffset = kCellIndexOffset + kPointerSize; - static const int kEndPosOffset = kBegPosOffset + kPointerSize; - static const int kSize = kEndPosOffset + kPointerSize; - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(ModuleInfoEntry); +// Layout description. +#define MODULE_INFO_FIELDS(V) \ + V(kExportNameOffset, kTaggedSize) \ + V(kLocalNameOffset, kTaggedSize) \ + V(kImportNameOffset, kTaggedSize) \ + V(kModuleRequestOffset, kTaggedSize) \ + V(kCellIndexOffset, kTaggedSize) \ + V(kBegPosOffset, kTaggedSize) \ + V(kEndPosOffset, kTaggedSize) \ + /* Total size. */ \ + V(kSize, 0) + + DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, MODULE_INFO_FIELDS) +#undef MODULE_INFO_FIELDS + + OBJECT_CONSTRUCTORS(ModuleInfoEntry, Struct); }; } // namespace internal |