5#ifndef INCLUDE_V8_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
24class FunctionTemplate;
26class PropertyCallbackInfo;
75 static void CheckCast(
Data* that);
148 PrivateData* private_;
396 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
397 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
402 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
403 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
410 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
411 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect) {
412 return SetNativeDataProperty(
413 context, name, getter,
415 getter_side_effect_type, setter_side_effect_type);
430 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
431 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
483 inline
Local<
Value> GetPrototypeV2() {
return GetPrototype(); }
495 return SetPrototype(context, prototype);
528 return object.template value<Object>()->InternalFieldCount();
534 return object.template value<Object>()->InternalFieldCount();
557 V8_INLINE void* GetAlignedPointerFromInternalField(
int index,
567 return object.template value<Object>()->GetAlignedPointerFromInternalField(
575 return object.template value<Object>()->GetAlignedPointerFromInternalField(
620 template <CppHeapPo
interTag tag,
typename T =
void>
623 template <CppHeapPo
interTag tag,
typename T =
void>
626 template <CppHeapPo
interTag tag,
typename T =
void>
630 template <
typename T =
void>
634 template <
typename T =
void>
638 template <
typename T =
void>
652 template <CppHeapPo
interTag tag>
655 Wrappable* wrappable);
656 template <CppHeapPo
interTag tag>
659 Wrappable* wrappable);
660 template <CppHeapPo
interTag tag>
663 Wrappable* wrappable);
794 return object.template value<Object>()->GetCreationContext(isolate);
819 void* GetAlignedPointerFromEmbedderDataInCreationContext(
821 void* GetAlignedPointerFromEmbedderDataInCreationContext(
829 bool IsCallable() const;
834 bool IsConstructor() const;
847 bool IsApiWrapper() const;
854 bool IsUndetectable() const;
911 static
void* Unwrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
913 static
void Wrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
917 static
void CheckCast(
Value* obj);
918 Local<
Data> SlowGetInternalField(
int index);
919 void* SlowGetAlignedPointerFromInternalField(
int index,
921 void* SlowGetAlignedPointerFromInternalField(
v8::
Isolate* isolate,
int index,
928#ifndef V8_ENABLE_CHECKS
931 A obj = internal::ValueHelper::ValueAsAddress(
this);
934 int instance_type = I::GetInstanceType(obj);
935 if (I::CanHaveInternalField(instance_type)) {
936 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
937 (I::kEmbedderDataSlotSize * index);
938 A value = I::ReadRawField<A>(obj, offset);
939#ifdef V8_COMPRESS_POINTERS
942 value = I::DecompressTaggedField(obj,
static_cast<uint32_t
>(value));
945 auto* isolate = I::GetCurrentIsolate();
949 return SlowGetInternalField(index);
952void* Object::GetAlignedPointerFromInternalField(
v8::Isolate* isolate,
955#if !defined(V8_ENABLE_CHECKS)
958 A obj = internal::ValueHelper::ValueAsAddress(
this);
961 auto instance_type = I::GetInstanceType(obj);
962 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
963 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
964 (I::kEmbedderDataSlotSize * index) +
965 I::kEmbedderDataSlotExternalPointerOffset;
966 A value = I::ReadExternalPointerField(isolate, obj, offset,
968 return reinterpret_cast<void*
>(value);
971 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
974void* Object::GetAlignedPointerFromInternalField(
int index,
976#if !defined(V8_ENABLE_CHECKS)
979 A obj = internal::ValueHelper::ValueAsAddress(
this);
982 auto instance_type = I::GetInstanceType(obj);
983 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
984 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
985 (I::kEmbedderDataSlotSize * index) +
986 I::kEmbedderDataSlotExternalPointerOffset;
987 Isolate* isolate = I::GetCurrentIsolateForSandbox();
988 A value = I::ReadExternalPointerField(isolate, obj, offset,
990 return reinterpret_cast<void*
>(value);
993 return SlowGetAlignedPointerFromInternalField(index, tag);
997template <CppHeapPo
interTag tag,
typename T>
1000 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1001#if !defined(V8_ENABLE_CHECKS)
1002 return internal::ReadCppHeapPointerField<T>(
1003 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1005 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1010template <CppHeapPo
interTag tag,
typename T>
1014 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1015#if !defined(V8_ENABLE_CHECKS)
1016 return internal::ReadCppHeapPointerField<T>(
1017 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1019 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1024template <CppHeapPo
interTag tag,
typename T>
1029 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1030#if !defined(V8_ENABLE_CHECKS)
1031 return internal::ReadCppHeapPointerField<T>(
1032 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1034 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1039template <
typename T>
1042 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1043#if !defined(V8_ENABLE_CHECKS)
1044 return internal::ReadCppHeapPointerField<T>(
1045 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1047 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1052template <
typename T>
1056 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1057#if !defined(V8_ENABLE_CHECKS)
1058 return internal::ReadCppHeapPointerField<T>(
1059 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1062 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1067template <
typename T>
1072 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1073#if !defined(V8_ENABLE_CHECKS)
1074 return internal::ReadCppHeapPointerField<T>(
1075 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1077 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1082template <CppHeapPo
interTag tag>
1085 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1086 Wrap(isolate, obj, tag, wrappable);
1090template <CppHeapPo
interTag tag>
1094 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1095 Wrap(isolate, obj, tag, wrappable);
1099template <CppHeapPo
interTag tag>
1104 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1105 Wrap(isolate, obj, tag, wrappable);
1111 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1112 Wrap(isolate, obj, tag, wrappable);
1119 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1120 Wrap(isolate, obj, tag, wrappable);
1128 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1129 Wrap(isolate, obj, tag, wrappable);
1133#ifdef V8_ENABLE_CHECKS
1136 return reinterpret_cast<Private*
>(data);
1140#ifdef V8_ENABLE_CHECKS
1143 return static_cast<Object*
>(value);
Definition: garbage-collected.h:53
Definition: name-provider.h:26
Definition: v8-container.h:25
Definition: v8-traced-handle.h:124
Definition: v8-context.h:48
Definition: v8-isolate.h:291
Definition: v8-local-handle.h:366
Definition: v8-local-handle.h:734
Definition: v8-maybe.h:39
Definition: v8-primitive.h:79
Definition: v8-object.h:599
const char * GetHumanReadableName() const override
Definition: v8-object.h:605
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:601
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:607
Definition: v8-object.h:266
Maybe< PropertyAttribute > GetRealNamedPropertyAttributesInPrototypeChain(Local< Context > context, Local< Name > key)
Maybe< PropertyAttribute > GetPropertyAttributes(Local< Context > context, Local< Value > key)
Maybe< bool > CreateDataProperty(Local< Context > context, uint32_t index, Local< Value > value)
MaybeLocal< Value > GetOwnPropertyDescriptor(Local< Context > context, Local< Name > key)
bool HasNamedLookupInterceptor() const
Maybe< bool > SetPrivate(Local< Context > context, Local< Private > key, Local< Value > value)
Maybe< bool > HasRealNamedProperty(Local< Context > context, Local< Name > key)
MaybeLocal< Array > GetPropertyNames(Local< Context > context)
Maybe< bool > Delete(Local< Context > context, uint32_t index)
MaybeLocal< Value > GetRealNamedProperty(Local< Context > context, Local< Name > key)
Maybe< bool > DefineProperty(Local< Context > context, Local< Name > key, PropertyDescriptor &descriptor)
Maybe< bool > SetPrototype(Local< Context > context, Local< Value > prototype)
Maybe< bool > Delete(Local< Context > context, Local< Value > key)
Maybe< bool > DefineOwnProperty(Local< Context > context, Local< Name > key, Local< Value > value, PropertyAttribute attributes=None)
static void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index, EmbedderDataTypeTag tag)
Definition: v8-object.h:564
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:526
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:532
Maybe< bool > Has(Local< Context > context, Local< Value > key)
void SetAlignedPointerInInternalField(int index, void *value, EmbedderDataTypeTag tag)
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
Local< Value > GetPrototype()
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, nullptr_t setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
Definition: v8-object.h:406
void SetAccessorProperty(Local< Name > name, Local< Function > getter, Local< Function > setter=Local< Function >(), PropertyAttribute attributes=None)
Maybe< bool > CreateDataProperty(Local< Context > context, Local< Name > key, Local< Value > value)
static void * GetAlignedPointerFromInternalField(const BasicTracedReference< Object > &object, int index, EmbedderDataTypeTag tag)
Definition: v8-object.h:572
Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
MaybeLocal< String > ObjectProtoToString(Local< Context > context)
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
Maybe< bool > SetLazyDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
MaybeLocal< Value > Get(Local< Context > context, uint32_t index)
static void WrapGlobal(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable, CppHeapPointerTag tag)
Maybe< bool > SetIntegrityLevel(Local< Context > context, IntegrityLevel level)
MaybeLocal< Array > GetPropertyNames(Local< Context > context, KeyCollectionMode mode, PropertyFilter property_filter, IndexFilter index_filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
int InternalFieldCount() const
Maybe< PropertyAttribute > GetRealNamedPropertyAttributes(Local< Context > context, Local< Name > key)
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallbackV2 setter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
static bool CheckGlobalWrappable(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, CppHeapPointerTagRange tag_range)
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
Local< Object > FindInstanceInPrototypeChain(Local< FunctionTemplate > tmpl)
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
MaybeLocal< Context > GetCreationContext(v8::Isolate *isolate)
void SetInternalField(int index, Local< Data > data)
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context, PropertyFilter filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
Maybe< bool > Set(Local< Context > context, uint32_t index, Local< Value > value)
Local< Object > Clone(v8::Isolate *isolate)
Maybe< bool > HasOwnProperty(Local< Context > context, Local< Name > key)
Maybe< bool > Has(Local< Context > context, uint32_t index)
Maybe< bool > DeletePrivate(Local< Context > context, Local< Private > key)
Local< String > GetConstructorName()
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key, MaybeLocal< Object > receiver)
Maybe< bool > HasRealNamedCallbackProperty(Local< Context > context, Local< Name > key)
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value, MaybeLocal< Object > receiver)
Maybe< bool > HasOwnProperty(Local< Context > context, uint32_t index)
bool HasIndexedLookupInterceptor() const
Definition: v8-persistent-handle.h:93
Definition: v8-object.h:46
Local< Value > Name() const
static Local< Private > ForApi(Isolate *isolate, Local< String > name)
static Local< Private > New(Isolate *isolate, Local< String > name=Local< String >())
Definition: v8-function-callback.h:224
Definition: v8-object.h:106
void set_enumerable(bool enumerable)
bool has_writable() const
Local< Value > get() const
Local< Value > set() const
PropertyDescriptor(Local< Value > get, Local< Value > set)
bool has_enumerable() const
PropertyDescriptor(Local< Value > value)
PrivateData * get_private() const
Definition: v8-object.h:142
void operator=(const PropertyDescriptor &)=delete
Local< Value > value() const
PropertyDescriptor(Local< Value > value, bool writable)
void set_configurable(bool configurable)
PropertyDescriptor(const PropertyDescriptor &)=delete
bool has_configurable() const
bool configurable() const
Definition: v8-value.h:32
Definition: v8-internal.h:984
ExternalPointerTag
Definition: v8-internal.h:636
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:261
PropertyAttribute
Definition: v8-object.h:154
@ DontEnum
Definition: v8-object.h:160
@ None
Definition: v8-object.h:156
@ DontDelete
Definition: v8-object.h:162
@ ReadOnly
Definition: v8-object.h:158
internal::ExternalPointerTag ToExternalPointerTag(v8::EmbedderDataTypeTag api_tag)
KeyCollectionMode
Definition: v8-object.h:244
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:180
SideEffectType
Definition: v8-object.h:231
@ kHasSideEffectToReceiver
IndexFilter
Definition: v8-object.h:250
KeyConversionMode
Definition: v8-object.h:256
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:36
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallbackV2
Definition: v8-object.h:203
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:34
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:207
PropertyFilter
Definition: v8-object.h:212
@ ONLY_CONFIGURABLE
Definition: v8-object.h:216
@ SKIP_SYMBOLS
Definition: v8-object.h:218
@ ONLY_WRITABLE
Definition: v8-object.h:214
@ ALL_PROPERTIES
Definition: v8-object.h:213
@ SKIP_STRINGS
Definition: v8-object.h:217
@ ONLY_ENUMERABLE
Definition: v8-object.h:215
Definition: v8-object.h:589
const int16_t type_id
Definition: v8-object.h:590
Definition: v8-internal.h:486
#define V8_EXPORT
Definition: v8config.h:854
#define V8_INLINE
Definition: v8config.h:508
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:621
#define V8_LIKELY(condition)
Definition: v8config.h:668
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:678