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_;
432 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
433 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
447 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
448 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
536 return object.template value<Object>()->InternalFieldCount();
542 return object.template value<Object>()->InternalFieldCount();
565 V8_INLINE void* GetAlignedPointerFromInternalField(
int index,
576 template <
typename T>
577 requires cppgc::IsGarbageCollectedTypeV<T>
585 return object.template value<Object>()->GetAlignedPointerFromInternalField(
588 template <
typename T>
589 requires cppgc::IsGarbageCollectedTypeV<T>
593 return object.template value<Object>()->GetPointerFromInternalField<T>(
594 isolate, index, tag);
601 return object.template value<Object>()->GetAlignedPointerFromInternalField(
604 template <
typename T>
605 requires cppgc::IsGarbageCollectedTypeV<T>
609 return object.template value<Object>()->GetPointerFromInternalField<T>(
610 isolate, index, tag);
626 template <
typename T>
627 requires(!std::is_void_v<T>) && cppgc::IsGarbageCollectedTypeV<T>
629 SetPointerInInternalFieldInternal(index,
static_cast<void*
>(value), tag);
665 template <CppHeapPo
interTag tag,
typename T =
void>
668 template <CppHeapPo
interTag tag,
typename T =
void>
671 template <CppHeapPo
interTag tag,
typename T =
void>
675 template <
typename T =
void>
679 template <
typename T =
void>
683 template <
typename T =
void>
697 template <CppHeapPo
interTag tag>
700 Wrappable* wrappable);
701 template <CppHeapPo
interTag tag>
704 Wrappable* wrappable);
705 template <CppHeapPo
interTag tag>
708 Wrappable* wrappable);
839 return object.template value<Object>()->GetCreationContext(isolate);
864 void* GetAlignedPointerFromEmbedderDataInCreationContext(
866 void* GetAlignedPointerFromEmbedderDataInCreationContext(
869 void* GetAlignedPointerFromEmbedderDataInCreationContext(
876 bool IsCallable() const;
881 bool IsConstructor() const;
894 bool IsApiWrapper() const;
901 bool IsUndetectable() const;
958 static
void* Unwrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
960 static
void Wrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
964 static
void CheckCast(
Value* obj);
965 Local<
Data> SlowGetInternalField(
int index);
966 void* SlowGetAlignedPointerFromInternalField(
int index,
968 void* SlowGetAlignedPointerFromInternalField(
v8::
Isolate* isolate,
int index,
970 void* SlowGetPointerFromInternalField(
v8::
Isolate* isolate,
int index,
972 void SetPointerInInternalFieldInternal(
int index,
void* value,
979#ifndef V8_ENABLE_CHECKS
982 A obj = internal::ValueHelper::ValueAsAddress(
this);
985 int instance_type = I::GetInstanceType(obj);
986 if (I::CanHaveInternalField(instance_type)) {
987 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
988 (I::kEmbedderDataSlotSize * index);
989#ifdef V8_COMPRESS_POINTERS
994 uint32_t compressed = I::ReadRawField<uint32_t>(obj, offset);
995 A value = I::DecompressTaggedField(obj, compressed);
997 A value = I::ReadRawField<A>(obj, offset);
1000 auto* isolate = I::GetCurrentIsolate();
1004 return SlowGetInternalField(index);
1010 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
1013void* Object::GetAlignedPointerFromInternalField(
int index,
1015 return SlowGetAlignedPointerFromInternalField(index, tag);
1018template <
typename T>
1019 requires cppgc::IsGarbageCollectedTypeV<T>
1020T* Object::GetPointerFromInternalField(
v8::Isolate* isolate,
int index,
1022#if !defined(V8_ENABLE_CHECKS)
1025 A obj = internal::ValueHelper::ValueAsAddress(
this);
1028 auto instance_type = I::GetInstanceType(obj);
1029 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
1030 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
1031 (I::kEmbedderDataSlotSize * index) +
1032 I::kEmbedderDataSlotCppHeapPointerOffset;
1033 return internal::ReadCppHeapPointerField<T>(
1037 return static_cast<T*
>(SlowGetPointerFromInternalField(isolate, index, tag));
1041template <CppHeapPo
interTag tag,
typename T>
1044 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1045#if !defined(V8_ENABLE_CHECKS)
1046 return internal::ReadCppHeapPointerField<T>(
1047 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1049 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1054template <CppHeapPo
interTag tag,
typename T>
1058 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1059#if !defined(V8_ENABLE_CHECKS)
1060 return internal::ReadCppHeapPointerField<T>(
1061 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1063 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1068template <CppHeapPo
interTag tag,
typename T>
1073 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1074#if !defined(V8_ENABLE_CHECKS)
1075 return internal::ReadCppHeapPointerField<T>(
1076 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1078 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1083template <
typename T>
1086 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1087#if !defined(V8_ENABLE_CHECKS)
1088 return internal::ReadCppHeapPointerField<T>(
1089 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1091 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1096template <
typename T>
1100 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1101#if !defined(V8_ENABLE_CHECKS)
1102 return internal::ReadCppHeapPointerField<T>(
1103 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1106 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1111template <
typename T>
1116 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1117#if !defined(V8_ENABLE_CHECKS)
1118 return internal::ReadCppHeapPointerField<T>(
1119 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1121 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1126template <CppHeapPo
interTag tag>
1130 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1131 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1132 Wrap(isolate, obj, tag, wrappable);
1136template <CppHeapPo
interTag tag>
1140 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1142 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1143 Wrap(isolate, obj, tag, wrappable);
1147template <CppHeapPo
interTag tag>
1152 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1154 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1155 Wrap(isolate, obj, tag, wrappable);
1161 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1162 Wrap(isolate, obj, tag, wrappable);
1169 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1170 Wrap(isolate, obj, tag, wrappable);
1178 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1179 Wrap(isolate, obj, tag, wrappable);
1183#ifdef V8_ENABLE_CHECKS
1186 return reinterpret_cast<Private*
>(data);
1190#ifdef V8_ENABLE_CHECKS
1193 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:299
Definition: v8-local-handle.h:356
Definition: v8-local-handle.h:724
Definition: v8-maybe.h:39
Definition: v8-primitive.h:82
Definition: v8-object.h:644
const char * GetHumanReadableName() const override
Definition: v8-object.h:650
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:646
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:652
Definition: v8-object.h:269
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:606
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:582
static T * GetPointerFromInternalField(v8::Isolate *isolate, const PersistentBase< Object > &object, int index, CppHeapPointerTag tag)
Definition: v8-object.h:590
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:534
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:540
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:598
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< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Data > data=Local< Data >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
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:628
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: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:231
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:965
ExternalPointerTag
Definition: v8-internal.h:685
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:264
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:247
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:183
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallback
Definition: v8-object.h:206
SideEffectType
Definition: v8-object.h:234
@ kHasSideEffectToReceiver
AccessorNameSetterCallback AccessorNameSetterCallbackV2
Definition: v8-object.h:210
IndexFilter
Definition: v8-object.h:253
KeyConversionMode
Definition: v8-object.h:259
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:39
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:37
constexpr CppHeapPointerTagRange kObjectWrappableTagRange(CppHeapPointerTag::kFirstObjectWrappableTag, CppHeapPointerTag::kLastObjectWrappableTag)
PropertyFilter
Definition: v8-object.h:215
@ ONLY_CONFIGURABLE
Definition: v8-object.h:219
@ SKIP_SYMBOLS
Definition: v8-object.h:221
@ ONLY_WRITABLE
Definition: v8-object.h:217
@ ALL_PROPERTIES
Definition: v8-object.h:216
@ SKIP_STRINGS
Definition: v8-object.h:220
@ ONLY_ENUMERABLE
Definition: v8-object.h:218
Definition: v8-object.h:634
const int16_t type_id
Definition: v8-object.h:635
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