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_;
430 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
431 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
445 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
446 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
534 return object.template value<Object>()->InternalFieldCount();
540 return object.template value<Object>()->InternalFieldCount();
563 V8_INLINE void* GetAlignedPointerFromInternalField(
int index,
573 return object.template value<Object>()->GetAlignedPointerFromInternalField(
581 return object.template value<Object>()->GetAlignedPointerFromInternalField(
626 template <CppHeapPo
interTag tag,
typename T =
void>
629 template <CppHeapPo
interTag tag,
typename T =
void>
632 template <CppHeapPo
interTag tag,
typename T =
void>
636 template <
typename T =
void>
640 template <
typename T =
void>
644 template <
typename T =
void>
658 template <CppHeapPo
interTag tag>
661 Wrappable* wrappable);
662 template <CppHeapPo
interTag tag>
665 Wrappable* wrappable);
666 template <CppHeapPo
interTag tag>
669 Wrappable* wrappable);
800 return object.template value<Object>()->GetCreationContext(isolate);
825 void* GetAlignedPointerFromEmbedderDataInCreationContext(
827 void* GetAlignedPointerFromEmbedderDataInCreationContext(
830 void* GetAlignedPointerFromEmbedderDataInCreationContext(
837 bool IsCallable() const;
842 bool IsConstructor() const;
855 bool IsApiWrapper() const;
862 bool IsUndetectable() const;
919 static
void* Unwrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
921 static
void Wrap(
v8::
Isolate* isolate, internal::Address wrapper_obj,
925 static
void CheckCast(
Value* obj);
926 Local<
Data> SlowGetInternalField(
int index);
927 void* SlowGetAlignedPointerFromInternalField(
int index,
929 void* SlowGetAlignedPointerFromInternalField(
v8::
Isolate* isolate,
int index,
936#ifndef V8_ENABLE_CHECKS
939 A obj = internal::ValueHelper::ValueAsAddress(
this);
942 int instance_type = I::GetInstanceType(obj);
943 if (I::CanHaveInternalField(instance_type)) {
944 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
945 (I::kEmbedderDataSlotSize * index);
946#ifdef V8_COMPRESS_POINTERS
951 uint32_t compressed = I::ReadRawField<uint32_t>(obj, offset);
952 A value = I::DecompressTaggedField(obj, compressed);
954 A value = I::ReadRawField<A>(obj, offset);
957 auto* isolate = I::GetCurrentIsolate();
961 return SlowGetInternalField(index);
964void* Object::GetAlignedPointerFromInternalField(
v8::Isolate* isolate,
967 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
970void* Object::GetAlignedPointerFromInternalField(
int index,
972 return SlowGetAlignedPointerFromInternalField(index, tag);
976template <CppHeapPo
interTag tag,
typename T>
979 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
980#if !defined(V8_ENABLE_CHECKS)
981 return internal::ReadCppHeapPointerField<T>(
982 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
984 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
989template <CppHeapPo
interTag tag,
typename T>
993 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
994#if !defined(V8_ENABLE_CHECKS)
995 return internal::ReadCppHeapPointerField<T>(
996 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
998 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1003template <CppHeapPo
interTag tag,
typename T>
1008 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1009#if !defined(V8_ENABLE_CHECKS)
1010 return internal::ReadCppHeapPointerField<T>(
1011 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1013 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1018template <
typename T>
1021 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1022#if !defined(V8_ENABLE_CHECKS)
1023 return internal::ReadCppHeapPointerField<T>(
1024 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1026 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1031template <
typename T>
1035 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1036#if !defined(V8_ENABLE_CHECKS)
1037 return internal::ReadCppHeapPointerField<T>(
1038 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1041 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1046template <
typename T>
1051 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1052#if !defined(V8_ENABLE_CHECKS)
1053 return internal::ReadCppHeapPointerField<T>(
1054 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1056 return reinterpret_cast<T*
>(Unwrap(isolate, obj, tag_range));
1061template <CppHeapPo
interTag tag>
1065 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1066 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1067 Wrap(isolate, obj, tag, wrappable);
1071template <CppHeapPo
interTag tag>
1075 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1077 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1078 Wrap(isolate, obj, tag, wrappable);
1082template <CppHeapPo
interTag tag>
1087 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1089 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1090 Wrap(isolate, obj, tag, wrappable);
1096 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1097 Wrap(isolate, obj, tag, wrappable);
1104 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1105 Wrap(isolate, obj, tag, wrappable);
1113 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1114 Wrap(isolate, obj, tag, wrappable);
1118#ifdef V8_ENABLE_CHECKS
1121 return reinterpret_cast<Private*
>(data);
1125#ifdef V8_ENABLE_CHECKS
1128 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:81
Definition: v8-object.h:605
const char * GetHumanReadableName() const override
Definition: v8-object.h:611
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:607
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:613
Definition: v8-object.h:267
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)
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:570
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:532
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:538
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:578
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< 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)
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)
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: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:234
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:979
ExternalPointerTag
Definition: v8-internal.h:692
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:262
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:245
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:180
SideEffectType
Definition: v8-object.h:232
@ kHasSideEffectToReceiver
IndexFilter
Definition: v8-object.h:251
KeyConversionMode
Definition: v8-object.h:257
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:208
constexpr CppHeapPointerTagRange kObjectWrappableTagRange(CppHeapPointerTag::kFirstObjectWrappableTag, CppHeapPointerTag::kLastObjectWrappableTag)
PropertyFilter
Definition: v8-object.h:213
@ ONLY_CONFIGURABLE
Definition: v8-object.h:217
@ SKIP_SYMBOLS
Definition: v8-object.h:219
@ ONLY_WRITABLE
Definition: v8-object.h:215
@ ALL_PROPERTIES
Definition: v8-object.h:214
@ SKIP_STRINGS
Definition: v8-object.h:218
@ ONLY_ENUMERABLE
Definition: v8-object.h:216
Definition: v8-object.h:595
const int16_t type_id
Definition: v8-object.h:596
Definition: v8-internal.h:536
constexpr bool Contains(Tag tag) const
Definition: v8-internal.h:571
#define V8_EXPORT
Definition: v8config.h:874
#define V8_INLINE
Definition: v8config.h:518
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:631
#define V8_DEPRECATED(message)
Definition: v8config.h:623
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:688