5#ifndef INCLUDE_V8_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
27class FunctionTemplate;
29class PropertyCallbackInfo;
78 static void CheckCast(
Data* that);
151 PrivateData* private_;
428 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
429 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
443 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
444 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
532 return object.template value<Object>()->InternalFieldCount();
538 return object.template value<Object>()->InternalFieldCount();
561 V8_INLINE void* GetAlignedPointerFromInternalField(
int index,
572 template <
typename T>
573 requires cppgc::IsGarbageCollectedTypeV<T>
581 return object.template value<Object>()->GetAlignedPointerFromInternalField(
584 template <
typename T>
585 requires cppgc::IsGarbageCollectedTypeV<T>
589 return object.template value<Object>()->GetPointerFromInternalField<T>(
590 isolate, index, tag);
597 return object.template value<Object>()->GetAlignedPointerFromInternalField(
600 template <
typename T>
601 requires cppgc::IsGarbageCollectedTypeV<T>
605 return object.template value<Object>()->GetPointerFromInternalField<T>(
606 isolate, index, tag);
622 template <
typename T>
623 requires(!std::is_void_v<T>) && cppgc::IsGarbageCollectedTypeV<T>
625 SetPointerInInternalFieldInternal(index,
static_cast<void*
>(value), tag);
661 template <CppHeapPo
interTag tag,
typename T =
void>
664 template <CppHeapPo
interTag tag,
typename T =
void>
667 template <CppHeapPo
interTag tag,
typename T =
void>
671 template <
typename T =
void>
675 template <
typename T =
void>
679 template <
typename T =
void>
693 template <CppHeapPo
interTag tag>
696 Wrappable* wrappable);
697 template <CppHeapPo
interTag tag>
700 Wrappable* wrappable);
701 template <CppHeapPo
interTag tag>
704 Wrappable* wrappable);
835 return object.template value<Object>()->GetCreationContext(isolate);
860 void* GetAlignedPointerFromEmbedderDataInCreationContext(
862 void* GetAlignedPointerFromEmbedderDataInCreationContext(
865 void* GetAlignedPointerFromEmbedderDataInCreationContext(
872 bool IsCallable() const;
877 bool IsConstructor() const;
890 bool IsApiWrapper() const;
897 bool IsUndetectable() const;
954 static
void* Unwrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
956 static
void Wrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
960 static
void CheckCast(
Value* obj);
961 Local<
Data> SlowGetInternalField(
int index);
962 void* SlowGetAlignedPointerFromInternalField(
int index,
964 void* SlowGetAlignedPointerFromInternalField(
v8::
Isolate* isolate,
int index,
966 void* SlowGetPointerFromInternalField(
v8::
Isolate* isolate,
int index,
968 void SetPointerInInternalFieldInternal(
int index,
void* value,
975#ifndef V8_ENABLE_CHECKS
978 A obj = internal::ValueHelper::ValueAsAddress(
this);
981 int instance_type = I::GetInstanceType(obj);
982 if (I::CanHaveInternalField(instance_type)) {
983 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
984 (I::kEmbedderDataSlotSize * index);
985#ifdef V8_COMPRESS_POINTERS
990 uint32_t compressed = I::ReadRawField<uint32_t>(obj, offset);
991 A value = I::DecompressTaggedField(obj, compressed);
993 A value = I::ReadRawField<A>(obj, offset);
996 auto* isolate = I::GetCurrentIsolate();
1000 return SlowGetInternalField(index);
1006 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
1009void* Object::GetAlignedPointerFromInternalField(
int index,
1011 return SlowGetAlignedPointerFromInternalField(index, tag);
1014template <
typename T>
1015 requires cppgc::IsGarbageCollectedTypeV<T>
1016T* Object::GetPointerFromInternalField(
v8::Isolate* isolate,
int index,
1018#if !defined(V8_ENABLE_CHECKS)
1021 A obj = internal::ValueHelper::ValueAsAddress(
this);
1024 auto instance_type = I::GetInstanceType(obj);
1025 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
1026 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
1027 (I::kEmbedderDataSlotSize * index) +
1028 I::kEmbedderDataSlotCppHeapPointerOffset;
1029 return internal::ReadCppHeapPointerField<T>(
1033 return static_cast<T*
>(SlowGetPointerFromInternalField(isolate, index, tag));
1037template <CppHeapPo
interTag tag,
typename T>
1040 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1041#if !defined(V8_ENABLE_CHECKS)
1042 return internal::ReadCppHeapPointerField<T>(
1043 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1045 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1050template <CppHeapPo
interTag tag,
typename T>
1054 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1055#if !defined(V8_ENABLE_CHECKS)
1056 return internal::ReadCppHeapPointerField<T>(
1057 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1059 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1064template <CppHeapPo
interTag tag,
typename T>
1069 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1070#if !defined(V8_ENABLE_CHECKS)
1071 return internal::ReadCppHeapPointerField<T>(
1072 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1074 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1079template <
typename T>
1082 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1083#if !defined(V8_ENABLE_CHECKS)
1084 return internal::ReadCppHeapPointerField<T>(
1085 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1087 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1092template <
typename T>
1096 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1097#if !defined(V8_ENABLE_CHECKS)
1098 return internal::ReadCppHeapPointerField<T>(
1099 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1102 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1107template <
typename T>
1112 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1113#if !defined(V8_ENABLE_CHECKS)
1114 return internal::ReadCppHeapPointerField<T>(
1115 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1117 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1122template <CppHeapPo
interTag tag>
1126 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1127 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1128 Wrap(isolate, obj, tag, wrappable);
1132template <CppHeapPo
interTag tag>
1136 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1138 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1139 Wrap(isolate, obj, tag, wrappable);
1143template <CppHeapPo
interTag tag>
1148 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1150 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1151 Wrap(isolate, obj, tag, wrappable);
1157 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1158 Wrap(isolate, obj, tag, wrappable);
1165 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1166 Wrap(isolate, obj, tag, wrappable);
1174 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1175 Wrap(isolate, obj, tag, wrappable);
1179#ifdef V8_ENABLE_CHECKS
1182 return reinterpret_cast<Private*
>(data);
1186#ifdef V8_ENABLE_CHECKS
1189 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:125
Definition: v8-context.h:55
Definition: v8-isolate.h:305
Definition: v8-local-handle.h:359
Definition: v8-local-handle.h:730
Definition: v8-maybe.h:39
Definition: v8-primitive.h:83
Definition: v8-object.h:640
const char * GetHumanReadableName() const override
Definition: v8-object.h:646
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:642
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:648
Definition: v8-object.h:265
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)
static T * GetPointerFromInternalField(v8::Isolate *isolate, const BasicTracedReference< Object > &object, int index, CppHeapPointerTag tag)
Definition: v8-object.h:602
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)
MaybeLocal< Value > TryGetWithNoSideEffects(Local< Context > context, Local< Name > 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:578
static T * GetPointerFromInternalField(v8::Isolate *isolate, const PersistentBase< Object > &object, int index, CppHeapPointerTag tag)
Definition: v8-object.h:586
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:530
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:536
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)
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:594
Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
MaybeLocal< String > ObjectProtoToString(Local< Context > context)
Maybe< bool > SetLazyDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, Local< Data > data=Local< Data >(), 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)
static bool CheckGlobalWrappable(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, CppHeapPointerTagRange tag_range)
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
Maybe< bool > GetPropertyAttributes(Local< Context > context, Local< Value > key, PropertyAttribute *out_attributes)
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)
void SetPointerInInternalField(int index, T *value, CppHeapPointerTag tag)
Definition: v8-object.h:624
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)
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallbackV2 setter=nullptr, Local< Data > data=Local< Data >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
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:49
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:229
Definition: v8-object.h:109
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:145
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:969
ExternalPointerTag
Definition: v8-internal.h:685
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:260
PropertyAttribute
Definition: v8-object.h:157
@ DontEnum
Definition: v8-object.h:163
@ None
Definition: v8-object.h:159
@ DontDelete
Definition: v8-object.h:165
@ ReadOnly
Definition: v8-object.h:161
internal::ExternalPointerTag ToExternalPointerTag(v8::EmbedderDataTypeTag api_tag)
KeyCollectionMode
Definition: v8-object.h:243
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:183
SideEffectType
Definition: v8-object.h:230
@ kHasSideEffectToReceiver
IndexFilter
Definition: v8-object.h:249
KeyConversionMode
Definition: v8-object.h:255
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:39
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallbackV2
Definition: v8-object.h:206
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:37
constexpr CppHeapPointerTagRange kObjectWrappableTagRange(CppHeapPointerTag::kFirstObjectWrappableTag, CppHeapPointerTag::kLastObjectWrappableTag)
PropertyFilter
Definition: v8-object.h:211
@ ONLY_CONFIGURABLE
Definition: v8-object.h:215
@ SKIP_SYMBOLS
Definition: v8-object.h:217
@ ONLY_WRITABLE
Definition: v8-object.h:213
@ ALL_PROPERTIES
Definition: v8-object.h:212
@ SKIP_STRINGS
Definition: v8-object.h:216
@ ONLY_ENUMERABLE
Definition: v8-object.h:214
Definition: v8-object.h:630
const int16_t type_id
Definition: v8-object.h:631
Definition: v8-internal.h:536
constexpr bool Contains(Tag tag) const
Definition: v8-internal.h:571
#define V8_EXPORT
Definition: v8config.h:875
#define V8_INLINE
Definition: v8config.h:519
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:632
#define V8_LIKELY(condition)
Definition: v8config.h:679
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:689