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_;
186 "This enum is no longer used and will be removed in V8 14.3.")
379 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
380 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
394 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
395 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
485 return object.template value<Object>()->InternalFieldCount();
491 return object.template value<Object>()->InternalFieldCount();
514 V8_INLINE void* GetAlignedPointerFromInternalField(
int index,
521 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
522 "parameter instead.")
523 V8_INLINE void* GetAlignedPointerFromInternalField(
int index) {
524 return GetAlignedPointerFromInternalField(index,
529 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
530 "parameter instead.")
533 return GetAlignedPointerFromInternalField(isolate, index,
541 return object.template value<Object>()->GetAlignedPointerFromInternalField(
546 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
547 "parameter instead.")
548 V8_INLINE static
void* GetAlignedPointerFromInternalField(
550 return object.template value<Object>()->GetAlignedPointerFromInternalField(
558 return object.template value<Object>()->GetAlignedPointerFromInternalField(
563 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
564 "parameter instead.")
565 V8_INLINE static
void* GetAlignedPointerFromInternalField(
567 return object.template value<Object>()->GetAlignedPointerFromInternalField(
580 "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag parameter "
582 void SetAlignedPointerInInternalField(
int index,
void* value) {
587 "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag "
588 "parameter instead.")
589 void SetAlignedPointerInInternalFields(
int argc,
int indices[],
625 template <CppHeapPo
interTag tag,
typename T =
void>
628 template <CppHeapPo
interTag tag,
typename T =
void>
631 template <CppHeapPo
interTag tag,
typename T =
void>
635 template <
typename T =
void>
639 template <
typename T =
void>
643 template <
typename T =
void>
657 template <CppHeapPo
interTag tag>
660 Wrappable* wrappable);
661 template <CppHeapPo
interTag tag>
664 Wrappable* wrappable);
665 template <CppHeapPo
interTag tag>
668 Wrappable* wrappable);
799 return object.template value<Object>()->GetCreationContext(isolate);
819 void* GetAlignedPointerFromEmbedderDataInCreationContext(
821 void* GetAlignedPointerFromEmbedderDataInCreationContext(
825 "Use GetAlignedPointerFromEmbedderDataInCreationContext with "
827 void* GetAlignedPointerFromEmbedderDataInCreationContext(
v8::
Isolate* isolate,
829 return GetAlignedPointerFromEmbedderDataInCreationContext(
834 "Use GetAlignedPointerFromEmbedderDataInCreationContext with "
835 "EmbedderDataTypeTag parameter instead.")
836 void* GetAlignedPointerFromEmbedderDataInCreationContext(
int index) {
837 return GetAlignedPointerFromEmbedderDataInCreationContext(
934 static void CheckCast(
Value* obj);
936 void* SlowGetAlignedPointerFromInternalField(
int index,
938 void* SlowGetAlignedPointerFromInternalField(
v8::Isolate* isolate,
int index,
945#ifndef V8_ENABLE_CHECKS
951 int instance_type = I::GetInstanceType(obj);
952 if (I::CanHaveInternalField(instance_type)) {
953 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
954 (I::kEmbedderDataSlotSize * index);
955 A value = I::ReadRawField<A>(obj, offset);
956#ifdef V8_COMPRESS_POINTERS
959 value = I::DecompressTaggedField(obj,
static_cast<uint32_t
>(value));
962 auto* isolate = I::GetCurrentIsolate();
966 return SlowGetInternalField(index);
972#if !defined(V8_ENABLE_CHECKS)
978 auto instance_type = I::GetInstanceType(obj);
979 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
980 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
981 (I::kEmbedderDataSlotSize * index) +
982 I::kEmbedderDataSlotExternalPointerOffset;
983 A value = I::ReadExternalPointerField(isolate, obj, offset,
985 return reinterpret_cast<void*
>(value);
988 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
993#if !defined(V8_ENABLE_CHECKS)
999 auto instance_type = I::GetInstanceType(obj);
1000 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
1001 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
1002 (I::kEmbedderDataSlotSize * index) +
1003 I::kEmbedderDataSlotExternalPointerOffset;
1004 Isolate* isolate = I::GetCurrentIsolateForSandbox();
1005 A value = I::ReadExternalPointerField(isolate, obj, offset,
1007 return reinterpret_cast<void*
>(value);
1010 return SlowGetAlignedPointerFromInternalField(index, tag);
1014template <CppHeapPo
interTag tag,
typename T>
1018#if !defined(V8_ENABLE_CHECKS)
1019 return internal::ReadCppHeapPointerField<T>(
1022 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1027template <CppHeapPo
interTag tag,
typename T>
1032#if !defined(V8_ENABLE_CHECKS)
1033 return internal::ReadCppHeapPointerField<T>(
1036 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1041template <CppHeapPo
interTag tag,
typename T>
1047#if !defined(V8_ENABLE_CHECKS)
1048 return internal::ReadCppHeapPointerField<T>(
1051 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1056template <
typename T>
1060#if !defined(V8_ENABLE_CHECKS)
1061 return internal::ReadCppHeapPointerField<T>(
1064 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1069template <
typename T>
1074#if !defined(V8_ENABLE_CHECKS)
1075 return internal::ReadCppHeapPointerField<T>(
1079 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1084template <
typename T>
1090#if !defined(V8_ENABLE_CHECKS)
1091 return internal::ReadCppHeapPointerField<T>(
1094 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1099template <CppHeapPo
interTag tag>
1103 Wrap(isolate, obj, tag, wrappable);
1107template <CppHeapPo
interTag tag>
1112 Wrap(isolate, obj, tag, wrappable);
1116template <CppHeapPo
interTag tag>
1122 Wrap(isolate, obj, tag, wrappable);
1129 Wrap(isolate, obj, tag, wrappable);
1137 Wrap(isolate, obj, tag, wrappable);
1146 Wrap(isolate, obj, tag, wrappable);
1150#ifdef V8_ENABLE_CHECKS
1153 return reinterpret_cast<Private*
>(data);
1157#ifdef V8_ENABLE_CHECKS
1160 return static_cast<Object*
>(value);
Definition: garbage-collected.h:53
Definition: name-provider.h:26
Definition: v8-traced-handle.h:124
Definition: v8-context.h:48
Definition: v8-isolate.h:290
Definition: v8-local-handle.h:366
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:448
Definition: v8-local-handle.h:734
Definition: v8-maybe.h:39
Definition: v8-object.h:604
const char * GetHumanReadableName() const override
Definition: v8-object.h:610
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:606
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:612
Definition: v8-object.h:248
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 Object * Cast(Value *obj)
Definition: v8-object.h:1156
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 > Delete(Local< Context > context, Local< Value > key)
bool IsConstructor() const
bool IsUndetectable() const
MaybeLocal< Value > CallAsFunction(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
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:538
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:483
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:489
Maybe< bool > Has(Local< Context > context, Local< Value > key)
void SetAlignedPointerInInternalField(int index, void *value, EmbedderDataTypeTag tag)
void * GetAlignedPointerFromInternalField(int index, EmbedderDataTypeTag tag)
Definition: v8-object.h:991
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
bool IsCodeLike(Isolate *isolate) const
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
MaybeLocal< Value > CallAsConstructor(Local< Context > context, int argc, Local< Value > argv[])
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
Maybe< bool > SetPrototypeV2(Local< Context > context, Local< Value > prototype)
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:555
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)
bool IsApiWrapper() const
static void Wrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable)
Definition: v8-object.h:1100
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
Local< Data > GetInternalField(int index)
Definition: v8-object.h:944
Local< Value > GetPrototypeV2()
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)
Local< Object > FindInstanceInPrototypeChain(Local< FunctionTemplate > tmpl)
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
static Local< Object > New(Isolate *isolate)
MaybeLocal< Context > GetCreationContext(v8::Isolate *isolate)
void SetInternalField(int index, Local< Data > data)
static T * Unwrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper)
Definition: v8-object.h:1015
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)
MaybeLocal< Array > PreviewEntries(bool *is_key_value)
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)
static Local< Object > New(Isolate *isolate, Local< Value > prototype_or_null, Local< Name > *names, Local< Value > *values, size_t length)
bool HasIndexedLookupInterceptor() const
Definition: v8-persistent-handle.h:93
Definition: v8-object.h:46
static Private * Cast(Data *data)
Definition: v8-object.h:1149
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:187
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:882
static const int kJSObjectHeaderSize
Definition: v8-internal.h:899
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1727
ExternalPointerTag
Definition: v8-internal.h:548
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:243
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:226
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:171
SideEffectType
Definition: v8-object.h:213
@ kHasSideEffectToReceiver
AccessControl
Definition: v8-object.h:187
@ DEFAULT
Definition: v8-object.h:188
IndexFilter
Definition: v8-object.h:232
KeyConversionMode
Definition: v8-object.h:238
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:36
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:34
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:175
PropertyFilter
Definition: v8-object.h:194
@ ONLY_CONFIGURABLE
Definition: v8-object.h:198
@ SKIP_SYMBOLS
Definition: v8-object.h:200
@ ONLY_WRITABLE
Definition: v8-object.h:196
@ ALL_PROPERTIES
Definition: v8-object.h:195
@ SKIP_STRINGS
Definition: v8-object.h:199
@ ONLY_ENUMERABLE
Definition: v8-object.h:197
Definition: v8-sandbox.h:70
Definition: v8-object.h:594
const int16_t type_id
Definition: v8-object.h:595
#define V8_EXPORT
Definition: v8config.h:855
#define V8_INLINE
Definition: v8config.h:508
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:622
#define V8_DEPRECATED(message)
Definition: v8config.h:614
#define V8_LIKELY(condition)
Definition: v8config.h:669
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:679
#define V8_ENUM_DEPRECATED(message)
Definition: v8config.h:658