5#ifndef INCLUDE_V8_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
24class FunctionTemplate;
26class PropertyCallbackInfo;
70 static void CheckCast(
Data* that);
143 PrivateData* private_;
181 "This enum is no longer used and will be removed in V8 12.9.")
374 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
375 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
389 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
390 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
441 "V8 will stop providing access to hidden prototype (i.e. "
442 "JSGlobalObject). Use GetPrototypeV2() instead. "
443 "See http://crbug.com/333672197.")
460 "
V8 will stop providing access to hidden prototype (i.e. "
461 "JSGlobalObject). Use SetPrototypeV2() instead. "
500 int InternalFieldCount() const;
505 return object.template value<Object>()->InternalFieldCount();
511 return object.template value<Object>()->InternalFieldCount();
534 V8_INLINE void* GetAlignedPointerFromInternalField(
int index);
541 return object.template value<Object>()->GetAlignedPointerFromInternalField(
548 return object.template value<Object>()->GetAlignedPointerFromInternalField(
558 "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag parameter "
560 void SetAlignedPointerInInternalField(
int index,
void* value);
562 void SetAlignedPointerInInternalField(
int index,
void* value,
567 "parameter instead.")
568 void SetAlignedPointerInInternalFields(
int argc,
int indices[],
604 template <CppHeapPo
interTag tag,
typename T =
void>
607 template <CppHeapPo
interTag tag,
typename T =
void>
610 template <CppHeapPo
interTag tag,
typename T =
void>
614 template <
typename T =
void>
618 template <
typename T =
void>
622 template <
typename T =
void>
636 template <CppHeapPo
interTag tag>
639 Wrappable* wrappable);
640 template <CppHeapPo
interTag tag>
643 Wrappable* wrappable);
644 template <CppHeapPo
interTag tag>
647 Wrappable* wrappable);
778 return object.template value<Object>()->GetCreationContext(isolate);
798 void* GetAlignedPointerFromEmbedderDataInCreationContext(
v8::
Isolate* isolate,
800 void* GetAlignedPointerFromEmbedderDataInCreationContext(
int index);
807 bool IsCallable() const;
812 bool IsConstructor() const;
825 bool IsApiWrapper() const;
832 bool IsUndetectable() const;
855 "Use
Isolate::GetCurrent() instead, which is guaranteed to return the "
856 "same isolate since https:
860 "Use
Isolate::GetCurrent() instead, which is guaranteed to return the "
861 "same isolate since https:
863 return handle.template value<Object>()->GetIsolate();
910 static void CheckCast(
Value* obj);
912 void* SlowGetAlignedPointerFromInternalField(
int index);
913 void* SlowGetAlignedPointerFromInternalField(
v8::Isolate* isolate,
int index);
919#ifndef V8_ENABLE_CHECKS
925 int instance_type = I::GetInstanceType(obj);
926 if (I::CanHaveInternalField(instance_type)) {
927 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
928 (I::kEmbedderDataSlotSize * index);
929 A value = I::ReadRawField<A>(obj, offset);
930#ifdef V8_COMPRESS_POINTERS
933 value = I::DecompressTaggedField(obj,
static_cast<uint32_t
>(value));
936 auto* isolate = I::GetCurrentIsolate();
940 return SlowGetInternalField(index);
945#if !defined(V8_ENABLE_CHECKS)
951 auto instance_type = I::GetInstanceType(obj);
952 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
953 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
954 (I::kEmbedderDataSlotSize * index) +
955 I::kEmbedderDataSlotExternalPointerOffset;
959 isolate, obj, offset);
960 return reinterpret_cast<void*
>(value);
963 return SlowGetAlignedPointerFromInternalField(isolate, index);
967#if !defined(V8_ENABLE_CHECKS)
973 auto instance_type = I::GetInstanceType(obj);
974 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
975 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
976 (I::kEmbedderDataSlotSize * index) +
977 I::kEmbedderDataSlotExternalPointerOffset;
978 Isolate* isolate = I::GetCurrentIsolateForSandbox();
982 isolate, obj, offset);
983 return reinterpret_cast<void*
>(value);
986 return SlowGetAlignedPointerFromInternalField(index);
990template <CppHeapPo
interTag tag,
typename T>
994#if !defined(V8_ENABLE_CHECKS)
995 return internal::ReadCppHeapPointerField<T>(
998 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1003template <CppHeapPo
interTag tag,
typename T>
1008#if !defined(V8_ENABLE_CHECKS)
1009 return internal::ReadCppHeapPointerField<T>(
1012 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1017template <CppHeapPo
interTag tag,
typename T>
1023#if !defined(V8_ENABLE_CHECKS)
1024 return internal::ReadCppHeapPointerField<T>(
1027 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1032template <
typename T>
1036#if !defined(V8_ENABLE_CHECKS)
1037 return internal::ReadCppHeapPointerField<T>(
1040 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1045template <
typename T>
1050#if !defined(V8_ENABLE_CHECKS)
1051 return internal::ReadCppHeapPointerField<T>(
1055 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1060template <
typename T>
1066#if !defined(V8_ENABLE_CHECKS)
1067 return internal::ReadCppHeapPointerField<T>(
1070 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1075template <CppHeapPo
interTag tag>
1079 Wrap(isolate, obj, tag, wrappable);
1083template <CppHeapPo
interTag tag>
1088 Wrap(isolate, obj, tag, wrappable);
1092template <CppHeapPo
interTag tag>
1098 Wrap(isolate, obj, tag, wrappable);
1105 Wrap(isolate, obj, tag, wrappable);
1113 Wrap(isolate, obj, tag, wrappable);
1122 Wrap(isolate, obj, tag, wrappable);
1126#ifdef V8_ENABLE_CHECKS
1129 return reinterpret_cast<Private*
>(data);
1133#ifdef V8_ENABLE_CHECKS
1136 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-template.h:583
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:583
const char * GetHumanReadableName() const override
Definition: v8-object.h:589
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:585
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:591
Definition: v8-object.h:243
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:1132
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)
Maybe< bool > DefineOwnProperty(Local< Context > context, Local< Name > key, Local< Value > value, PropertyAttribute attributes=None)
void * GetAlignedPointerFromInternalField(int index)
Definition: v8-object.h:966
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)
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:509
Maybe< bool > Has(Local< Context > context, Local< Value > key)
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
bool IsCodeLike(Isolate *isolate) const
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
static void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8-object.h:539
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)
Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
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)
static void Wrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable)
Definition: v8-object.h:1076
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)
MaybeLocal< Array > GetPropertyNames(Local< Context > context, KeyCollectionMode mode, PropertyFilter property_filter, IndexFilter index_filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
Local< Data > GetInternalField(int index)
Definition: v8-object.h:918
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)
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:991
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)
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)
static void * GetAlignedPointerFromInternalField(const BasicTracedReference< Object > &object, int index)
Definition: v8-object.h:546
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:41
static Private * Cast(Data *data)
Definition: v8-object.h:1125
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:101
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:137
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-primitive.h:124
Definition: v8-traced-handle.h:165
Definition: v8-initialization.h:61
Definition: v8-value.h:32
Definition: v8-internal.h:883
static const int kJSObjectHeaderSize
Definition: v8-internal.h:900
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1757
@ kFirstEmbedderDataTag
Definition: v8-internal.h:580
@ kLastEmbedderDataTag
Definition: v8-internal.h:581
uintptr_t Address
Definition: v8-internal.h:52
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:238
PropertyAttribute
Definition: v8-object.h:149
@ DontEnum
Definition: v8-object.h:155
@ None
Definition: v8-object.h:151
@ DontDelete
Definition: v8-object.h:157
@ ReadOnly
Definition: v8-object.h:153
KeyCollectionMode
Definition: v8-object.h:221
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:166
SideEffectType
Definition: v8-object.h:208
@ kHasSideEffectToReceiver
AccessControl
Definition: v8-object.h:182
@ DEFAULT
Definition: v8-object.h:183
IndexFilter
Definition: v8-object.h:227
KeyConversionMode
Definition: v8-object.h:233
CppHeapPointerTag
Definition: v8-sandbox.h:28
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:34
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:170
PropertyFilter
Definition: v8-object.h:189
@ ONLY_CONFIGURABLE
Definition: v8-object.h:193
@ SKIP_SYMBOLS
Definition: v8-object.h:195
@ ONLY_WRITABLE
Definition: v8-object.h:191
@ ALL_PROPERTIES
Definition: v8-object.h:190
@ SKIP_STRINGS
Definition: v8-object.h:194
@ ONLY_ENUMERABLE
Definition: v8-object.h:192
Definition: v8-sandbox.h:70
Definition: v8-object.h:573
const int16_t type_id
Definition: v8-object.h:574
#define V8_EXPORT
Definition: v8config.h:860
#define V8_INLINE
Definition: v8config.h:513
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:627
#define V8_DEPRECATED(message)
Definition: v8config.h:619
#define V8_LIKELY(condition)
Definition: v8config.h:674
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:684
#define V8_ENUM_DEPRECATE_SOON(message)
Definition: v8config.h:664