5#ifndef INCLUDE_V8_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
24class FunctionTemplate;
26class PropertyCallbackInfo;
62 static void CheckCast(
Data* that);
135 PrivateData* private_;
173 "This enum is no longer used and will be removed in V8 12.9.")
366 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
367 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
381 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
382 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
433 "V8 will stop providing access to hidden prototype (i.e. "
434 "JSGlobalObject). Use GetPrototypeV2() instead. "
435 "See http://crbug.com/333672197.")
452 "
V8 will stop providing access to hidden prototype (i.e. "
453 "JSGlobalObject). Use SetPrototypeV2() instead. "
492 int InternalFieldCount() const;
497 return object.template value<Object>()->InternalFieldCount();
503 return object.template value<Object>()->InternalFieldCount();
526 V8_INLINE void* GetAlignedPointerFromInternalField(
int index);
533 return object.template value<Object>()->GetAlignedPointerFromInternalField(
540 return object.template value<Object>()->GetAlignedPointerFromInternalField(
586 template <CppHeapPo
interTag tag,
typename T =
void>
589 template <CppHeapPo
interTag tag,
typename T =
void>
592 template <CppHeapPo
interTag tag,
typename T =
void>
596 template <
typename T =
void>
600 template <
typename T =
void>
604 template <
typename T =
void>
618 template <CppHeapPo
interTag tag>
619 V8_DEPRECATED(
"Use `Wrap` with `Wrappable* wrappable` instead")
624 V8_DEPRECATED("Use `Wrap` with `Wrappable* wrappable` instead")
629 V8_DEPRECATED("Use `Wrap` with `Wrappable* wrappable` instead")
633 V8_DEPRECATED("Use `Wrap` with `Wrappable* wrappable` instead")
637 V8_DEPRECATED("Use `Wrap` with `Wrappable* wrappable` instead")
641 V8_DEPRECATED("Use `Wrap` with `Wrappable* wrappable` instead")
649 Wrappable* wrappable);
653 Wrappable* wrappable);
657 Wrappable* wrappable);
744 bool HasNamedLookupInterceptor() const;
747 bool HasIndexedLookupInterceptor() const;
756 int GetIdentityHash();
788 return object.template value<Object>()->GetCreationContext(isolate);
808 void* GetAlignedPointerFromEmbedderDataInCreationContext(
v8::
Isolate* isolate,
810 void* GetAlignedPointerFromEmbedderDataInCreationContext(
int index);
817 bool IsCallable() const;
822 bool IsConstructor() const;
835 bool IsApiWrapper() const;
842 bool IsUndetectable() const;
865 "Use
Isolate::GetCurrent() instead, which is guaranteed to return the "
866 "same isolate since https:
870 "Use
Isolate::GetCurrent() instead, which is guaranteed to return the "
871 "same isolate since https:
873 return handle.template value<Object>()->GetIsolate();
920 static void CheckCast(
Value* obj);
922 void* SlowGetAlignedPointerFromInternalField(
int index);
923 void* SlowGetAlignedPointerFromInternalField(
v8::Isolate* isolate,
int index);
929#ifndef V8_ENABLE_CHECKS
935 int instance_type = I::GetInstanceType(obj);
936 if (I::CanHaveInternalField(instance_type)) {
937 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
938 (I::kEmbedderDataSlotSize * index);
939 A value = I::ReadRawField<A>(obj, offset);
940#ifdef V8_COMPRESS_POINTERS
943 value = I::DecompressTaggedField(obj,
static_cast<uint32_t
>(value));
946 auto* isolate = I::GetCurrentIsolate();
950 return SlowGetInternalField(index);
955#if !defined(V8_ENABLE_CHECKS)
961 auto instance_type = I::GetInstanceType(obj);
962 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
963 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
964 (I::kEmbedderDataSlotSize * index) +
965 I::kEmbedderDataSlotExternalPointerOffset;
967 I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
968 isolate, obj, offset);
969 return reinterpret_cast<void*
>(value);
972 return SlowGetAlignedPointerFromInternalField(isolate, index);
976#if !defined(V8_ENABLE_CHECKS)
982 auto instance_type = I::GetInstanceType(obj);
983 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
984 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
985 (I::kEmbedderDataSlotSize * index) +
986 I::kEmbedderDataSlotExternalPointerOffset;
987 Isolate* isolate = I::GetCurrentIsolateForSandbox();
989 I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
990 isolate, obj, offset);
991 return reinterpret_cast<void*
>(value);
994 return SlowGetAlignedPointerFromInternalField(index);
998template <CppHeapPo
interTag tag,
typename T>
1002#if !defined(V8_ENABLE_CHECKS)
1003 return internal::ReadCppHeapPointerField<T>(
1006 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1011template <CppHeapPo
interTag tag,
typename T>
1016#if !defined(V8_ENABLE_CHECKS)
1017 return internal::ReadCppHeapPointerField<T>(
1020 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1025template <CppHeapPo
interTag tag,
typename T>
1031#if !defined(V8_ENABLE_CHECKS)
1032 return internal::ReadCppHeapPointerField<T>(
1035 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1040template <
typename T>
1044#if !defined(V8_ENABLE_CHECKS)
1045 return internal::ReadCppHeapPointerField<T>(
1048 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1053template <
typename T>
1058#if !defined(V8_ENABLE_CHECKS)
1059 return internal::ReadCppHeapPointerField<T>(
1063 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1068template <
typename T>
1074#if !defined(V8_ENABLE_CHECKS)
1075 return internal::ReadCppHeapPointerField<T>(
1078 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1083template <CppHeapPo
interTag tag>
1087 Wrap(isolate, obj, tag, wrappable);
1091template <CppHeapPo
interTag tag>
1096 Wrap(isolate, obj, tag, wrappable);
1100template <CppHeapPo
interTag tag>
1106 Wrap(isolate, obj, tag, wrappable);
1113 Wrap(isolate, obj, tag, wrappable);
1121 Wrap(isolate, obj, tag, wrappable);
1130 Wrap(isolate, obj, tag, wrappable);
1134template <CppHeapPo
interTag tag>
1138 Wrap(isolate, obj, tag, wrappable);
1142template <CppHeapPo
interTag tag>
1147 Wrap(isolate, obj, tag, wrappable);
1151template <CppHeapPo
interTag tag>
1157 Wrap(isolate, obj, tag, wrappable);
1164 Wrap(isolate, obj, tag, wrappable);
1172 Wrap(isolate, obj, tag, wrappable);
1181 Wrap(isolate, obj, tag, wrappable);
1185#ifdef V8_ENABLE_CHECKS
1188 return reinterpret_cast<Private*
>(data);
1192#ifdef V8_ENABLE_CHECKS
1195 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:364
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:446
Definition: v8-local-handle.h:732
Definition: v8-maybe.h:39
Definition: v8-primitive.h:79
Definition: v8-object.h:565
const char * GetHumanReadableName() const override
Definition: v8-object.h:571
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:567
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:573
Definition: v8-object.h:235
Maybe< PropertyAttribute > GetPropertyAttributes(Local< Context > context, Local< Value > key)
void SetAlignedPointerInInternalField(int index, void *value)
Maybe< bool > CreateDataProperty(Local< Context > context, uint32_t index, Local< Value > value)
MaybeLocal< Value > GetOwnPropertyDescriptor(Local< Context > context, Local< Name > key)
static void Wrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, void *wrappable)
Definition: v8-object.h:1084
static Object * Cast(Value *obj)
Definition: v8-object.h:1191
Maybe< bool > SetPrivate(Local< Context > context, Local< Private > key, Local< Value > value)
MaybeLocal< Array > GetPropertyNames(Local< Context > context)
Maybe< bool > Delete(Local< Context > context, uint32_t index)
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:975
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 BasicTracedReference< Object > &object)
Definition: v8-object.h:501
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:531
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 > 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)
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:928
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
static Local< Object > New(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:999
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)
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)
void SetAlignedPointerInInternalFields(int argc, int indices[], void *values[])
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:538
static Local< Object > New(Isolate *isolate, Local< Value > prototype_or_null, Local< Name > *names, Local< Value > *values, size_t length)
Definition: v8-persistent-handle.h:93
Definition: v8-object.h:33
static Private * Cast(Data *data)
Definition: v8-object.h:1184
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:93
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:129
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:874
static const int kJSObjectHeaderSize
Definition: v8-internal.h:891
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1748
uintptr_t Address
Definition: v8-internal.h:52
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:230
PropertyAttribute
Definition: v8-object.h:141
@ DontEnum
Definition: v8-object.h:147
@ None
Definition: v8-object.h:143
@ DontDelete
Definition: v8-object.h:149
@ ReadOnly
Definition: v8-object.h:145
KeyCollectionMode
Definition: v8-object.h:213
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:158
SideEffectType
Definition: v8-object.h:200
@ kHasSideEffectToReceiver
AccessControl
Definition: v8-object.h:174
@ DEFAULT
Definition: v8-object.h:175
IndexFilter
Definition: v8-object.h:219
KeyConversionMode
Definition: v8-object.h:225
CppHeapPointerTag
Definition: v8-sandbox.h:28
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:162
PropertyFilter
Definition: v8-object.h:181
@ ONLY_CONFIGURABLE
Definition: v8-object.h:185
@ SKIP_SYMBOLS
Definition: v8-object.h:187
@ ONLY_WRITABLE
Definition: v8-object.h:183
@ ALL_PROPERTIES
Definition: v8-object.h:182
@ SKIP_STRINGS
Definition: v8-object.h:186
@ ONLY_ENUMERABLE
Definition: v8-object.h:184
Definition: v8-sandbox.h:70
Definition: v8-object.h:555
const int16_t type_id
Definition: v8-object.h:556
#define V8_EXPORT
Definition: v8config.h:849
#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