OLD | NEW |
---|---|
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 7889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7900 | 7900 |
7901 // A Module object is a mapping from export names to cells | 7901 // A Module object is a mapping from export names to cells |
7902 // This is still very much in flux. | 7902 // This is still very much in flux. |
7903 class Module : public Struct { | 7903 class Module : public Struct { |
7904 public: | 7904 public: |
7905 DECLARE_CAST(Module) | 7905 DECLARE_CAST(Module) |
7906 DECLARE_VERIFIER(Module) | 7906 DECLARE_VERIFIER(Module) |
7907 DECLARE_PRINTER(Module) | 7907 DECLARE_PRINTER(Module) |
7908 | 7908 |
7909 // The code representing this Module, either a SharedFunctionInfo or a | 7909 // The code representing this Module, either a SharedFunctionInfo or a |
7910 // JSFunction depending on whether it's been instantiated. | 7910 // JSFunction or a ModuleInfo depending on whether it's been instantiated and |
7911 // evaluated. See Module::ModuleVerify() for the precise invariant. | |
7911 DECL_ACCESSORS(code, Object) | 7912 DECL_ACCESSORS(code, Object) |
adamk
2016/10/11 15:54:05
Some name ideas:
impl
internal
module
| |
7912 | 7913 |
7914 // The export table. | |
7913 DECL_ACCESSORS(exports, ObjectHashTable) | 7915 DECL_ACCESSORS(exports, ObjectHashTable) |
7914 | 7916 |
7915 // The namespace object (or undefined). | 7917 // The namespace object (or undefined). |
7916 DECL_ACCESSORS(module_namespace, HeapObject) | 7918 DECL_ACCESSORS(module_namespace, HeapObject) |
7917 | 7919 |
7918 // [[RequestedModules]]: Modules imported or re-exported by this module. | 7920 // [[RequestedModules]]: Modules imported or re-exported by this module. |
7919 // Corresponds 1-to-1 to the module specifier strings in | 7921 // Corresponds 1-to-1 to the module specifier strings in |
7920 // ModuleInfo::module_requests. | 7922 // ModuleInfo::module_requests. |
7921 DECL_ACCESSORS(requested_modules, FixedArray) | 7923 DECL_ACCESSORS(requested_modules, FixedArray) |
7922 | 7924 |
7923 // [[Evaluated]]: Whether this module has been evaluated. Modules | |
7924 // are only evaluated a single time. | |
7925 DECL_BOOLEAN_ACCESSORS(evaluated) | |
7926 | |
7927 // Storage for [[Evaluated]]. | |
7928 DECL_INT_ACCESSORS(flags) | |
7929 | |
7930 // Embedder-specified data | 7925 // Embedder-specified data |
7931 DECL_ACCESSORS(embedder_data, Object) | 7926 DECL_ACCESSORS(embedder_data, Object) |
7932 | 7927 |
7933 // Hash for this object (a random non-zero Smi). | 7928 // Hash for this object (a random non-zero Smi). |
7934 DECL_INT_ACCESSORS(hash) | 7929 DECL_INT_ACCESSORS(hash) |
7935 | 7930 |
7936 // Get the SharedFunctionInfo associated with the code. | 7931 // Get the SharedFunctionInfo associated with the code. |
7937 inline SharedFunctionInfo* shared() const; | 7932 inline SharedFunctionInfo* shared() const; |
7938 | 7933 |
7939 // Get the ModuleInfo associated with the code. | 7934 // Get the ModuleInfo associated with the code. |
7940 inline ModuleInfo* info() const; | 7935 inline ModuleInfo* info() const; |
7941 | 7936 |
7937 inline bool instantiated() const; | |
7938 inline bool evaluated() const; | |
7939 inline void set_evaluated(); | |
7940 | |
7942 // Implementation of spec operation ModuleDeclarationInstantiation. | 7941 // Implementation of spec operation ModuleDeclarationInstantiation. |
7943 // Returns false if an exception occurred during instantiation, true | 7942 // Returns false if an exception occurred during instantiation, true |
7944 // otherwise. | 7943 // otherwise. |
7945 static MUST_USE_RESULT bool Instantiate(Handle<Module> module, | 7944 static MUST_USE_RESULT bool Instantiate(Handle<Module> module, |
7946 v8::Local<v8::Context> context, | 7945 v8::Local<v8::Context> context, |
7947 v8::Module::ResolveCallback callback, | 7946 v8::Module::ResolveCallback callback, |
7948 v8::Local<v8::Value> callback_data); | 7947 v8::Local<v8::Value> callback_data); |
7949 | 7948 |
7950 // Implementation of spec operation ModuleEvaluation. | 7949 // Implementation of spec operation ModuleEvaluation. |
7951 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module); | 7950 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module); |
7952 | 7951 |
7953 static Handle<Object> LoadExport(Handle<Module> module, Handle<String> name); | 7952 static Handle<Object> LoadExport(Handle<Module> module, Handle<String> name); |
7954 static void StoreExport(Handle<Module> module, Handle<String> name, | 7953 static void StoreExport(Handle<Module> module, Handle<String> name, |
7955 Handle<Object> value); | 7954 Handle<Object> value); |
7956 | 7955 |
7957 static Handle<Object> LoadImport(Handle<Module> module, Handle<String> name, | 7956 static Handle<Object> LoadImport(Handle<Module> module, Handle<String> name, |
7958 int module_request); | 7957 int module_request); |
7959 | 7958 |
7960 // Get the namespace object for [module_request] of [module]. If it doesn't | 7959 // Get the namespace object for [module_request] of [module]. If it doesn't |
7961 // exist yet, it is created. | 7960 // exist yet, it is created. |
7962 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module, | 7961 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module, |
7963 int module_request); | 7962 int module_request); |
7964 | 7963 |
7965 static const int kCodeOffset = HeapObject::kHeaderSize; | 7964 static const int kCodeOffset = HeapObject::kHeaderSize; |
7966 static const int kExportsOffset = kCodeOffset + kPointerSize; | 7965 static const int kExportsOffset = kCodeOffset + kPointerSize; |
7967 static const int kRequestedModulesOffset = kExportsOffset + kPointerSize; | 7966 static const int kRequestedModulesOffset = kExportsOffset + kPointerSize; |
7968 static const int kFlagsOffset = kRequestedModulesOffset + kPointerSize; | 7967 static const int kEmbedderDataOffset = kRequestedModulesOffset + kPointerSize; |
7969 static const int kEmbedderDataOffset = kFlagsOffset + kPointerSize; | |
7970 static const int kModuleNamespaceOffset = kEmbedderDataOffset + kPointerSize; | 7968 static const int kModuleNamespaceOffset = kEmbedderDataOffset + kPointerSize; |
7971 static const int kHashOffset = kModuleNamespaceOffset + kPointerSize; | 7969 static const int kHashOffset = kModuleNamespaceOffset + kPointerSize; |
7972 static const int kSize = kHashOffset + kPointerSize; | 7970 static const int kSize = kHashOffset + kPointerSize; |
7973 | 7971 |
7974 private: | 7972 private: |
7975 enum { kEvaluatedBit }; | 7973 enum { kEvaluatedBit }; |
7976 | 7974 |
7977 static void CreateExport(Handle<Module> module, Handle<FixedArray> names); | 7975 static void CreateExport(Handle<Module> module, Handle<FixedArray> names); |
7978 static void CreateIndirectExport(Handle<Module> module, Handle<String> name, | 7976 static void CreateIndirectExport(Handle<Module> module, Handle<String> name, |
7979 Handle<ModuleInfoEntry> entry); | 7977 Handle<ModuleInfoEntry> entry); |
(...skipping 3470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11450 } | 11448 } |
11451 return value; | 11449 return value; |
11452 } | 11450 } |
11453 }; | 11451 }; |
11454 | 11452 |
11455 | 11453 |
11456 } // NOLINT, false-positive due to second-order macros. | 11454 } // NOLINT, false-positive due to second-order macros. |
11457 } // NOLINT, false-positive due to second-order macros. | 11455 } // NOLINT, false-positive due to second-order macros. |
11458 | 11456 |
11459 #endif // V8_OBJECTS_H_ | 11457 #endif // V8_OBJECTS_H_ |
OLD | NEW |