5#ifndef INCLUDE_V8_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
60 static void CheckCast(Data* that);
133 PrivateData* private_;
171 "This enum is no longer used and will be removed in V8 12.9.")
431 "V8 will stop providing access to hidden prototype (i.e. "
432 "JSGlobalObject). Use GetPrototypeV2() instead. "
433 "See http://crbug.com/333672197.")
450 "V8 will stop providing access to hidden prototype (i.e. "
451 "JSGlobalObject). Use SetPrototypeV2() instead. "
452 "See http://crbug.com/333672197.")
495 return object.template value<Object>()->InternalFieldCount();
501 return object.template value<Object>()->InternalFieldCount();
531 return object.template value<Object>()->GetAlignedPointerFromInternalField(
538 return object.template value<Object>()->GetAlignedPointerFromInternalField(
561 template <CppHeapPo
interTag tag,
typename T =
void>
564 template <CppHeapPo
interTag tag,
typename T =
void>
567 template <CppHeapPo
interTag tag,
typename T =
void>
571 template <
typename T =
void>
575 template <
typename T =
void>
579 template <
typename T =
void>
593 template <CppHeapPo
interTag tag>
597 template <CppHeapPo
interTag tag>
601 template <CppHeapPo
interTag tag>
722 return object.template value<Object>()->GetCreationContext(isolate);
801 return handle.template value<Object>()->GetIsolate();
848 static void CheckCast(
Value* obj);
850 void* SlowGetAlignedPointerFromInternalField(
int index);
851 void* SlowGetAlignedPointerFromInternalField(
v8::Isolate* isolate,
int index);
857#ifndef V8_ENABLE_CHECKS
863 int instance_type = I::GetInstanceType(obj);
864 if (I::CanHaveInternalField(instance_type)) {
865 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
866 (I::kEmbedderDataSlotSize * index);
867 A value = I::ReadRawField<A>(obj, offset);
868#ifdef V8_COMPRESS_POINTERS
871 value = I::DecompressTaggedField(obj,
static_cast<uint32_t
>(value));
879 return SlowGetInternalField(index);
884#if !defined(V8_ENABLE_CHECKS)
890 auto instance_type = I::GetInstanceType(obj);
891 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
892 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
893 (I::kEmbedderDataSlotSize * index) +
894 I::kEmbedderDataSlotExternalPointerOffset;
896 I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
897 isolate, obj, offset);
898 return reinterpret_cast<void*
>(value);
901 return SlowGetAlignedPointerFromInternalField(isolate, index);
905#if !defined(V8_ENABLE_CHECKS)
911 auto instance_type = I::GetInstanceType(obj);
912 if (
V8_LIKELY(I::CanHaveInternalField(instance_type))) {
913 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
914 (I::kEmbedderDataSlotSize * index) +
915 I::kEmbedderDataSlotExternalPointerOffset;
916 Isolate* isolate = I::GetIsolateForSandbox(obj);
918 I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
919 isolate, obj, offset);
920 return reinterpret_cast<void*
>(value);
923 return SlowGetAlignedPointerFromInternalField(index);
927template <CppHeapPo
interTag tag,
typename T>
931#if !defined(V8_ENABLE_CHECKS)
932 return internal::ReadCppHeapPointerField<T>(
935 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
940template <CppHeapPo
interTag tag,
typename T>
945#if !defined(V8_ENABLE_CHECKS)
946 return internal::ReadCppHeapPointerField<T>(
949 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
954template <CppHeapPo
interTag tag,
typename T>
960#if !defined(V8_ENABLE_CHECKS)
961 return internal::ReadCppHeapPointerField<T>(
964 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
973#if !defined(V8_ENABLE_CHECKS)
974 return internal::ReadCppHeapPointerField<T>(
977 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
987#if !defined(V8_ENABLE_CHECKS)
988 return internal::ReadCppHeapPointerField<T>(
992 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1003#if !defined(V8_ENABLE_CHECKS)
1004 return internal::ReadCppHeapPointerField<T>(
1007 return reinterpret_cast<T*
>(
Unwrap(isolate, obj, tag_range));
1012template <CppHeapPo
interTag tag>
1016 Wrap(isolate, obj, tag, wrappable);
1020template <CppHeapPo
interTag tag>
1025 Wrap(isolate, obj, tag, wrappable);
1029template <CppHeapPo
interTag tag>
1035 Wrap(isolate, obj, tag, wrappable);
1042 Wrap(isolate, obj, tag, wrappable);
1050 Wrap(isolate, obj, tag, wrappable);
1059 Wrap(isolate, obj, tag, wrappable);
1063#ifdef V8_ENABLE_CHECKS
1066 return reinterpret_cast<Private*
>(data);
1070#ifdef V8_ENABLE_CHECKS
1073 return static_cast<Object*
>(value);
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
bool HasNamedLookupInterceptor() const
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetPropertyNames(Local< Context > context, KeyCollectionMode mode, PropertyFilter property_filter, IndexFilter index_filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
V8_WARN_UNUSED_RESULT Maybe< bool > HasOwnProperty(Local< Context > context, uint32_t index)
bool HasIndexedLookupInterceptor() const
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value, MaybeLocal< Object > receiver)
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetPropertyAttributes(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > SetPrototypeV2(Local< Context > context, Local< Value > prototype)
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
static V8_INLINE int InternalFieldCount(const BasicTracedReference< Object > &object)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > CallAsConstructor(Local< Context > context, int argc, Local< Value > argv[])
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealNamedProperty(Local< Context > context, Local< Name > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT 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)
Maybe< bool > SetIntegrityLevel(Local< Context > context, IntegrityLevel level)
V8_WARN_UNUSED_RESULT 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 V8_INLINE void * GetAlignedPointerFromInternalField(const BasicTracedReference< Object > &object, int index)
V8_WARN_UNUSED_RESULT Maybe< bool > DefineOwnProperty(Local< Context > context, Local< Name > key, Local< Value > value, PropertyAttribute attributes=None)
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
V8_INLINE Local< Data > GetInternalField(int index)
bool IsApiWrapper() const
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper)
Local< String > GetConstructorName()
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context, PropertyFilter filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
Local< Object > Clone(v8::Isolate *isolate)
Maybe< bool > DeletePrivate(Local< Context > context, Local< Private > key)
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetRealNamedPropertyAttributes(Local< Context > context, Local< Name > key)
V8_DEPRECATE_SOON("V8 will stop providing access to hidden prototype (i.e. " "JSGlobalObject). Use GetPrototypeV2() instead. " "See http://crbug.com/333672197.") Local< Value > GetPrototype()
void * GetAlignedPointerFromEmbedderDataInCreationContext(v8::Isolate *isolate, int index)
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, CppHeapPointerTagRange tag_range)
void SetInternalField(int index, Local< Data > data)
V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Local< Context > context, uint32_t index, Local< Value > value)
MaybeLocal< Array > PreviewEntries(bool *is_key_value)
bool IsCodeLike(Isolate *isolate) const
Local< Value > GetPrototypeV2()
V8_WARN_UNUSED_RESULT MaybeLocal< String > ObjectProtoToString(Local< Context > context)
bool IsConstructor() const
static V8_INLINE Object * Cast(Value *obj)
void SetAccessorProperty(Local< Name > name, Local< Function > getter, Local< Function > setter=Local< Function >(), PropertyAttribute attributes=None)
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const PersistentBase< Object > &wrapper)
void SetAlignedPointerInInternalField(int index, void *value)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetPropertyNames(Local< Context > context)
static V8_INLINE void Wrap(v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, void *wrappable)
void SetAlignedPointerInInternalFields(int argc, int indices[], void *values[])
V8_WARN_UNUSED_RESULT MaybeLocal< Value > CallAsFunction(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
Maybe< bool > SetPrivate(Local< Context > context, Local< Private > key, Local< Value > value)
static V8_INLINE void Wrap(v8::Isolate *isolate, const PersistentBase< Object > &wrapper, void *wrappable)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetOwnPropertyDescriptor(Local< Context > context, Local< Name > key)
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, uint32_t index, Local< Value > value)
V8_WARN_UNUSED_RESULT Maybe< bool > HasOwnProperty(Local< Context > context, Local< Name > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, uint32_t index)
V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Local< Context > context, Local< Name > key, Local< Value > value)
MaybeLocal< Context > GetCreationContext(v8::Isolate *isolate)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, uint32_t index)
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealNamedCallbackProperty(Local< Context > context, Local< Name > key)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, CppHeapPointerTagRange tag_range)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, Local< Value > key, MaybeLocal< Object > receiver)
Local< Object > FindInstanceInPrototypeChain(Local< FunctionTemplate > tmpl)
static Local< Object > New(Isolate *isolate)
static Local< Object > New(Isolate *isolate, Local< Value > prototype_or_null, Local< Name > *names, Local< Value > *values, size_t length)
V8_WARN_UNUSED_RESULT Maybe< bool > DefineProperty(Local< Context > context, Local< Name > key, PropertyDescriptor &descriptor)
bool IsUndetectable() const
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetRealNamedPropertyAttributesInPrototypeChain(Local< Context > context, Local< Name > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, uint32_t index)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetRealNamedProperty(Local< Context > context, Local< Name > key)
static V8_INLINE T * Unwrap(v8::Isolate *isolate, const PersistentBase< Object > &wrapper, CppHeapPointerTagRange tag_range)
static V8_INLINE void Wrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, void *wrappable)
Local< Context > GetCreationContextChecked(v8::Isolate *isolate)
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
int InternalFieldCount() const
Local< Value > Name() const
static Local< Private > ForApi(Isolate *isolate, Local< String > name)
static V8_INLINE Private * Cast(Data *data)
static Local< Private > New(Isolate *isolate, Local< String > name=Local< String >())
PrivateData * get_private() const
bool has_configurable() const
PropertyDescriptor(const PropertyDescriptor &)=delete
bool has_enumerable() const
Local< Value > set() const
void set_configurable(bool configurable)
void operator=(const PropertyDescriptor &)=delete
PropertyDescriptor(Local< Value > get, Local< Value > set)
bool has_writable() const
PropertyDescriptor(Local< Value > value)
Local< Value > value() const
void set_enumerable(bool enumerable)
Local< Value > get() const
PropertyDescriptor(Local< Value > value, bool writable)
bool configurable() const
static const int kJSObjectHeaderSize
static V8_INLINE Address ValueAsAddress(const T *value)
V8_EXPORT internal::Isolate * IsolateFromNeverReadOnlySpaceObject(Address obj)
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
@ kHasSideEffectToReceiver
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
#define V8_DEPRECATE_SOON(message)
#define V8_LIKELY(condition)
#define V8_WARN_UNUSED_RESULT