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
8#include <type_traits>
9
11#include "cppgc/name-provider.h"
12#include "cppgc/type-traits.h"
13#include "v8-internal.h" // NOLINT(build/include_directory)
14#include "v8-local-handle.h" // NOLINT(build/include_directory)
15#include "v8-maybe.h" // NOLINT(build/include_directory)
16#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
17#include "v8-primitive.h" // NOLINT(build/include_directory)
18#include "v8-sandbox.h" // NOLINT(build/include_directory)
19#include "v8-traced-handle.h" // NOLINT(build/include_directory)
20#include "v8-value.h" // NOLINT(build/include_directory)
21#include "v8config.h" // NOLINT(build/include_directory)
22
23namespace v8 {
24
25class Array;
26class Function;
27class FunctionTemplate;
28template <typename T>
29class PropertyCallbackInfo;
30
37using EmbedderDataTypeTag = uint16_t;
38
40
43
49class V8_EXPORT Private : public Data {
50 public:
55
59 static Local<Private> New(Isolate* isolate,
61
72
73 V8_INLINE static Private* Cast(Data* data);
74
75 private:
76 Private();
77
78 static void CheckCast(Data* that);
79};
80
110 public:
111 // GenericDescriptor
113
114 // DataDescriptor
116
117 // DataDescriptor with writable property
118 PropertyDescriptor(Local<Value> value, bool writable);
119
120 // AccessorDescriptor
122
124
126 bool has_value() const;
127
129 bool has_get() const;
131 bool has_set() const;
132
133 void set_enumerable(bool enumerable);
134 bool enumerable() const;
135 bool has_enumerable() const;
136
137 void set_configurable(bool configurable);
138 bool configurable() const;
139 bool has_configurable() const;
140
141 bool writable() const;
142 bool has_writable() const;
143
144 struct PrivateData;
145 PrivateData* get_private() const { return private_; }
146
148 void operator=(const PropertyDescriptor&) = delete;
149
150 private:
151 PrivateData* private_;
152};
153
159 None = 0,
161 ReadOnly = 1 << 0,
163 DontEnum = 1 << 1,
165 DontDelete = 1 << 2
167
183 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
184
205 void (*)(Local<Name> property, Local<Value> value,
207// TODO(https://crbug.com/348660658): deprecate and remove.
209 V8_DEPRECATE_SOON("Use AccessorNameSetterCallback instead.") =
211
221 SKIP_SYMBOLS = 16
223
234enum class SideEffectType {
238};
239
248
254
260
265
269class V8_EXPORT Object : public Value {
270 public:
276 Local<Value> key, Local<Value> value);
278 Local<Value> key, Local<Value> value,
279 MaybeLocal<Object> receiver);
280
282 Local<Value> value);
283
295 Local<Name> key,
296 Local<Value> value);
298 uint32_t index,
299 Local<Value> value);
300
311 Local<Context> context, Local<Name> key, Local<Value> value,
312 PropertyAttribute attributes = None);
313
331 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
332
334 Local<Value> key);
336 Local<Value> key,
337 MaybeLocal<Object> receiver);
338
340 uint32_t index);
341
357 Local<Context> context, Local<Name> key);
358
369 Local<Context> context, Local<Value> key);
379 Local<Context> context, Local<Value> key,
380 PropertyAttribute* out_attributes);
381
387 Local<Context> context, Local<Name> key);
388
405 Local<Value> key);
406
408 Local<Value> key);
409
411
413 uint32_t index);
414
421 PropertyAttribute attributes = None);
422
428 Local<Context> context, Local<Name> name,
430 AccessorNameSetterCallback setter = nullptr,
431 Local<Data> data = Local<Data>(), PropertyAttribute attributes = None,
432 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
433 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
434
444 Local<Context> context, Local<Name> name,
446 PropertyAttribute attributes = None,
447 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
448 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
449
458 Local<Value> value);
461
469 Local<Context> context);
471 Local<Context> context, KeyCollectionMode mode,
472 PropertyFilter property_filter, IndexFilter index_filter,
473 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
474
481 Local<Context> context);
482
490 Local<Context> context, PropertyFilter filter,
491 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
492
498
504 Local<Value> prototype);
505
511
518 Local<Context> context);
519
524
529
532
535 const PersistentBase<Object>& object) {
536 return object.template value<Object>()->InternalFieldCount();
537 }
538
541 const BasicTracedReference<Object>& object) {
542 return object.template value<Object>()->InternalFieldCount();
543 }
544
555 V8_INLINE Local<Data> GetInternalField(int index);
556
558 void SetInternalField(int index, Local<Data> data);
559
565 V8_INLINE void* GetAlignedPointerFromInternalField(int index,
567 V8_INLINE void* GetAlignedPointerFromInternalField(v8::Isolate* isolate,
568 int index,
570
576 template <typename T>
577 requires cppgc::IsGarbageCollectedTypeV<T>
578 V8_INLINE T* GetPointerFromInternalField(v8::Isolate* isolate, int index,
580
583 const PersistentBase<Object>& object, int index,
585 return object.template value<Object>()->GetAlignedPointerFromInternalField(
586 index, tag);
587 }
588 template <typename T>
589 requires cppgc::IsGarbageCollectedTypeV<T>
591 v8::Isolate* isolate, const PersistentBase<Object>& object, int index,
592 CppHeapPointerTag tag) {
593 return object.template value<Object>()->GetPointerFromInternalField<T>(
594 isolate, index, tag);
595 }
596
599 const BasicTracedReference<Object>& object, int index,
601 return object.template value<Object>()->GetAlignedPointerFromInternalField(
602 index, tag);
603 }
604 template <typename T>
605 requires cppgc::IsGarbageCollectedTypeV<T>
607 v8::Isolate* isolate, const BasicTracedReference<Object>& object,
608 int index, CppHeapPointerTag tag) {
609 return object.template value<Object>()->GetPointerFromInternalField<T>(
610 isolate, index, tag);
611 }
612
618 void SetAlignedPointerInInternalField(int index, void* value,
620
626 template <typename T>
627 requires(!std::is_void_v<T>) && cppgc::IsGarbageCollectedTypeV<T>
628 void SetPointerInInternalField(int index, T* value, CppHeapPointerTag tag) {
629 SetPointerInInternalFieldInternal(index, static_cast<void*>(value), tag);
630 }
631
632 // Type information for a Wrappable object that got wrapped with
633 // `v8::Object::Wrap()`.
635 const int16_t type_id;
636 };
637
638 // v8::Object::Wrappable serves as the base class for all C++ objects that can
639 // be wrapped by a JavaScript object using `v8::Object::Wrap()`.
640 //
641 // Note that v8::Object::Wrappable` inherits from `NameProvider` and provides
642 // `GetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
643 class Wrappable : public cppgc::GarbageCollected<Wrappable>,
644 public cppgc::NameProvider {
645 public:
646 virtual const WrapperTypeInfo* GetWrapperTypeInfo() const {
647 return nullptr;
648 }
649
650 const char* GetHumanReadableName() const override { return "internal"; }
651
652 virtual void Trace(cppgc::Visitor* visitor) const {}
653 };
654
665 template <CppHeapPointerTag tag, typename T = void>
666 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
667 const v8::Local<v8::Object>& wrapper);
668 template <CppHeapPointerTag tag, typename T = void>
669 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
670 const PersistentBase<Object>& wrapper);
671 template <CppHeapPointerTag tag, typename T = void>
672 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
673 const BasicTracedReference<Object>& wrapper);
674
675 template <typename T = void>
676 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
677 const v8::Local<v8::Object>& wrapper,
678 CppHeapPointerTagRange tag_range);
679 template <typename T = void>
680 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
681 const PersistentBase<Object>& wrapper,
682 CppHeapPointerTagRange tag_range);
683 template <typename T = void>
684 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
685 const BasicTracedReference<Object>& wrapper,
686 CppHeapPointerTagRange tag_range);
687
697 template <CppHeapPointerTag tag>
698 static V8_INLINE void Wrap(v8::Isolate* isolate,
699 const v8::Local<v8::Object>& wrapper,
700 Wrappable* wrappable);
701 template <CppHeapPointerTag tag>
702 static V8_INLINE void Wrap(v8::Isolate* isolate,
703 const PersistentBase<Object>& wrapper,
704 Wrappable* wrappable);
705 template <CppHeapPointerTag tag>
706 static V8_INLINE void Wrap(v8::Isolate* isolate,
707 const BasicTracedReference<Object>& wrapper,
708 Wrappable* wrappable);
709 static V8_INLINE void Wrap(v8::Isolate* isolate,
710 const v8::Local<v8::Object>& wrapper,
711 Wrappable* wrappable, CppHeapPointerTag tag);
712 static V8_INLINE void Wrap(v8::Isolate* isolate,
713 const PersistentBase<Object>& wrapper,
714 Wrappable* wrappable, CppHeapPointerTag tag);
715 static V8_INLINE void Wrap(v8::Isolate* isolate,
716 const BasicTracedReference<Object>& wrapper,
717 Wrappable* wrappable, CppHeapPointerTag tag);
718
719 // Version of Wrap() function for v8::Context::Global() objects.
720 // Unlike the functions above it wraps both JSGlobalProxy and its hidden
721 // prototype (JSGlobalObject or remote object).
722 static void WrapGlobal(v8::Isolate* isolate,
723 const v8::Local<v8::Object>& wrapper,
724 Wrappable* wrappable, CppHeapPointerTag tag);
725
726 // Checks that wrappables set on JSGlobalProxy and its hidden prototype are
727 // the same.
728 static bool CheckGlobalWrappable(v8::Isolate* isolate,
729 const v8::Local<v8::Object>& wrapper,
730 CppHeapPointerTagRange tag_range);
731
739 Local<Name> key);
741 uint32_t index);
756 Local<Name> key);
758 Local<Context> context, uint32_t index);
760 Local<Context> context, Local<Name> key);
761
767 Local<Context> context, Local<Name> key);
768
776 Local<Name> key);
777
784 Local<Context> context, Local<Name> key);
785
792 Local<Context> context, Local<Name> key);
793
796
799
808
817
824 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
825 MaybeLocal<Context> GetCreationContext();
826
832 Local<Context> GetCreationContextChecked(v8::Isolate* isolate);
833 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
834 Local<Context> GetCreationContextChecked();
835
837 V8_INLINE static MaybeLocal<Context> GetCreationContext(
838 v8::Isolate* isolate, const PersistentBase<Object>& object) {
839 return object.template value<Object>()->GetCreationContext(isolate);
840 }
841 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
842 V8_INLINE static MaybeLocal<Context> GetCreationContext(
843 const PersistentBase<Object>& object);
844
864 void* GetAlignedPointerFromEmbedderDataInCreationContext(
865 v8::Isolate* isolate, int index, EmbedderDataTypeTag tag);
866 void* GetAlignedPointerFromEmbedderDataInCreationContext(
867 int index, EmbedderDataTypeTag tag);
868
869 void* GetAlignedPointerFromEmbedderDataInCreationContext(
870 v8::Isolate* isolate, int index, CppHeapPointerTag tag);
876 bool IsCallable() const;
877
881 bool IsConstructor() const;
882
894 bool IsApiWrapper() const;
895
901 bool IsUndetectable() const;
902
908 Local<Value> recv,
909 int argc,
910 Local<Value> argv[]);
911
918 Local<Context> context, int argc, Local<Value> argv[]);
919
929 MaybeLocal<Array> PreviewEntries(bool* is_key_value);
930
931 static Local<Object> New(Isolate* isolate);
932
941 static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
942 Local<Name>* names, Local<Value>* values,
943 size_t length);
944
945 V8_INLINE static Object* Cast(Value* obj);
946
955 bool IsCodeLike(Isolate* isolate) const;
956
957 private:
958 static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj,
959 CppHeapPointerTagRange tag_range);
960 static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj,
961 CppHeapPointerTag tag, void* wrappable);
962
963 Object();
964 static void CheckCast(Value* obj);
965 Local<Data> SlowGetInternalField(int index);
966 void* SlowGetAlignedPointerFromInternalField(int index,
968 void* SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate, int index,
970 void* SlowGetPointerFromInternalField(v8::Isolate* isolate, int index,
972 void SetPointerInInternalFieldInternal(int index, void* value,
974};
975
976// --- Implementation ---
977
978Local<Data> Object::GetInternalField(int index) {
979#ifndef V8_ENABLE_CHECKS
980 using A = internal::Address;
981 using I = internal::Internals;
982 A obj = internal::ValueHelper::ValueAsAddress(this);
983 // Fast path: If the object is a plain JSObject, which is the common case, we
984 // know where to find the internal fields and can return the value directly.
985 int instance_type = I::GetInstanceType(obj);
986 if (I::CanHaveInternalField(instance_type)) {
987 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
988 (I::kEmbedderDataSlotSize * index);
989#ifdef V8_COMPRESS_POINTERS
990 // The tagged payload lives in the low kTaggedSize half of the slot (at
991 // kTaggedPayloadOffset == 0). Read it as a 32-bit field so the correct half
992 // is picked on both little and big endian targets. A full width read plus
993 // truncation would return the CppHeap pointer half on big endian.
994 uint32_t compressed = I::ReadRawField<uint32_t>(obj, offset);
995 A value = I::DecompressTaggedField(obj, compressed);
996#else
997 A value = I::ReadRawField<A>(obj, offset);
998#endif
999
1000 auto* isolate = I::GetCurrentIsolate();
1001 return Local<Data>::New(isolate, value);
1002 }
1003#endif
1004 return SlowGetInternalField(index);
1005}
1006
1007void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate,
1008 int index,
1009 EmbedderDataTypeTag tag) {
1010 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
1011}
1012
1013void* Object::GetAlignedPointerFromInternalField(int index,
1014 EmbedderDataTypeTag tag) {
1015 return SlowGetAlignedPointerFromInternalField(index, tag);
1016}
1017
1018template <typename T>
1019 requires cppgc::IsGarbageCollectedTypeV<T>
1020T* Object::GetPointerFromInternalField(v8::Isolate* isolate, int index,
1021 CppHeapPointerTag tag) {
1022#if !defined(V8_ENABLE_CHECKS)
1023 using A = internal::Address;
1024 using I = internal::Internals;
1025 A obj = internal::ValueHelper::ValueAsAddress(this);
1026 // Fast path: If the object is a plain JSObject, which is the common case, we
1027 // know where to find the internal fields and can return the value directly.
1028 auto instance_type = I::GetInstanceType(obj);
1029 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
1030 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
1031 (I::kEmbedderDataSlotSize * index) +
1032 I::kEmbedderDataSlotCppHeapPointerOffset;
1033 return internal::ReadCppHeapPointerField<T>(
1034 isolate, obj, offset, CppHeapPointerTagRange(tag, tag));
1035 }
1036#endif
1037 return static_cast<T*>(SlowGetPointerFromInternalField(isolate, index, tag));
1038}
1039
1040// static
1041template <CppHeapPointerTag tag, typename T>
1042T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper) {
1043 CppHeapPointerTagRange tag_range(tag, tag);
1044 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1045#if !defined(V8_ENABLE_CHECKS)
1046 return internal::ReadCppHeapPointerField<T>(
1047 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1048#else // defined(V8_ENABLE_CHECKS)
1049 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1050#endif // defined(V8_ENABLE_CHECKS)
1051}
1052
1053// static
1054template <CppHeapPointerTag tag, typename T>
1055T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper) {
1056 CppHeapPointerTagRange tag_range(tag, tag);
1057 auto obj =
1058 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1059#if !defined(V8_ENABLE_CHECKS)
1060 return internal::ReadCppHeapPointerField<T>(
1061 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1062#else // defined(V8_ENABLE_CHECKS)
1063 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1064#endif // defined(V8_ENABLE_CHECKS)
1065}
1066
1067// static
1068template <CppHeapPointerTag tag, typename T>
1069T* Object::Unwrap(v8::Isolate* isolate,
1070 const BasicTracedReference<Object>& wrapper) {
1071 CppHeapPointerTagRange tag_range(tag, tag);
1072 auto obj =
1073 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1074#if !defined(V8_ENABLE_CHECKS)
1075 return internal::ReadCppHeapPointerField<T>(
1076 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1077#else // defined(V8_ENABLE_CHECKS)
1078 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1079#endif // defined(V8_ENABLE_CHECKS)
1080}
1081
1082// static
1083template <typename T>
1084T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1085 CppHeapPointerTagRange tag_range) {
1086 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1087#if !defined(V8_ENABLE_CHECKS)
1088 return internal::ReadCppHeapPointerField<T>(
1089 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1090#else // defined(V8_ENABLE_CHECKS)
1091 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1092#endif // defined(V8_ENABLE_CHECKS)
1093}
1094
1095// static
1096template <typename T>
1097T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<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
1106 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1107#endif // defined(V8_ENABLE_CHECKS)
1108}
1109
1110// static
1111template <typename T>
1112T* Object::Unwrap(v8::Isolate* isolate,
1113 const BasicTracedReference<Object>& wrapper,
1114 CppHeapPointerTagRange tag_range) {
1115 auto obj =
1116 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1117#if !defined(V8_ENABLE_CHECKS)
1118 return internal::ReadCppHeapPointerField<T>(
1119 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1120#else // defined(V8_ENABLE_CHECKS)
1121 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1122#endif // defined(V8_ENABLE_CHECKS)
1123}
1124
1125// static
1126template <CppHeapPointerTag tag>
1127void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1128 v8::Object::Wrappable* wrappable) {
1129 static_assert(kObjectWrappableTagRange.Contains(tag),
1130 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1131 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1132 Wrap(isolate, obj, tag, wrappable);
1133}
1134
1135// static
1136template <CppHeapPointerTag tag>
1137void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1138 v8::Object::Wrappable* wrappable) {
1139 static_assert(kObjectWrappableTagRange.Contains(tag),
1140 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1141 auto obj =
1142 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1143 Wrap(isolate, obj, tag, wrappable);
1144}
1145
1146// static
1147template <CppHeapPointerTag tag>
1148void Object::Wrap(v8::Isolate* isolate,
1149 const BasicTracedReference<Object>& wrapper,
1150 v8::Object::Wrappable* wrappable) {
1151 static_assert(kObjectWrappableTagRange.Contains(tag),
1152 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1153 auto obj =
1154 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1155 Wrap(isolate, obj, tag, wrappable);
1156}
1157
1158// static
1159void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1160 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1161 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1162 Wrap(isolate, obj, tag, wrappable);
1163}
1164
1165// static
1166void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1167 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1168 auto obj =
1169 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1170 Wrap(isolate, obj, tag, wrappable);
1171}
1172
1173// static
1174void Object::Wrap(v8::Isolate* isolate,
1175 const BasicTracedReference<Object>& wrapper,
1176 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1177 auto obj =
1178 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1179 Wrap(isolate, obj, tag, wrappable);
1180}
1181
1182Private* Private::Cast(Data* data) {
1183#ifdef V8_ENABLE_CHECKS
1184 CheckCast(data);
1185#endif
1186 return reinterpret_cast<Private*>(data);
1187}
1188
1189Object* Object::Cast(v8::Value* value) {
1190#ifdef V8_ENABLE_CHECKS
1191 CheckCast(value);
1192#endif
1193 return static_cast<Object*>(value);
1194}
1195
1196} // namespace v8
1197
1198#endif // INCLUDE_V8_OBJECT_H_
Definition: garbage-collected.h:53
Definition: name-provider.h:26
Definition: visitor.h:78
Definition: v8-container.h:25
Definition: v8-traced-handle.h:125
Definition: v8-context.h:55
Definition: v8-data.h:18
Definition: v8-isolate.h:299
Definition: v8-local-handle.h:356
Definition: v8-local-handle.h:724
Definition: v8-maybe.h:39
Definition: v8-primitive.h:82
Definition: v8-object.h:644
const char * GetHumanReadableName() const override
Definition: v8-object.h:650
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:646
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:652
Definition: v8-object.h:269
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 T * GetPointerFromInternalField(v8::Isolate *isolate, const BasicTracedReference< Object > &object, int index, CppHeapPointerTag tag)
Definition: v8-object.h:606
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)
MaybeLocal< Value > TryGetWithNoSideEffects(Local< Context > context, Local< Name > key)
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:582
static T * GetPointerFromInternalField(v8::Isolate *isolate, const PersistentBase< Object > &object, int index, CppHeapPointerTag tag)
Definition: v8-object.h:590
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:534
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:540
Maybe< bool > Has(Local< Context > context, Local< Value > key)
void SetAlignedPointerInInternalField(int index, void *value, EmbedderDataTypeTag tag)
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
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:598
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< Data > data=Local< Data >(), 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)
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
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Data > data=Local< Data >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
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)
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)
int GetIdentityHash()
MaybeLocal< Context > GetCreationContext(v8::Isolate *isolate)
void SetInternalField(int index, Local< Data > data)
void SetPointerInInternalField(int index, T *value, CppHeapPointerTag tag)
Definition: v8-object.h:628
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)
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)
bool HasIndexedLookupInterceptor() const
Definition: v8-persistent-handle.h:93
Definition: v8-object.h:49
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:231
Definition: v8-object.h:109
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:145
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:965
ExternalPointerTag
Definition: v8-internal.h:685
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:264
PropertyAttribute
Definition: v8-object.h:157
@ DontEnum
Definition: v8-object.h:163
@ None
Definition: v8-object.h:159
@ DontDelete
Definition: v8-object.h:165
@ ReadOnly
Definition: v8-object.h:161
internal::ExternalPointerTag ToExternalPointerTag(v8::EmbedderDataTypeTag api_tag)
KeyCollectionMode
Definition: v8-object.h:247
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:183
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallback
Definition: v8-object.h:206
SideEffectType
Definition: v8-object.h:234
AccessorNameSetterCallback AccessorNameSetterCallbackV2
Definition: v8-object.h:210
IndexFilter
Definition: v8-object.h:253
KeyConversionMode
Definition: v8-object.h:259
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:39
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:37
constexpr CppHeapPointerTagRange kObjectWrappableTagRange(CppHeapPointerTag::kFirstObjectWrappableTag, CppHeapPointerTag::kLastObjectWrappableTag)
PropertyFilter
Definition: v8-object.h:215
@ ONLY_CONFIGURABLE
Definition: v8-object.h:219
@ SKIP_SYMBOLS
Definition: v8-object.h:221
@ ONLY_WRITABLE
Definition: v8-object.h:217
@ ALL_PROPERTIES
Definition: v8-object.h:216
@ SKIP_STRINGS
Definition: v8-object.h:220
@ ONLY_ENUMERABLE
Definition: v8-object.h:218
Definition: v8-object.h:634
const int16_t type_id
Definition: v8-object.h:635
Definition: v8-internal.h:536
constexpr bool Contains(Tag tag) const
Definition: v8-internal.h:571
#define V8_EXPORT
Definition: v8config.h:875
#define V8_INLINE
Definition: v8config.h:519
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:632
#define V8_LIKELY(condition)
Definition: v8config.h:679
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:689