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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // - JSWeakMap | 64 // - JSWeakMap |
65 // - JSWeakSet | 65 // - JSWeakSet |
66 // - JSRegExp | 66 // - JSRegExp |
67 // - JSFunction | 67 // - JSFunction |
68 // - JSGeneratorObject | 68 // - JSGeneratorObject |
69 // - JSGlobalObject | 69 // - JSGlobalObject |
70 // - JSGlobalProxy | 70 // - JSGlobalProxy |
71 // - JSValue | 71 // - JSValue |
72 // - JSDate | 72 // - JSDate |
73 // - JSMessageObject | 73 // - JSMessageObject |
| 74 // - JSModuleNamespace |
74 // - JSProxy | 75 // - JSProxy |
75 // - FixedArrayBase | 76 // - FixedArrayBase |
76 // - ByteArray | 77 // - ByteArray |
77 // - BytecodeArray | 78 // - BytecodeArray |
78 // - FixedArray | 79 // - FixedArray |
79 // - DescriptorArray | 80 // - DescriptorArray |
80 // - FrameArray | 81 // - FrameArray |
81 // - LiteralsArray | 82 // - LiteralsArray |
82 // - HashTable | 83 // - HashTable |
83 // - Dictionary | 84 // - Dictionary |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 V(TRANSITION_ARRAY_TYPE) \ | 410 V(TRANSITION_ARRAY_TYPE) \ |
410 \ | 411 \ |
411 V(JS_MESSAGE_OBJECT_TYPE) \ | 412 V(JS_MESSAGE_OBJECT_TYPE) \ |
412 \ | 413 \ |
413 V(JS_VALUE_TYPE) \ | 414 V(JS_VALUE_TYPE) \ |
414 V(JS_DATE_TYPE) \ | 415 V(JS_DATE_TYPE) \ |
415 V(JS_OBJECT_TYPE) \ | 416 V(JS_OBJECT_TYPE) \ |
416 V(JS_ARGUMENTS_TYPE) \ | 417 V(JS_ARGUMENTS_TYPE) \ |
417 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ | 418 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ |
418 V(JS_GENERATOR_OBJECT_TYPE) \ | 419 V(JS_GENERATOR_OBJECT_TYPE) \ |
| 420 V(JS_MODULE_NAMESPACE_TYPE) \ |
419 V(JS_GLOBAL_OBJECT_TYPE) \ | 421 V(JS_GLOBAL_OBJECT_TYPE) \ |
420 V(JS_GLOBAL_PROXY_TYPE) \ | 422 V(JS_GLOBAL_PROXY_TYPE) \ |
421 V(JS_API_OBJECT_TYPE) \ | 423 V(JS_API_OBJECT_TYPE) \ |
422 V(JS_SPECIAL_API_OBJECT_TYPE) \ | 424 V(JS_SPECIAL_API_OBJECT_TYPE) \ |
423 V(JS_ARRAY_TYPE) \ | 425 V(JS_ARRAY_TYPE) \ |
424 V(JS_ARRAY_BUFFER_TYPE) \ | 426 V(JS_ARRAY_BUFFER_TYPE) \ |
425 V(JS_TYPED_ARRAY_TYPE) \ | 427 V(JS_TYPED_ARRAY_TYPE) \ |
426 V(JS_DATA_VIEW_TYPE) \ | 428 V(JS_DATA_VIEW_TYPE) \ |
427 V(JS_PROXY_TYPE) \ | 429 V(JS_PROXY_TYPE) \ |
428 V(JS_SET_TYPE) \ | 430 V(JS_SET_TYPE) \ |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 JS_SPECIAL_API_OBJECT_TYPE, // LAST_SPECIAL_RECEIVER_TYPE | 712 JS_SPECIAL_API_OBJECT_TYPE, // LAST_SPECIAL_RECEIVER_TYPE |
711 JS_VALUE_TYPE, // LAST_CUSTOM_ELEMENTS_RECEIVER | 713 JS_VALUE_TYPE, // LAST_CUSTOM_ELEMENTS_RECEIVER |
712 JS_MESSAGE_OBJECT_TYPE, | 714 JS_MESSAGE_OBJECT_TYPE, |
713 JS_DATE_TYPE, | 715 JS_DATE_TYPE, |
714 // Like JS_OBJECT_TYPE, but created from API function. | 716 // Like JS_OBJECT_TYPE, but created from API function. |
715 JS_API_OBJECT_TYPE, | 717 JS_API_OBJECT_TYPE, |
716 JS_OBJECT_TYPE, | 718 JS_OBJECT_TYPE, |
717 JS_ARGUMENTS_TYPE, | 719 JS_ARGUMENTS_TYPE, |
718 JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 720 JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
719 JS_GENERATOR_OBJECT_TYPE, | 721 JS_GENERATOR_OBJECT_TYPE, |
| 722 JS_MODULE_NAMESPACE_TYPE, |
720 JS_ARRAY_TYPE, | 723 JS_ARRAY_TYPE, |
721 JS_ARRAY_BUFFER_TYPE, | 724 JS_ARRAY_BUFFER_TYPE, |
722 JS_TYPED_ARRAY_TYPE, | 725 JS_TYPED_ARRAY_TYPE, |
723 JS_DATA_VIEW_TYPE, | 726 JS_DATA_VIEW_TYPE, |
724 JS_SET_TYPE, | 727 JS_SET_TYPE, |
725 JS_MAP_TYPE, | 728 JS_MAP_TYPE, |
726 JS_SET_ITERATOR_TYPE, | 729 JS_SET_ITERATOR_TYPE, |
727 JS_MAP_ITERATOR_TYPE, | 730 JS_MAP_ITERATOR_TYPE, |
728 JS_WEAK_MAP_TYPE, | 731 JS_WEAK_MAP_TYPE, |
729 JS_WEAK_SET_TYPE, | 732 JS_WEAK_SET_TYPE, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 class ConsString; | 882 class ConsString; |
880 class ElementsAccessor; | 883 class ElementsAccessor; |
881 class FixedArrayBase; | 884 class FixedArrayBase; |
882 class FunctionLiteral; | 885 class FunctionLiteral; |
883 class JSGlobalObject; | 886 class JSGlobalObject; |
884 class KeyAccumulator; | 887 class KeyAccumulator; |
885 class LayoutDescriptor; | 888 class LayoutDescriptor; |
886 class LiteralsArray; | 889 class LiteralsArray; |
887 class LookupIterator; | 890 class LookupIterator; |
888 class FieldType; | 891 class FieldType; |
| 892 class Module; |
889 class ModuleDescriptor; | 893 class ModuleDescriptor; |
890 class ModuleInfoEntry; | 894 class ModuleInfoEntry; |
891 class ModuleInfo; | 895 class ModuleInfo; |
892 class ObjectHashTable; | 896 class ObjectHashTable; |
893 class ObjectVisitor; | 897 class ObjectVisitor; |
894 class PropertyCell; | 898 class PropertyCell; |
895 class PropertyDescriptor; | 899 class PropertyDescriptor; |
896 class SafepointEntry; | 900 class SafepointEntry; |
897 class SharedFunctionInfo; | 901 class SharedFunctionInfo; |
898 class StringStream; | 902 class StringStream; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 V(FixedFloat32Array) \ | 967 V(FixedFloat32Array) \ |
964 V(FixedFloat64Array) \ | 968 V(FixedFloat64Array) \ |
965 V(FixedUint8ClampedArray) \ | 969 V(FixedUint8ClampedArray) \ |
966 V(ByteArray) \ | 970 V(ByteArray) \ |
967 V(BytecodeArray) \ | 971 V(BytecodeArray) \ |
968 V(FreeSpace) \ | 972 V(FreeSpace) \ |
969 V(JSReceiver) \ | 973 V(JSReceiver) \ |
970 V(JSObject) \ | 974 V(JSObject) \ |
971 V(JSContextExtensionObject) \ | 975 V(JSContextExtensionObject) \ |
972 V(JSGeneratorObject) \ | 976 V(JSGeneratorObject) \ |
| 977 V(JSModuleNamespace) \ |
973 V(Map) \ | 978 V(Map) \ |
974 V(DescriptorArray) \ | 979 V(DescriptorArray) \ |
975 V(FrameArray) \ | 980 V(FrameArray) \ |
976 V(TransitionArray) \ | 981 V(TransitionArray) \ |
977 V(LiteralsArray) \ | 982 V(LiteralsArray) \ |
978 V(TypeFeedbackMetadata) \ | 983 V(TypeFeedbackMetadata) \ |
979 V(TypeFeedbackVector) \ | 984 V(TypeFeedbackVector) \ |
980 V(DeoptimizationInputData) \ | 985 V(DeoptimizationInputData) \ |
981 V(DeoptimizationOutputData) \ | 986 V(DeoptimizationOutputData) \ |
982 V(DependentCode) \ | 987 V(DependentCode) \ |
(...skipping 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3943 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( | 3948 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( |
3944 Handle<ObjectHashTable> table, | 3949 Handle<ObjectHashTable> table, |
3945 Handle<Object> key); | 3950 Handle<Object> key); |
3946 | 3951 |
3947 // Looks up the value associated with the given key. The hole value is | 3952 // Looks up the value associated with the given key. The hole value is |
3948 // returned in case the key is not present. | 3953 // returned in case the key is not present. |
3949 Object* Lookup(Handle<Object> key); | 3954 Object* Lookup(Handle<Object> key); |
3950 Object* Lookup(Handle<Object> key, int32_t hash); | 3955 Object* Lookup(Handle<Object> key, int32_t hash); |
3951 Object* Lookup(Isolate* isolate, Handle<Object> key, int32_t hash); | 3956 Object* Lookup(Isolate* isolate, Handle<Object> key, int32_t hash); |
3952 | 3957 |
| 3958 // Returns the value at entry. |
| 3959 Object* ValueAt(int entry); |
| 3960 |
3953 // Adds (or overwrites) the value associated with the given key. | 3961 // Adds (or overwrites) the value associated with the given key. |
3954 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, | 3962 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
3955 Handle<Object> key, | 3963 Handle<Object> key, |
3956 Handle<Object> value); | 3964 Handle<Object> value); |
3957 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, | 3965 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
3958 Handle<Object> key, Handle<Object> value, | 3966 Handle<Object> key, Handle<Object> value, |
3959 int32_t hash); | 3967 int32_t hash); |
3960 | 3968 |
3961 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. | 3969 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. |
3962 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, | 3970 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, |
(...skipping 3928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7891 static const int kInputOrDebugPosOffset = kReceiverOffset + kPointerSize; | 7899 static const int kInputOrDebugPosOffset = kReceiverOffset + kPointerSize; |
7892 static const int kResumeModeOffset = kInputOrDebugPosOffset + kPointerSize; | 7900 static const int kResumeModeOffset = kInputOrDebugPosOffset + kPointerSize; |
7893 static const int kContinuationOffset = kResumeModeOffset + kPointerSize; | 7901 static const int kContinuationOffset = kResumeModeOffset + kPointerSize; |
7894 static const int kOperandStackOffset = kContinuationOffset + kPointerSize; | 7902 static const int kOperandStackOffset = kContinuationOffset + kPointerSize; |
7895 static const int kSize = kOperandStackOffset + kPointerSize; | 7903 static const int kSize = kOperandStackOffset + kPointerSize; |
7896 | 7904 |
7897 private: | 7905 private: |
7898 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGeneratorObject); | 7906 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGeneratorObject); |
7899 }; | 7907 }; |
7900 | 7908 |
| 7909 // When importing a module namespace (import * as foo from "bar"), a |
| 7910 // JSModuleNamespace object (representing module "bar") is created and bound to |
| 7911 // the declared variable (foo). A module can have at most one namespace object. |
| 7912 class JSModuleNamespace : public JSObject { |
| 7913 public: |
| 7914 DECLARE_CAST(JSModuleNamespace) |
| 7915 DECLARE_VERIFIER(JSModuleNamespace) |
| 7916 |
| 7917 // The actual module whose namespace is being represented. |
| 7918 DECL_ACCESSORS(module, Module) |
| 7919 |
| 7920 // Retrieve the value exported by [module] under the given [name]. If there is |
| 7921 // no such export, return Just(undefined). If the export is uninitialized, |
| 7922 // schedule an exception and return Nothing. |
| 7923 MUST_USE_RESULT MaybeHandle<Object> GetExport(Handle<String> name); |
| 7924 |
| 7925 static const int kModuleOffset = JSObject::kHeaderSize; |
| 7926 static const int kSize = kModuleOffset + kPointerSize; |
| 7927 |
| 7928 private: |
| 7929 DISALLOW_IMPLICIT_CONSTRUCTORS(JSModuleNamespace); |
| 7930 }; |
| 7931 |
7901 // A Module object is a mapping from export names to cells | 7932 // A Module object is a mapping from export names to cells |
7902 // This is still very much in flux. | 7933 // This is still very much in flux. |
7903 class Module : public Struct { | 7934 class Module : public Struct { |
7904 public: | 7935 public: |
7905 DECLARE_CAST(Module) | 7936 DECLARE_CAST(Module) |
7906 DECLARE_VERIFIER(Module) | 7937 DECLARE_VERIFIER(Module) |
7907 DECLARE_PRINTER(Module) | 7938 DECLARE_PRINTER(Module) |
7908 | 7939 |
7909 // The code representing this Module, either a | 7940 // The code representing this Module, either a SharedFunctionInfo or a |
7910 // SharedFunctionInfo or a JSFunction depending | 7941 // JSFunction depending on whether it's been instantiated. |
7911 // on whether it's been instantiated. | |
7912 DECL_ACCESSORS(code, Object) | 7942 DECL_ACCESSORS(code, Object) |
7913 | 7943 |
7914 DECL_ACCESSORS(exports, ObjectHashTable) | 7944 DECL_ACCESSORS(exports, ObjectHashTable) |
7915 | 7945 |
| 7946 // The namespace object (or undefined). |
| 7947 DECL_ACCESSORS(module_namespace, HeapObject) |
| 7948 |
7916 // [[RequestedModules]]: Modules imported or re-exported by this module. | 7949 // [[RequestedModules]]: Modules imported or re-exported by this module. |
7917 // Corresponds 1-to-1 to the module specifier strings in | 7950 // Corresponds 1-to-1 to the module specifier strings in |
7918 // ModuleInfo::module_requests. | 7951 // ModuleInfo::module_requests. |
7919 DECL_ACCESSORS(requested_modules, FixedArray) | 7952 DECL_ACCESSORS(requested_modules, FixedArray) |
7920 | 7953 |
7921 // [[Evaluated]]: Whether this module has been evaluated. Modules | 7954 // [[Evaluated]]: Whether this module has been evaluated. Modules |
7922 // are only evaluated a single time. | 7955 // are only evaluated a single time. |
7923 DECL_BOOLEAN_ACCESSORS(evaluated) | 7956 DECL_BOOLEAN_ACCESSORS(evaluated) |
7924 | 7957 |
7925 // Storage for [[Evaluated]] | 7958 // Storage for [[Evaluated]]. |
7926 DECL_INT_ACCESSORS(flags) | 7959 DECL_INT_ACCESSORS(flags) |
7927 | 7960 |
7928 // Embedder-specified data | 7961 // Embedder-specified data |
7929 DECL_ACCESSORS(embedder_data, Object) | 7962 DECL_ACCESSORS(embedder_data, Object) |
7930 | 7963 |
7931 // Get the SharedFunctionInfo associated with the code. | 7964 // Get the SharedFunctionInfo associated with the code. |
7932 inline SharedFunctionInfo* shared() const; | 7965 inline SharedFunctionInfo* shared() const; |
7933 | 7966 |
7934 // Get the ModuleInfo associated with the code. | 7967 // Get the ModuleInfo associated with the code. |
7935 inline ModuleInfo* info() const; | 7968 inline ModuleInfo* info() const; |
(...skipping 12 matching lines...) Expand all Loading... |
7948 // Implementation of spec operation ModuleEvaluation. | 7981 // Implementation of spec operation ModuleEvaluation. |
7949 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module); | 7982 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module); |
7950 | 7983 |
7951 static Handle<Object> LoadExport(Handle<Module> module, Handle<String> name); | 7984 static Handle<Object> LoadExport(Handle<Module> module, Handle<String> name); |
7952 static void StoreExport(Handle<Module> module, Handle<String> name, | 7985 static void StoreExport(Handle<Module> module, Handle<String> name, |
7953 Handle<Object> value); | 7986 Handle<Object> value); |
7954 | 7987 |
7955 static Handle<Object> LoadImport(Handle<Module> module, Handle<String> name, | 7988 static Handle<Object> LoadImport(Handle<Module> module, Handle<String> name, |
7956 int module_request); | 7989 int module_request); |
7957 | 7990 |
| 7991 // Get the namespace object for [module_request] of [module]. If it doesn't |
| 7992 // exist yet, it is created. |
| 7993 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module, |
| 7994 int module_request); |
| 7995 |
7958 static const int kCodeOffset = HeapObject::kHeaderSize; | 7996 static const int kCodeOffset = HeapObject::kHeaderSize; |
7959 static const int kExportsOffset = kCodeOffset + kPointerSize; | 7997 static const int kExportsOffset = kCodeOffset + kPointerSize; |
7960 static const int kRequestedModulesOffset = kExportsOffset + kPointerSize; | 7998 static const int kRequestedModulesOffset = kExportsOffset + kPointerSize; |
7961 static const int kFlagsOffset = kRequestedModulesOffset + kPointerSize; | 7999 static const int kFlagsOffset = kRequestedModulesOffset + kPointerSize; |
7962 static const int kEmbedderDataOffset = kFlagsOffset + kPointerSize; | 8000 static const int kEmbedderDataOffset = kFlagsOffset + kPointerSize; |
7963 static const int kSize = kEmbedderDataOffset + kPointerSize; | 8001 static const int kModuleNamespaceOffset = kEmbedderDataOffset + kPointerSize; |
| 8002 static const int kSize = kModuleNamespaceOffset + kPointerSize; |
7964 | 8003 |
7965 private: | 8004 private: |
7966 enum { kEvaluatedBit }; | 8005 enum { kEvaluatedBit }; |
7967 | 8006 |
7968 static void CreateExport(Handle<Module> module, Handle<FixedArray> names); | 8007 static void CreateExport(Handle<Module> module, Handle<FixedArray> names); |
7969 static void CreateIndirectExport(Handle<Module> module, Handle<String> name, | 8008 static void CreateIndirectExport(Handle<Module> module, Handle<String> name, |
7970 Handle<ModuleInfoEntry> entry); | 8009 Handle<ModuleInfoEntry> entry); |
7971 | 8010 |
| 8011 // Get the namespace object for [module]. If it doesn't exist yet, it is |
| 8012 // created. |
| 8013 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module); |
| 8014 |
7972 // The [must_resolve] argument indicates whether or not an exception should be | 8015 // The [must_resolve] argument indicates whether or not an exception should be |
7973 // thrown in case the module does not provide an export named [name] | 8016 // thrown in case the module does not provide an export named [name] |
7974 // (including when a cycle is detected). An exception is always thrown in the | 8017 // (including when a cycle is detected). An exception is always thrown in the |
7975 // case of conflicting star exports. | 8018 // case of conflicting star exports. |
7976 // | 8019 // |
7977 // If [must_resolve] is true, a null result indicates an exception. If | 8020 // If [must_resolve] is true, a null result indicates an exception. If |
7978 // [must_resolve] is false, a null result may or may not indicate an | 8021 // [must_resolve] is false, a null result may or may not indicate an |
7979 // exception (so check manually!). | 8022 // exception (so check manually!). |
7980 class ResolveSet; | 8023 class ResolveSet; |
7981 static MUST_USE_RESULT MaybeHandle<Cell> ResolveExport( | 8024 static MUST_USE_RESULT MaybeHandle<Cell> ResolveExport( |
(...skipping 3447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11429 } | 11472 } |
11430 return value; | 11473 return value; |
11431 } | 11474 } |
11432 }; | 11475 }; |
11433 | 11476 |
11434 | 11477 |
11435 } // NOLINT, false-positive due to second-order macros. | 11478 } // NOLINT, false-positive due to second-order macros. |
11436 } // NOLINT, false-positive due to second-order macros. | 11479 } // NOLINT, false-positive due to second-order macros. |
11437 | 11480 |
11438 #endif // V8_OBJECTS_H_ | 11481 #endif // V8_OBJECTS_H_ |
OLD | NEW |