Loading...
Searching...
No Matches
v8-object.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
7
10#include "v8-internal.h" // NOLINT(build/include_directory)
11#include "v8-local-handle.h" // NOLINT(build/include_directory)
12#include "v8-maybe.h" // NOLINT(build/include_directory)
13#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
14#include "v8-primitive.h" // NOLINT(build/include_directory)
15#include "v8-sandbox.h" // NOLINT(build/include_directory)
16#include "v8-traced-handle.h" // NOLINT(build/include_directory)
17#include "v8-value.h" // NOLINT(build/include_directory)
18#include "v8config.h" // NOLINT(build/include_directory)
19
20namespace v8 {
21
22class Array;
23class Function;
24class FunctionTemplate;
25template <typename T>
26class PropertyCallbackInfo;
27
34using EmbedderDataTypeTag = uint16_t;
35
37
40
46class V8_EXPORT Private : public Data {
47 public:
52
56 static Local<Private> New(Isolate* isolate,
58
69
70 V8_INLINE static Private* Cast(Data* data);
71
72 private:
73 Private();
74
75 static void CheckCast(Data* that);
76};
77
107 public:
108 // GenericDescriptor
110
111 // DataDescriptor
113
114 // DataDescriptor with writable property
115 PropertyDescriptor(Local<Value> value, bool writable);
116
117 // AccessorDescriptor
119
121
123 bool has_value() const;
124
126 bool has_get() const;
128 bool has_set() const;
129
130 void set_enumerable(bool enumerable);
131 bool enumerable() const;
132 bool has_enumerable() const;
133
134 void set_configurable(bool configurable);
135 bool configurable() const;
136 bool has_configurable() const;
137
138 bool writable() const;
139 bool has_writable() const;
140
141 struct PrivateData;
142 PrivateData* get_private() const { return private_; }
143
145 void operator=(const PropertyDescriptor&) = delete;
146
147 private:
148 PrivateData* private_;
149};
150
156 None = 0,
158 ReadOnly = 1 << 0,
160 DontEnum = 1 << 1,
162 DontDelete = 1 << 2
164
180 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
181
202 void (*)(Local<Name> property, Local<Value> value,
204// TODO(https://crbug.com/348660658): deprecate and remove.
206 void (*)(Local<Name> property, Local<Value> value,
207 const PropertyCallbackInfo<void>& info);
208
218 SKIP_SYMBOLS = 16
220
231enum class SideEffectType {
235};
236
245
251
257
262
266class V8_EXPORT Object : public Value {
267 public:
273 Local<Value> key, Local<Value> value);
275 Local<Value> key, Local<Value> value,
276 MaybeLocal<Object> receiver);
277
279 Local<Value> value);
280
292 Local<Name> key,
293 Local<Value> value);
295 uint32_t index,
296 Local<Value> value);
297
308 Local<Context> context, Local<Name> key, Local<Value> value,
309 PropertyAttribute attributes = None);
310
328 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
329
331 Local<Value> key);
333 Local<Value> key,
334 MaybeLocal<Object> receiver);
335
337 uint32_t index);
338
349 Local<Context> context, Local<Value> key);
359 Local<Context> context, Local<Value> key,
360 PropertyAttribute* out_attributes);
361
367 Local<Context> context, Local<Name> key);
368
385 Local<Value> key);
386
388 Local<Value> key);
389
391
393 uint32_t index);
394
401 PropertyAttribute attributes = None);
402
408 Local<Context> context, Local<Name> name,
410 Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
411 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
412 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
413 V8_DEPRECATED("Use AccessorNameSetterCallbackV2 setter instead")
414 V8_WARN_UNUSED_RESULT Maybe<bool> SetNativeDataProperty(
415 Local<Context> context, Local<Name> name,
417 Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
418 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
419 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
420 // TODO(https://crbug.com/348660658): remove once AccessorNameSetterCallback
421 // is removed.
422 V8_WARN_UNUSED_RESULT Maybe<bool> SetNativeDataProperty(
423 Local<Context> context, Local<Name> name,
424 AccessorNameGetterCallback getter, std::nullptr_t setter = nullptr,
425 Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
426 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
427 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect) {
428 return SetNativeDataProperty(
429 context, name, getter,
430 static_cast<AccessorNameSetterCallbackV2>(setter), data, attributes,
431 getter_side_effect_type, setter_side_effect_type);
432 }
433
443 Local<Context> context, Local<Name> name,
445 PropertyAttribute attributes = None,
446 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
447 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
448
457 Local<Value> value);
460
468 Local<Context> context);
470 Local<Context> context, KeyCollectionMode mode,
471 PropertyFilter property_filter, IndexFilter index_filter,
472 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
473
480 Local<Context> context);
481
489 Local<Context> context, PropertyFilter filter,
490 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
491
497 // TODO(http://crbug.com/333672197): deprecate and remove.
498 V8_DEPRECATED("Use GetPrototype().")
499 inline Local<Value> GetPrototypeV2() { return GetPrototype(); }
500
506 Local<Value> prototype);
507 // TODO(http://crbug.com/333672197): deprecate and remove.
508 V8_DEPRECATED("Use SetPrototype().")
509 V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototypeV2(Local<Context> context,
510 Local<Value> prototype) {
511 return SetPrototype(context, prototype);
512 }
513
519
526 Local<Context> context);
527
532
537
540
543 const PersistentBase<Object>& object) {
544 return object.template value<Object>()->InternalFieldCount();
545 }
546
549 const BasicTracedReference<Object>& object) {
550 return object.template value<Object>()->InternalFieldCount();
551 }
552
563 V8_INLINE Local<Data> GetInternalField(int index);
564
566 void SetInternalField(int index, Local<Data> data);
567
573 V8_INLINE void* GetAlignedPointerFromInternalField(int index,
575 V8_INLINE void* GetAlignedPointerFromInternalField(v8::Isolate* isolate,
576 int index,
578
581 const PersistentBase<Object>& object, int index,
583 return object.template value<Object>()->GetAlignedPointerFromInternalField(
584 index, tag);
585 }
586
589 const BasicTracedReference<Object>& object, int index,
591 return object.template value<Object>()->GetAlignedPointerFromInternalField(
592 index, tag);
593 }
594
600 void SetAlignedPointerInInternalField(int index, void* value,
602
603 // Type information for a Wrappable object that got wrapped with
604 // `v8::Object::Wrap()`.
606 const int16_t type_id;
607 };
608
609 // v8::Object::Wrappable serves as the base class for all C++ objects that can
610 // be wrapped by a JavaScript object using `v8::Object::Wrap()`.
611 //
612 // Note that v8::Object::Wrappable` inherits from `NameProvider` and provides
613 // `GetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
614 class Wrappable : public cppgc::GarbageCollected<Wrappable>,
615 public cppgc::NameProvider {
616 public:
617 virtual const WrapperTypeInfo* GetWrapperTypeInfo() const {
618 return nullptr;
619 }
620
621 const char* GetHumanReadableName() const override { return "internal"; }
622
623 virtual void Trace(cppgc::Visitor* visitor) const {}
624 };
625
636 template <CppHeapPointerTag tag, typename T = void>
637 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
638 const v8::Local<v8::Object>& wrapper);
639 template <CppHeapPointerTag tag, typename T = void>
640 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
641 const PersistentBase<Object>& wrapper);
642 template <CppHeapPointerTag tag, typename T = void>
643 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
644 const BasicTracedReference<Object>& wrapper);
645
646 template <typename T = void>
647 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
648 const v8::Local<v8::Object>& wrapper,
649 CppHeapPointerTagRange tag_range);
650 template <typename T = void>
651 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
652 const PersistentBase<Object>& wrapper,
653 CppHeapPointerTagRange tag_range);
654 template <typename T = void>
655 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
656 const BasicTracedReference<Object>& wrapper,
657 CppHeapPointerTagRange tag_range);
658
668 template <CppHeapPointerTag tag>
669 static V8_INLINE void Wrap(v8::Isolate* isolate,
670 const v8::Local<v8::Object>& wrapper,
671 Wrappable* wrappable);
672 template <CppHeapPointerTag tag>
673 static V8_INLINE void Wrap(v8::Isolate* isolate,
674 const PersistentBase<Object>& wrapper,
675 Wrappable* wrappable);
676 template <CppHeapPointerTag tag>
677 static V8_INLINE void Wrap(v8::Isolate* isolate,
678 const BasicTracedReference<Object>& wrapper,
679 Wrappable* wrappable);
680 static V8_INLINE void Wrap(v8::Isolate* isolate,
681 const v8::Local<v8::Object>& wrapper,
682 Wrappable* wrappable, CppHeapPointerTag tag);
683 static V8_INLINE void Wrap(v8::Isolate* isolate,
684 const PersistentBase<Object>& wrapper,
685 Wrappable* wrappable, CppHeapPointerTag tag);
686 static V8_INLINE void Wrap(v8::Isolate* isolate,
687 const BasicTracedReference<Object>& wrapper,
688 Wrappable* wrappable, CppHeapPointerTag tag);
689
690 // Version of Wrap() function for v8::Context::Global() objects.
691 // Unlike the functions above it wraps both JSGlobalProxy and its hidden
692 // prototype (JSGlobalObject or remote object).
693 static void WrapGlobal(v8::Isolate* isolate,
694 const v8::Local<v8::Object>& wrapper,
695 Wrappable* wrappable, CppHeapPointerTag tag);
696
697 // Checks that wrappables set on JSGlobalProxy and its hidden prototype are
698 // the same.
699 static bool CheckGlobalWrappable(v8::Isolate* isolate,
700 const v8::Local<v8::Object>& wrapper,
701 CppHeapPointerTagRange tag_range);
702
710 Local<Name> key);
712 uint32_t index);
727 Local<Name> key);
729 Local<Context> context, uint32_t index);
731 Local<Context> context, Local<Name> key);
732
738 Local<Context> context, Local<Name> key);
739
747 Local<Name> key);
748
755 Local<Context> context, Local<Name> key);
756
763 Local<Context> context, Local<Name> key);
764
767
770
779
788
795 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
796 MaybeLocal<Context> GetCreationContext();
797
803 Local<Context> GetCreationContextChecked(v8::Isolate* isolate);
804 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
805 Local<Context> GetCreationContextChecked();
806
808 V8_INLINE static MaybeLocal<Context> GetCreationContext(
809 v8::Isolate* isolate, const PersistentBase<Object>& object) {
810 return object.template value<Object>()->GetCreationContext(isolate);
811 }
812 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
813 V8_INLINE static MaybeLocal<Context> GetCreationContext(
814 const PersistentBase<Object>& object);
815
835 void* GetAlignedPointerFromEmbedderDataInCreationContext(
836 v8::Isolate* isolate, int index, EmbedderDataTypeTag tag);
837 void* GetAlignedPointerFromEmbedderDataInCreationContext(
838 int index, EmbedderDataTypeTag tag);
839
840 void* GetAlignedPointerFromEmbedderDataInCreationContext(
841 v8::Isolate* isolate, int index, CppHeapPointerTag tag) {
842 // TODO(ahaas): This is a temporary implementation, the actual
843 // implementation will follow with the refactoring of EmbedderDataSlots.
844 // The refactoring will regress the existing API, as the fast path will move
845 // to this new API.
846 // By using this temporary implementation, blink's ScriptState can already
847 // switch to the new API, and thereby switch from the old fast path to the
848 // new fast path directly.
849 return GetAlignedPointerFromEmbedderDataInCreationContext(
850 isolate, index, kEmbedderDataTypeTagDefault);
851 }
857 bool IsCallable() const;
858
862 bool IsConstructor() const;
863
875 bool IsApiWrapper() const;
876
882 bool IsUndetectable() const;
883
889 Local<Value> recv,
890 int argc,
891 Local<Value> argv[]);
892
899 Local<Context> context, int argc, Local<Value> argv[]);
900
911
912 static Local<Object> New(Isolate* isolate);
913
922 static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
923 Local<Name>* names, Local<Value>* values,
924 size_t length);
925
926 V8_INLINE static Object* Cast(Value* obj);
927
936 bool IsCodeLike(Isolate* isolate) const;
937
938 private:
939 static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj,
940 CppHeapPointerTagRange tag_range);
941 static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj,
942 CppHeapPointerTag tag, void* wrappable);
943
944 Object();
945 static void CheckCast(Value* obj);
946 Local<Data> SlowGetInternalField(int index);
947 void* SlowGetAlignedPointerFromInternalField(int index,
949 void* SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate, int index,
951};
952
953// --- Implementation ---
954
956#ifndef V8_ENABLE_CHECKS
957 using A = internal::Address;
958 using I = internal::Internals;
960 // Fast path: If the object is a plain JSObject, which is the common case, we
961 // know where to find the internal fields and can return the value directly.
962 int instance_type = I::GetInstanceType(obj);
963 if (I::CanHaveInternalField(instance_type)) {
964 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
965 (I::kEmbedderDataSlotSize * index);
966 A value = I::ReadRawField<A>(obj, offset);
967#ifdef V8_COMPRESS_POINTERS
968 // We read the full pointer value and then decompress it in order to avoid
969 // dealing with potential endianness issues.
970 value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
971#endif
972
973 auto* isolate = I::GetCurrentIsolate();
974 return Local<Data>::New(isolate, value);
975 }
976#endif
977 return SlowGetInternalField(index);
978}
979
981 int index,
983#if !defined(V8_ENABLE_CHECKS)
984 using A = internal::Address;
985 using I = internal::Internals;
987 // Fast path: If the object is a plain JSObject, which is the common case, we
988 // know where to find the internal fields and can return the value directly.
989 auto instance_type = I::GetInstanceType(obj);
990 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
991 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
992 (I::kEmbedderDataSlotSize * index) +
993 I::kEmbedderDataSlotExternalPointerOffset;
994 A value = I::ReadExternalPointerField(isolate, obj, offset,
996 return reinterpret_cast<void*>(value);
997 }
998#endif
999 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
1000}
1001
1003 EmbedderDataTypeTag tag) {
1004#if !defined(V8_ENABLE_CHECKS)
1005 using A = internal::Address;
1006 using I = internal::Internals;
1008 // Fast path: If the object is a plain JSObject, which is the common case, we
1009 // know where to find the internal fields and can return the value directly.
1010 auto instance_type = I::GetInstanceType(obj);
1011 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
1012 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
1013 (I::kEmbedderDataSlotSize * index) +
1014 I::kEmbedderDataSlotExternalPointerOffset;
1015 Isolate* isolate = I::GetCurrentIsolateForSandbox();
1016 A value = I::ReadExternalPointerField(isolate, obj, offset,
1018 return reinterpret_cast<void*>(value);
1019 }
1020#endif
1021 return SlowGetAlignedPointerFromInternalField(index, tag);
1022}
1023
1024// static
1025template <CppHeapPointerTag tag, typename T>
1027 CppHeapPointerTagRange tag_range(tag, tag);
1028 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1029#if !defined(V8_ENABLE_CHECKS)
1030 return internal::ReadCppHeapPointerField<T>(
1031 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1032#else // defined(V8_ENABLE_CHECKS)
1033 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1034#endif // defined(V8_ENABLE_CHECKS)
1035}
1036
1037// static
1038template <CppHeapPointerTag tag, typename T>
1040 CppHeapPointerTagRange tag_range(tag, tag);
1041 auto obj =
1042 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1043#if !defined(V8_ENABLE_CHECKS)
1044 return internal::ReadCppHeapPointerField<T>(
1045 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1046#else // defined(V8_ENABLE_CHECKS)
1047 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1048#endif // defined(V8_ENABLE_CHECKS)
1049}
1050
1051// static
1052template <CppHeapPointerTag tag, typename T>
1054 const BasicTracedReference<Object>& wrapper) {
1055 CppHeapPointerTagRange tag_range(tag, tag);
1056 auto obj =
1057 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1058#if !defined(V8_ENABLE_CHECKS)
1059 return internal::ReadCppHeapPointerField<T>(
1060 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1061#else // defined(V8_ENABLE_CHECKS)
1062 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1063#endif // defined(V8_ENABLE_CHECKS)
1064}
1065
1066// static
1067template <typename T>
1069 CppHeapPointerTagRange tag_range) {
1070 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1071#if !defined(V8_ENABLE_CHECKS)
1072 return internal::ReadCppHeapPointerField<T>(
1073 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1074#else // defined(V8_ENABLE_CHECKS)
1075 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1076#endif // defined(V8_ENABLE_CHECKS)
1077}
1078
1079// static
1080template <typename T>
1082 CppHeapPointerTagRange tag_range) {
1083 auto obj =
1084 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1085#if !defined(V8_ENABLE_CHECKS)
1086 return internal::ReadCppHeapPointerField<T>(
1087 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1088#else // defined(V8_ENABLE_CHECKS)
1089
1090 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1091#endif // defined(V8_ENABLE_CHECKS)
1092}
1093
1094// static
1095template <typename T>
1097 const BasicTracedReference<Object>& wrapper,
1098 CppHeapPointerTagRange tag_range) {
1099 auto obj =
1100 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1101#if !defined(V8_ENABLE_CHECKS)
1102 return internal::ReadCppHeapPointerField<T>(
1103 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1104#else // defined(V8_ENABLE_CHECKS)
1105 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1106#endif // defined(V8_ENABLE_CHECKS)
1107}
1108
1109// static
1110template <CppHeapPointerTag tag>
1111void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1112 v8::Object::Wrappable* wrappable) {
1113 static_assert(kObjectWrappableTagRange.Contains(tag),
1114 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1115 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1116 Wrap(isolate, obj, tag, wrappable);
1117}
1118
1119// static
1120template <CppHeapPointerTag tag>
1122 v8::Object::Wrappable* wrappable) {
1123 static_assert(kObjectWrappableTagRange.Contains(tag),
1124 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1125 auto obj =
1126 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1127 Wrap(isolate, obj, tag, wrappable);
1128}
1129
1130// static
1131template <CppHeapPointerTag tag>
1133 const BasicTracedReference<Object>& wrapper,
1134 v8::Object::Wrappable* wrappable) {
1135 static_assert(kObjectWrappableTagRange.Contains(tag),
1136 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1137 auto obj =
1138 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1139 Wrap(isolate, obj, tag, wrappable);
1140}
1141
1142// static
1143void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1144 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1145 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1146 Wrap(isolate, obj, tag, wrappable);
1147}
1148
1149// static
1151 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1152 auto obj =
1153 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1154 Wrap(isolate, obj, tag, wrappable);
1155}
1156
1157// static
1159 const BasicTracedReference<Object>& wrapper,
1160 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1161 auto obj =
1162 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1163 Wrap(isolate, obj, tag, wrappable);
1164}
1165
1167#ifdef V8_ENABLE_CHECKS
1168 CheckCast(data);
1169#endif
1170 return reinterpret_cast<Private*>(data);
1171}
1172
1174#ifdef V8_ENABLE_CHECKS
1175 CheckCast(value);
1176#endif
1177 return static_cast<Object*>(value);
1178}
1179
1180} // namespace v8
1181
1182#endif // INCLUDE_V8_OBJECT_H_
Definition: garbage-collected.h:53
Definition: name-provider.h:26
Definition: visitor.h:78
Definition: v8-traced-handle.h:124
Definition: v8-context.h:48
Definition: v8-data.h:18
Definition: v8-isolate.h:292
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-primitive.h:81
Definition: v8-object.h:615
const char * GetHumanReadableName() const override
Definition: v8-object.h:621
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:617
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:623
Definition: v8-object.h:266
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:1173
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)
bool IsConstructor() const
bool IsUndetectable() const
MaybeLocal< Value > CallAsFunction(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
Local< Object > Clone()
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:580
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:542
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:548
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:1002
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[])
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:588
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:1111
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:955
Maybe< PropertyAttribute > GetRealNamedPropertyAttributes(Local< Context > context, Local< Name > key)
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallbackV2 setter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
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)
static Local< Object > New(Isolate *isolate)
int GetIdentityHash()
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:1026
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)
bool IsCallable() const
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:1166
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:224
Definition: v8-object.h:106
void set_enumerable(bool enumerable)
bool has_writable() const
bool has_value() 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
bool enumerable() 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:975
static const int kJSObjectHeaderSize
Definition: v8-internal.h:992
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1853
ExternalPointerTag
Definition: v8-internal.h:673
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:261
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:244
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:180
SideEffectType
Definition: v8-object.h:231
IndexFilter
Definition: v8-object.h:250
KeyConversionMode
Definition: v8-object.h:256
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:207
constexpr CppHeapPointerTagRange kObjectWrappableTagRange(CppHeapPointerTag::kFirstObjectWrappableTag, CppHeapPointerTag::kLastObjectWrappableTag)
PropertyFilter
Definition: v8-object.h:212
@ ONLY_CONFIGURABLE
Definition: v8-object.h:216
@ SKIP_SYMBOLS
Definition: v8-object.h:218
@ ONLY_WRITABLE
Definition: v8-object.h:214
@ ALL_PROPERTIES
Definition: v8-object.h:213
@ SKIP_STRINGS
Definition: v8-object.h:217
@ ONLY_ENUMERABLE
Definition: v8-object.h:215
Definition: v8-object.h:605
const int16_t type_id
Definition: v8-object.h:606
Definition: v8-internal.h:517
constexpr bool Contains(Tag tag) const
Definition: v8-internal.h:552
#define V8_EXPORT
Definition: v8config.h:867
#define V8_INLINE
Definition: v8config.h:511
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:624
#define V8_DEPRECATED(message)
Definition: v8config.h:616
#define V8_LIKELY(condition)
Definition: v8config.h:671
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:681