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
217 SKIP_SYMBOLS = 16
219
230enum class SideEffectType {
234};
235
244
250
256
261
265class V8_EXPORT Object : public Value {
266 public:
272 Local<Value> key, Local<Value> value);
274 Local<Value> key, Local<Value> value,
275 MaybeLocal<Object> receiver);
276
278 Local<Value> value);
279
291 Local<Name> key,
292 Local<Value> value);
294 uint32_t index,
295 Local<Value> value);
296
307 Local<Context> context, Local<Name> key, Local<Value> value,
308 PropertyAttribute attributes = None);
309
327 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
328
330 Local<Value> key);
332 Local<Value> key,
333 MaybeLocal<Object> receiver);
334
336 uint32_t index);
337
353 Local<Context> context, Local<Name> key);
354
365 Local<Context> context, Local<Value> key);
375 Local<Context> context, Local<Value> key,
376 PropertyAttribute* out_attributes);
377
383 Local<Context> context, Local<Name> key);
384
401 Local<Value> key);
402
404 Local<Value> key);
405
407
409 uint32_t index);
410
417 PropertyAttribute attributes = None);
418
424 Local<Context> context, Local<Name> name,
426 AccessorNameSetterCallbackV2 setter = nullptr,
427 Local<Data> data = Local<Data>(), PropertyAttribute attributes = None,
428 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
429 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
430
440 Local<Context> context, Local<Name> name,
442 PropertyAttribute attributes = None,
443 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
444 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
445
454 Local<Value> value);
457
465 Local<Context> context);
467 Local<Context> context, KeyCollectionMode mode,
468 PropertyFilter property_filter, IndexFilter index_filter,
469 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
470
477 Local<Context> context);
478
486 Local<Context> context, PropertyFilter filter,
487 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
488
494
500 Local<Value> prototype);
501
507
514 Local<Context> context);
515
520
525
528
531 const PersistentBase<Object>& object) {
532 return object.template value<Object>()->InternalFieldCount();
533 }
534
537 const BasicTracedReference<Object>& object) {
538 return object.template value<Object>()->InternalFieldCount();
539 }
540
551 V8_INLINE Local<Data> GetInternalField(int index);
552
554 void SetInternalField(int index, Local<Data> data);
555
561 V8_INLINE void* GetAlignedPointerFromInternalField(int index,
563 V8_INLINE void* GetAlignedPointerFromInternalField(v8::Isolate* isolate,
564 int index,
566
572 template <typename T>
573 requires cppgc::IsGarbageCollectedTypeV<T>
574 V8_INLINE T* GetPointerFromInternalField(v8::Isolate* isolate, int index,
576
579 const PersistentBase<Object>& object, int index,
581 return object.template value<Object>()->GetAlignedPointerFromInternalField(
582 index, tag);
583 }
584 template <typename T>
585 requires cppgc::IsGarbageCollectedTypeV<T>
587 v8::Isolate* isolate, const PersistentBase<Object>& object, int index,
588 CppHeapPointerTag tag) {
589 return object.template value<Object>()->GetPointerFromInternalField<T>(
590 isolate, index, tag);
591 }
592
595 const BasicTracedReference<Object>& object, int index,
597 return object.template value<Object>()->GetAlignedPointerFromInternalField(
598 index, tag);
599 }
600 template <typename T>
601 requires cppgc::IsGarbageCollectedTypeV<T>
603 v8::Isolate* isolate, const BasicTracedReference<Object>& object,
604 int index, CppHeapPointerTag tag) {
605 return object.template value<Object>()->GetPointerFromInternalField<T>(
606 isolate, index, tag);
607 }
608
614 void SetAlignedPointerInInternalField(int index, void* value,
616
622 template <typename T>
623 requires(!std::is_void_v<T>) && cppgc::IsGarbageCollectedTypeV<T>
624 void SetPointerInInternalField(int index, T* value, CppHeapPointerTag tag) {
625 SetPointerInInternalFieldInternal(index, static_cast<void*>(value), tag);
626 }
627
628 // Type information for a Wrappable object that got wrapped with
629 // `v8::Object::Wrap()`.
631 const int16_t type_id;
632 };
633
634 // v8::Object::Wrappable serves as the base class for all C++ objects that can
635 // be wrapped by a JavaScript object using `v8::Object::Wrap()`.
636 //
637 // Note that v8::Object::Wrappable` inherits from `NameProvider` and provides
638 // `GetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
639 class Wrappable : public cppgc::GarbageCollected<Wrappable>,
640 public cppgc::NameProvider {
641 public:
642 virtual const WrapperTypeInfo* GetWrapperTypeInfo() const {
643 return nullptr;
644 }
645
646 const char* GetHumanReadableName() const override { return "internal"; }
647
648 virtual void Trace(cppgc::Visitor* visitor) const {}
649 };
650
661 template <CppHeapPointerTag tag, typename T = void>
662 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
663 const v8::Local<v8::Object>& wrapper);
664 template <CppHeapPointerTag tag, typename T = void>
665 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
666 const PersistentBase<Object>& wrapper);
667 template <CppHeapPointerTag tag, typename T = void>
668 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
669 const BasicTracedReference<Object>& wrapper);
670
671 template <typename T = void>
672 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
673 const v8::Local<v8::Object>& wrapper,
674 CppHeapPointerTagRange tag_range);
675 template <typename T = void>
676 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
677 const PersistentBase<Object>& wrapper,
678 CppHeapPointerTagRange tag_range);
679 template <typename T = void>
680 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
681 const BasicTracedReference<Object>& wrapper,
682 CppHeapPointerTagRange tag_range);
683
693 template <CppHeapPointerTag tag>
694 static V8_INLINE void Wrap(v8::Isolate* isolate,
695 const v8::Local<v8::Object>& wrapper,
696 Wrappable* wrappable);
697 template <CppHeapPointerTag tag>
698 static V8_INLINE void Wrap(v8::Isolate* isolate,
699 const PersistentBase<Object>& wrapper,
700 Wrappable* wrappable);
701 template <CppHeapPointerTag tag>
702 static V8_INLINE void Wrap(v8::Isolate* isolate,
703 const BasicTracedReference<Object>& wrapper,
704 Wrappable* wrappable);
705 static V8_INLINE void Wrap(v8::Isolate* isolate,
706 const v8::Local<v8::Object>& wrapper,
707 Wrappable* wrappable, CppHeapPointerTag tag);
708 static V8_INLINE void Wrap(v8::Isolate* isolate,
709 const PersistentBase<Object>& wrapper,
710 Wrappable* wrappable, CppHeapPointerTag tag);
711 static V8_INLINE void Wrap(v8::Isolate* isolate,
712 const BasicTracedReference<Object>& wrapper,
713 Wrappable* wrappable, CppHeapPointerTag tag);
714
715 // Version of Wrap() function for v8::Context::Global() objects.
716 // Unlike the functions above it wraps both JSGlobalProxy and its hidden
717 // prototype (JSGlobalObject or remote object).
718 static void WrapGlobal(v8::Isolate* isolate,
719 const v8::Local<v8::Object>& wrapper,
720 Wrappable* wrappable, CppHeapPointerTag tag);
721
722 // Checks that wrappables set on JSGlobalProxy and its hidden prototype are
723 // the same.
724 static bool CheckGlobalWrappable(v8::Isolate* isolate,
725 const v8::Local<v8::Object>& wrapper,
726 CppHeapPointerTagRange tag_range);
727
735 Local<Name> key);
737 uint32_t index);
752 Local<Name> key);
754 Local<Context> context, uint32_t index);
756 Local<Context> context, Local<Name> key);
757
763 Local<Context> context, Local<Name> key);
764
772 Local<Name> key);
773
780 Local<Context> context, Local<Name> key);
781
788 Local<Context> context, Local<Name> key);
789
792
795
804
813
820 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
821 MaybeLocal<Context> GetCreationContext();
822
828 Local<Context> GetCreationContextChecked(v8::Isolate* isolate);
829 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
830 Local<Context> GetCreationContextChecked();
831
833 V8_INLINE static MaybeLocal<Context> GetCreationContext(
834 v8::Isolate* isolate, const PersistentBase<Object>& object) {
835 return object.template value<Object>()->GetCreationContext(isolate);
836 }
837 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
838 V8_INLINE static MaybeLocal<Context> GetCreationContext(
839 const PersistentBase<Object>& object);
840
860 void* GetAlignedPointerFromEmbedderDataInCreationContext(
861 v8::Isolate* isolate, int index, EmbedderDataTypeTag tag);
862 void* GetAlignedPointerFromEmbedderDataInCreationContext(
863 int index, EmbedderDataTypeTag tag);
864
865 void* GetAlignedPointerFromEmbedderDataInCreationContext(
866 v8::Isolate* isolate, int index, CppHeapPointerTag tag);
872 bool IsCallable() const;
873
877 bool IsConstructor() const;
878
890 bool IsApiWrapper() const;
891
897 bool IsUndetectable() const;
898
904 Local<Value> recv,
905 int argc,
906 Local<Value> argv[]);
907
914 Local<Context> context, int argc, Local<Value> argv[]);
915
925 MaybeLocal<Array> PreviewEntries(bool* is_key_value);
926
927 static Local<Object> New(Isolate* isolate);
928
937 static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
938 Local<Name>* names, Local<Value>* values,
939 size_t length);
940
941 V8_INLINE static Object* Cast(Value* obj);
942
951 bool IsCodeLike(Isolate* isolate) const;
952
953 private:
954 static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj,
955 CppHeapPointerTagRange tag_range);
956 static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj,
957 CppHeapPointerTag tag, void* wrappable);
958
959 Object();
960 static void CheckCast(Value* obj);
961 Local<Data> SlowGetInternalField(int index);
962 void* SlowGetAlignedPointerFromInternalField(int index,
964 void* SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate, int index,
966 void* SlowGetPointerFromInternalField(v8::Isolate* isolate, int index,
968 void SetPointerInInternalFieldInternal(int index, void* value,
970};
971
972// --- Implementation ---
973
974Local<Data> Object::GetInternalField(int index) {
975#ifndef V8_ENABLE_CHECKS
976 using A = internal::Address;
977 using I = internal::Internals;
978 A obj = internal::ValueHelper::ValueAsAddress(this);
979 // Fast path: If the object is a plain JSObject, which is the common case, we
980 // know where to find the internal fields and can return the value directly.
981 int instance_type = I::GetInstanceType(obj);
982 if (I::CanHaveInternalField(instance_type)) {
983 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
984 (I::kEmbedderDataSlotSize * index);
985#ifdef V8_COMPRESS_POINTERS
986 // The tagged payload lives in the low kTaggedSize half of the slot (at
987 // kTaggedPayloadOffset == 0). Read it as a 32-bit field so the correct half
988 // is picked on both little and big endian targets. A full width read plus
989 // truncation would return the CppHeap pointer half on big endian.
990 uint32_t compressed = I::ReadRawField<uint32_t>(obj, offset);
991 A value = I::DecompressTaggedField(obj, compressed);
992#else
993 A value = I::ReadRawField<A>(obj, offset);
994#endif
995
996 auto* isolate = I::GetCurrentIsolate();
997 return Local<Data>::New(isolate, value);
998 }
999#endif
1000 return SlowGetInternalField(index);
1001}
1002
1003void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate,
1004 int index,
1005 EmbedderDataTypeTag tag) {
1006 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
1007}
1008
1009void* Object::GetAlignedPointerFromInternalField(int index,
1010 EmbedderDataTypeTag tag) {
1011 return SlowGetAlignedPointerFromInternalField(index, tag);
1012}
1013
1014template <typename T>
1015 requires cppgc::IsGarbageCollectedTypeV<T>
1016T* Object::GetPointerFromInternalField(v8::Isolate* isolate, int index,
1017 CppHeapPointerTag tag) {
1018#if !defined(V8_ENABLE_CHECKS)
1019 using A = internal::Address;
1020 using I = internal::Internals;
1021 A obj = internal::ValueHelper::ValueAsAddress(this);
1022 // Fast path: If the object is a plain JSObject, which is the common case, we
1023 // know where to find the internal fields and can return the value directly.
1024 auto instance_type = I::GetInstanceType(obj);
1025 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
1026 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
1027 (I::kEmbedderDataSlotSize * index) +
1028 I::kEmbedderDataSlotCppHeapPointerOffset;
1029 return internal::ReadCppHeapPointerField<T>(
1030 isolate, obj, offset, CppHeapPointerTagRange(tag, tag));
1031 }
1032#endif
1033 return static_cast<T*>(SlowGetPointerFromInternalField(isolate, index, tag));
1034}
1035
1036// static
1037template <CppHeapPointerTag tag, typename T>
1038T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper) {
1039 CppHeapPointerTagRange tag_range(tag, tag);
1040 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1041#if !defined(V8_ENABLE_CHECKS)
1042 return internal::ReadCppHeapPointerField<T>(
1043 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1044#else // defined(V8_ENABLE_CHECKS)
1045 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1046#endif // defined(V8_ENABLE_CHECKS)
1047}
1048
1049// static
1050template <CppHeapPointerTag tag, typename T>
1051T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper) {
1052 CppHeapPointerTagRange tag_range(tag, tag);
1053 auto obj =
1054 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1055#if !defined(V8_ENABLE_CHECKS)
1056 return internal::ReadCppHeapPointerField<T>(
1057 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1058#else // defined(V8_ENABLE_CHECKS)
1059 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1060#endif // defined(V8_ENABLE_CHECKS)
1061}
1062
1063// static
1064template <CppHeapPointerTag tag, typename T>
1065T* Object::Unwrap(v8::Isolate* isolate,
1066 const BasicTracedReference<Object>& wrapper) {
1067 CppHeapPointerTagRange tag_range(tag, tag);
1068 auto obj =
1069 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1070#if !defined(V8_ENABLE_CHECKS)
1071 return internal::ReadCppHeapPointerField<T>(
1072 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1073#else // defined(V8_ENABLE_CHECKS)
1074 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1075#endif // defined(V8_ENABLE_CHECKS)
1076}
1077
1078// static
1079template <typename T>
1080T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1081 CppHeapPointerTagRange tag_range) {
1082 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1083#if !defined(V8_ENABLE_CHECKS)
1084 return internal::ReadCppHeapPointerField<T>(
1085 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1086#else // defined(V8_ENABLE_CHECKS)
1087 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1088#endif // defined(V8_ENABLE_CHECKS)
1089}
1090
1091// static
1092template <typename T>
1093T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1094 CppHeapPointerTagRange tag_range) {
1095 auto obj =
1096 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1097#if !defined(V8_ENABLE_CHECKS)
1098 return internal::ReadCppHeapPointerField<T>(
1099 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1100#else // defined(V8_ENABLE_CHECKS)
1101
1102 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1103#endif // defined(V8_ENABLE_CHECKS)
1104}
1105
1106// static
1107template <typename T>
1108T* Object::Unwrap(v8::Isolate* isolate,
1109 const BasicTracedReference<Object>& wrapper,
1110 CppHeapPointerTagRange tag_range) {
1111 auto obj =
1112 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1113#if !defined(V8_ENABLE_CHECKS)
1114 return internal::ReadCppHeapPointerField<T>(
1115 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1116#else // defined(V8_ENABLE_CHECKS)
1117 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1118#endif // defined(V8_ENABLE_CHECKS)
1119}
1120
1121// static
1122template <CppHeapPointerTag tag>
1123void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1124 v8::Object::Wrappable* wrappable) {
1125 static_assert(kObjectWrappableTagRange.Contains(tag),
1126 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1127 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1128 Wrap(isolate, obj, tag, wrappable);
1129}
1130
1131// static
1132template <CppHeapPointerTag tag>
1133void Object::Wrap(v8::Isolate* isolate, const PersistentBase<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
1143template <CppHeapPointerTag tag>
1144void Object::Wrap(v8::Isolate* isolate,
1145 const BasicTracedReference<Object>& wrapper,
1146 v8::Object::Wrappable* wrappable) {
1147 static_assert(kObjectWrappableTagRange.Contains(tag),
1148 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1149 auto obj =
1150 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1151 Wrap(isolate, obj, tag, wrappable);
1152}
1153
1154// static
1155void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1156 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1157 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1158 Wrap(isolate, obj, tag, wrappable);
1159}
1160
1161// static
1162void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1163 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1164 auto obj =
1165 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1166 Wrap(isolate, obj, tag, wrappable);
1167}
1168
1169// static
1170void Object::Wrap(v8::Isolate* isolate,
1171 const BasicTracedReference<Object>& wrapper,
1172 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1173 auto obj =
1174 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1175 Wrap(isolate, obj, tag, wrappable);
1176}
1177
1178Private* Private::Cast(Data* data) {
1179#ifdef V8_ENABLE_CHECKS
1180 CheckCast(data);
1181#endif
1182 return reinterpret_cast<Private*>(data);
1183}
1184
1185Object* Object::Cast(v8::Value* value) {
1186#ifdef V8_ENABLE_CHECKS
1187 CheckCast(value);
1188#endif
1189 return static_cast<Object*>(value);
1190}
1191
1192} // namespace v8
1193
1194#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:305
Definition: v8-local-handle.h:359
Definition: v8-local-handle.h:730
Definition: v8-maybe.h:39
Definition: v8-primitive.h:83
Definition: v8-object.h:640
const char * GetHumanReadableName() const override
Definition: v8-object.h:646
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:642
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:648
Definition: v8-object.h:265
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:602
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:578
static T * GetPointerFromInternalField(v8::Isolate *isolate, const PersistentBase< Object > &object, int index, CppHeapPointerTag tag)
Definition: v8-object.h:586
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:530
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:536
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:594
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< 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:624
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)
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallbackV2 setter=nullptr, Local< Data > data=Local< Data >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
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:229
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:969
ExternalPointerTag
Definition: v8-internal.h:685
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:260
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:243
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:183
SideEffectType
Definition: v8-object.h:230
IndexFilter
Definition: v8-object.h:249
KeyConversionMode
Definition: v8-object.h:255
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:39
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallbackV2
Definition: v8-object.h:206
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:37
constexpr CppHeapPointerTagRange kObjectWrappableTagRange(CppHeapPointerTag::kFirstObjectWrappableTag, CppHeapPointerTag::kLastObjectWrappableTag)
PropertyFilter
Definition: v8-object.h:211
@ ONLY_CONFIGURABLE
Definition: v8-object.h:215
@ SKIP_SYMBOLS
Definition: v8-object.h:217
@ ONLY_WRITABLE
Definition: v8-object.h:213
@ ALL_PROPERTIES
Definition: v8-object.h:212
@ SKIP_STRINGS
Definition: v8-object.h:216
@ ONLY_ENUMERABLE
Definition: v8-object.h:214
Definition: v8-object.h:630
const int16_t type_id
Definition: v8-object.h:631
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