5#ifndef INCLUDE_V8_INTERNAL_H_
6#define INCLUDE_V8_INTERNAL_H_
23#if __has_include(<version>)
26#if defined(__cpp_lib_three_way_comparison) && \
27 __cpp_lib_three_way_comparison >= 201711L && \
28 defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L
32#define V8_HAVE_SPACESHIP_OPERATOR 1
34#define V8_HAVE_SPACESHIP_OPERATOR 0
52static constexpr Address kNullAddress = 0;
54constexpr int KB = 1024;
55constexpr int MB =
KB * 1024;
56constexpr int GB =
MB * 1024;
57#ifdef V8_TARGET_ARCH_X64
58constexpr size_t TB =
size_t{
GB} * 1024;
89template <
size_t tagged_ptr_size>
108 return static_cast<int32_t
>(
static_cast<uint32_t
>(value)) >> shift_bits;
111 template <
class T,
typename std::enable_if_t<std::is_
integral_v<T> &&
112 std::is_
signed_v<T>>* =
nullptr>
117 return (
static_cast<uintptr_t
>(value) -
124 typename std::enable_if_t<std::is_integral_v<T> &&
125 std::is_unsigned_v<T>>* =
nullptr>
127 static_assert(kSmiMaxValue <= std::numeric_limits<uintptr_t>::max());
134 return (
static_cast<uint64_t
>(value) -
141 static_assert(kSmiMaxValue <= std::numeric_limits<uint64_t>::max());
158 return static_cast<int>(
static_cast<intptr_t
>(value) >> shift_bits);
161 template <
class T,
typename std::enable_if_t<std::is_
integral_v<T> &&
162 std::is_
signed_v<T>>* =
nullptr>
165 return std::numeric_limits<int32_t>::min() <= value &&
166 value <= std::numeric_limits<int32_t>::max();
170 typename std::enable_if_t<std::is_integral_v<T> &&
171 std::is_unsigned_v<T>>* =
nullptr>
173 return value <= std::numeric_limits<int32_t>::max();
177#ifdef V8_COMPRESS_POINTERS
180constexpr size_t kPtrComprCageReservationSize =
size_t{1} << 32;
181constexpr size_t kPtrComprCageBaseAlignment =
size_t{1} << 32;
185 "Pointer compression can be enabled only for 64-bit architectures");
195#ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
205const int kSmiMinValue =
static_cast<int>(PlatformSmiTagging::kSmiMinValue);
206const int kSmiMaxValue =
static_cast<int>(PlatformSmiTagging::kSmiMaxValue);
220#ifdef V8_ENABLE_SANDBOX
231#ifdef V8_ENABLE_SANDBOX
234#if defined(V8_TARGET_OS_ANDROID)
238constexpr size_t kSandboxSizeLog2 = 37;
241constexpr size_t kSandboxSizeLog2 = 40;
243constexpr size_t kSandboxSize = 1ULL << kSandboxSizeLog2;
250constexpr size_t kSandboxAlignment = kPtrComprCageBaseAlignment;
256constexpr uint64_t kSandboxedPointerShift = 64 - kSandboxSizeLog2;
261constexpr size_t kSandboxGuardRegionSize = 32ULL *
GB;
263static_assert((kSandboxGuardRegionSize % kSandboxAlignment) == 0,
264 "The size of the guard regions around the sandbox must be a "
265 "multiple of its required alignment.");
277constexpr size_t kSandboxMinimumReservationSize = 8ULL *
GB;
279static_assert(kSandboxMinimumReservationSize > kPtrComprCageReservationSize,
280 "The minimum reservation size for a sandbox must be larger than "
281 "the pointer compression cage contained within it.");
287constexpr size_t kMaxSafeBufferSizeForSandbox = 32ULL *
GB - 1;
288static_assert(kMaxSafeBufferSizeForSandbox <= kSandboxGuardRegionSize,
289 "The maximum allowed buffer size must not be larger than the "
290 "sandbox's guard regions");
292constexpr size_t kBoundedSizeShift = 29;
293static_assert(1ULL << (64 - kBoundedSizeShift) ==
294 kMaxSafeBufferSizeForSandbox + 1,
295 "The maximum size of a BoundedSize must be synchronized with the "
296 "kMaxSafeBufferSizeForSandbox");
300#ifdef V8_COMPRESS_POINTERS
302#ifdef V8_TARGET_OS_ANDROID
308constexpr size_t kExternalPointerTableReservationSize = 256 *
MB;
314constexpr uint32_t kExternalPointerIndexShift = 7;
316constexpr size_t kExternalPointerTableReservationSize = 512 *
MB;
317constexpr uint32_t kExternalPointerIndexShift = 6;
321constexpr int kExternalPointerTableEntrySize = 8;
322constexpr int kExternalPointerTableEntrySizeLog2 = 3;
324 kExternalPointerTableReservationSize / kExternalPointerTableEntrySize;
326 "kExternalPointerTableReservationSize and "
327 "kExternalPointerIndexShift don't match");
348#ifdef V8_ENABLE_SANDBOX
368#ifdef V8_COMPRESS_POINTERS
381#ifdef V8_COMPRESS_POINTERS
385constexpr size_t kCppHeapPointerTableReservationSize =
386 kExternalPointerTableReservationSize;
387constexpr uint32_t kCppHeapPointerIndexShift = kExternalPointerIndexShift;
389constexpr int kCppHeapPointerTableEntrySize = 8;
390constexpr int kCppHeapPointerTableEntrySizeLog2 = 3;
392 kCppHeapPointerTableReservationSize / kCppHeapPointerTableEntrySize;
394 "kCppHeapPointerTableReservationSize and "
395 "kCppHeapPointerIndexShift don't match");
413#ifdef V8_ENABLE_SANDBOX
419#ifdef V8_TARGET_OS_ANDROID
443 "kExternalBufferTableReservationSize and "
444 "kExternalBufferHandleShift don't match");
526 0b00001111, 0b00010111, 0b00011011, 0b00011101, 0b00011110, 0b00100111,
527 0b00101011, 0b00101101, 0b00101110, 0b00110011, 0b00110101, 0b00110110,
528 0b00111001, 0b00111010, 0b00111100, 0b01000111, 0b01001011, 0b01001101,
529 0b01001110, 0b01010011, 0b01010101, 0b01010110, 0b01011001, 0b01011010,
530 0b01011100, 0b01100011, 0b01100101, 0b01100110, 0b01101001, 0b01101010,
531 0b01101100, 0b01110001, 0b01110010, 0b01110100, 0b01111000, 0b10000111,
532 0b10001011, 0b10001101, 0b10001110, 0b10010011, 0b10010101, 0b10010110,
533 0b10011001, 0b10011010, 0b10011100, 0b10100011, 0b10100101, 0b10100110,
534 0b10101001, 0b10101010, 0b10101100, 0b10110001, 0b10110010, 0b10110100,
535 0b10111000, 0b11000011, 0b11000101, 0b11000110, 0b11001001, 0b11001010,
536 0b11001100, 0b11010001, 0b11010010, 0b11010100, 0b11011000, 0b11100001,
537 0b11100010, 0b11100100, 0b11101000, 0b11110000};
540 ((kAllTagsForAndBasedTypeChecking[i] << kExternalPointerTagShift) | \
541 kExternalPointerMarkBit)
553#define SHARED_EXTERNAL_POINTER_TAGS(V) \
554 V(kFirstSharedTag, TAG(0)) \
555 V(kWaiterQueueNodeTag, TAG(0)) \
556 V(kExternalStringResourceTag, TAG(1)) \
557 V(kExternalStringResourceDataTag, TAG(2)) \
558 V(kLastSharedTag, TAG(2))
563#define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V) \
564 V(kNativeContextMicrotaskQueueTag, TAG(5)) \
565 V(kEmbedderDataSlotPayloadTag, TAG(6)) \
569 V(kExternalObjectValueTag, TAG(7)) \
570 V(kFunctionTemplateInfoCallbackTag, TAG(8)) \
571 V(kAccessorInfoGetterTag, TAG(9)) \
572 V(kAccessorInfoSetterTag, TAG(10)) \
573 V(kWasmInternalFunctionCallTargetTag, TAG(11)) \
574 V(kWasmTypeInfoNativeTypeTag, TAG(12)) \
575 V(kWasmExportedFunctionDataSignatureTag, TAG(13)) \
576 V(kWasmContinuationJmpbufTag, TAG(14)) \
577 V(kWasmStackMemoryTag, TAG(15)) \
578 V(kWasmIndirectFunctionTargetTag, TAG(16)) \
580 V(kGenericForeignTag, TAG(20)) \
581 V(kApiNamedPropertyQueryCallbackTag, TAG(21)) \
582 V(kApiNamedPropertyGetterCallbackTag, TAG(22)) \
583 V(kApiNamedPropertySetterCallbackTag, TAG(23)) \
584 V(kApiNamedPropertyDescriptorCallbackTag, TAG(24)) \
585 V(kApiNamedPropertyDefinerCallbackTag, TAG(25)) \
586 V(kApiNamedPropertyDeleterCallbackTag, TAG(26)) \
587 V(kApiIndexedPropertyQueryCallbackTag, TAG(27)) \
588 V(kApiIndexedPropertyGetterCallbackTag, TAG(28)) \
589 V(kApiIndexedPropertySetterCallbackTag, TAG(29)) \
590 V(kApiIndexedPropertyDescriptorCallbackTag, TAG(30)) \
591 V(kApiIndexedPropertyDefinerCallbackTag, TAG(31)) \
592 V(kApiIndexedPropertyDeleterCallbackTag, TAG(32)) \
593 V(kApiIndexedPropertyEnumeratorCallbackTag, TAG(33)) \
594 V(kApiAccessCheckCallbackTag, TAG(34)) \
595 V(kApiAbortScriptExecutionCallbackTag, TAG(35)) \
596 V(kSyntheticModuleTag, TAG(36)) \
597 V(kMicrotaskCallbackTag, TAG(37)) \
598 V(kMicrotaskCallbackDataTag, TAG(38)) \
599 V(kCFunctionTag, TAG(39)) \
600 V(kCFunctionInfoTag, TAG(40)) \
601 V(kMessageListenerTag, TAG(41)) \
602 V(kWaiterQueueForeignTag, TAG(42)) \
604 V(kFirstManagedResourceTag, TAG(50)) \
605 V(kGenericManagedTag, TAG(50)) \
606 V(kWasmWasmStreamingTag, TAG(51)) \
607 V(kWasmFuncDataTag, TAG(52)) \
608 V(kWasmManagedDataTag, TAG(53)) \
609 V(kWasmNativeModuleTag, TAG(54)) \
610 V(kIcuBreakIteratorTag, TAG(55)) \
611 V(kIcuUnicodeStringTag, TAG(56)) \
612 V(kIcuListFormatterTag, TAG(57)) \
613 V(kIcuLocaleTag, TAG(58)) \
614 V(kIcuSimpleDateFormatTag, TAG(59)) \
615 V(kIcuDateIntervalFormatTag, TAG(60)) \
616 V(kIcuRelativeDateTimeFormatterTag, TAG(61)) \
617 V(kIcuLocalizedNumberFormatterTag, TAG(62)) \
618 V(kIcuPluralRulesTag, TAG(63)) \
619 V(kIcuCollatorTag, TAG(64)) \
620 V(kDisplayNamesInternalTag, TAG(65)) \
624 V(kArrayBufferExtensionTag, TAG(66)) \
625 V(kLastManagedResourceTag, TAG(66)) \
628#define ALL_EXTERNAL_POINTER_TAGS(V) \
629 SHARED_EXTERNAL_POINTER_TAGS(V) \
630 PER_ISOLATE_EXTERNAL_POINTER_TAGS(V)
632#define EXTERNAL_POINTER_TAG_ENUM(Name, Tag) Name = Tag,
633#define MAKE_TAG(HasMarkBit, TypeTag) \
634 ((static_cast<uint64_t>(TypeTag) << kExternalPointerTagShift) | \
635 (HasMarkBit ? kExternalPointerMarkBit : 0))
659#undef EXTERNAL_POINTER_TAG_ENUM
665V8_INLINE static constexpr bool IsSharedExternalPointerType(
673V8_INLINE static constexpr bool IsMaybeReadOnlyExternalPointerType(
683V8_INLINE static constexpr bool IsManagedExternalPointerType(
689#define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \
690 static_assert(IsSharedExternalPointerType(Tag));
691#define CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \
692 static_assert(!IsSharedExternalPointerType(Tag));
697#undef CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS
698#undef CHECK_SHARED_EXTERNAL_POINTER_TAGS
700#undef SHARED_EXTERNAL_POINTER_TAGS
701#undef EXTERNAL_POINTER_TAGS
761 "kTrustedPointerTableReservationSize and "
762 "kTrustedPointerHandleShift don't match");
810 "kCodePointerTableReservationSize and kCodePointerHandleShift don't match");
843 "kJSDispatchTableReservationSize and kJSDispatchEntryHandleShift "
863 return mapword ^ kMapWordXorMask;
877#ifdef V8_COMPRESS_POINTERS
887#ifdef V8_ENABLE_SANDBOX
954#ifdef V8_COMPRESS_POINTERS
955 static const int kIsolateExternalPointerTableOffset =
957 static const int kIsolateSharedExternalPointerTableAddressOffset =
959 static const int kIsolateCppHeapPointerTableOffset =
961#ifdef V8_ENABLE_SANDBOX
962 static const int kIsolateTrustedCageBaseOffset =
964 static const int kIsolateTrustedPointerTableOffset =
966 static const int kIsolateSharedTrustedPointerTableAddressOffset =
989#if V8_STATIC_ROOTS_BOOL
992#define EXPORTED_STATIC_ROOTS_PTR_LIST(V) \
993 V(UndefinedValue, 0x11) \
996 V(FalseValue, 0x55) \
997 V(EmptyString, 0x49) \
998 V(TheHoleValue, 0x739)
1000 using Tagged_t = uint32_t;
1001 struct StaticReadOnlyRoot {
1002#define DEF_ROOT(name, value) static constexpr Tagged_t k##name = value;
1003 EXPORTED_STATIC_ROOTS_PTR_LIST(DEF_ROOT)
1007 static constexpr Tagged_t kStringMapLowerBound = 0;
1008 static constexpr Tagged_t kStringMapUpperBound = 0x425;
1010#define PLUSONE(...) +1
1011 static constexpr size_t kNumberOfExportedStaticRoots =
1012 2 + EXPORTED_STATIC_ROOTS_PTR_LIST(PLUSONE);
1056#ifdef V8_MAP_PACKING
1057 static const uintptr_t kMapWordMetadataMask = 0xffffULL << 48;
1059 static const uintptr_t kMapWordSignature = 0b10;
1064 static const int kMapWordXorMask = 0b11;
1069#ifdef V8_ENABLE_CHECKS
1079 return PlatformSmiTagging::SmiToInt(value);
1091 template <
typename T,
1092 typename std::enable_if_t<std::is_integral_v<T>>* =
nullptr>
1097 template <
typename T,
1098 typename std::enable_if_t<std::is_integral_v<T>>* =
nullptr>
1100 return PlatformSmiTagging::IsValidSmi(value);
1103 template <
typename T,
1104 typename std::enable_if_t<std::is_integral_v<T>>* =
nullptr>
1106 if (
V8_LIKELY(PlatformSmiTagging::IsValidSmi(value))) {
1112#if V8_STATIC_ROOTS_BOOL
1114 return static_cast<Tagged_t
>(obj) == constant;
1117 V8_INLINE static bool CheckInstanceMapRange(
Address obj, Tagged_t first_map,
1118 Tagged_t last_map) {
1120#ifdef V8_MAP_PACKING
1121 map = UnpackMapWord(map);
1123 return map >= first_map && map <= last_map;
1129#ifdef V8_MAP_PACKING
1130 map = UnpackMapWord(map);
1138#ifdef V8_MAP_PACKING
1139 map = UnpackMapWord(map);
1160 (
static_cast<unsigned>(
static_cast<unsigned>(instance_type) -
1167 return *addr &
static_cast<uint8_t
>(1U << shift);
1172 uint8_t mask =
static_cast<uint8_t
>(1U << shift);
1173 *addr =
static_cast<uint8_t
>((*addr & ~mask) | (value << shift));
1183 *addr =
static_cast<uint8_t
>((*addr & ~kNodeStateMask) | value);
1190 *
reinterpret_cast<void**
>(addr) = data;
1197 return *
reinterpret_cast<void* const*
>(addr);
1203 ++(*
reinterpret_cast<size_t*
>(addr));
1209 return reinterpret_cast<Address*
>(addr);
1213#if V8_STATIC_ROOTS_BOOL
1217#define DECOMPRESS_ROOT(name, ...) \
1218 case k##name##RootIndex: \
1219 return base + StaticReadOnlyRoot::k##name;
1220 EXPORTED_STATIC_ROOTS_PTR_LIST(DECOMPRESS_ROOT)
1221#undef DECOMPRESS_ROOT
1222#undef EXPORTED_STATIC_ROOTS_PTR_LIST
1230#ifdef V8_ENABLE_SANDBOX
1233 kIsolateExternalPointerTableOffset +
1235 return *
reinterpret_cast<Address**
>(addr);
1241 kIsolateSharedExternalPointerTableAddressOffset;
1242 addr = *
reinterpret_cast<Address*
>(addr);
1244 return *
reinterpret_cast<Address**
>(addr);
1248 template <
typename T>
1251#ifdef V8_COMPRESS_POINTERS
1258 memcpy(&r,
reinterpret_cast<void*
>(addr),
sizeof(T));
1262 return *
reinterpret_cast<const T*
>(addr);
1267#ifdef V8_COMPRESS_POINTERS
1268 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
1269 Address base = GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
1270 return base +
static_cast<Address>(
static_cast<uintptr_t
>(value));
1272 return ReadRawField<Address>(heap_object_ptr, offset);
1278#ifdef V8_COMPRESS_POINTERS
1279 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
1280 return static_cast<Address>(
static_cast<uintptr_t
>(value));
1282 return ReadRawField<Address>(heap_object_ptr, offset);
1287#ifdef V8_ENABLE_SANDBOX
1296 template <ExternalPo
interTag tag>
1300#ifdef V8_ENABLE_SANDBOX
1304 Address* table = IsSharedExternalPointerType(tag)
1305 ? GetSharedExternalPointerTableBase(isolate)
1306 : GetExternalPointerTableBase(isolate);
1308 ReadRawField<ExternalPointerHandle>(heap_object_ptr, offset);
1309 uint32_t index = handle >> kExternalPointerIndexShift;
1310 std::atomic<Address>* ptr =
1311 reinterpret_cast<std::atomic<Address>*
>(&table[index]);
1312 Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed);
1313 return entry & ~tag;
1315 return ReadRawField<Address>(heap_object_ptr, offset);
1319#ifdef V8_COMPRESS_POINTERS
1321 return addr & -
static_cast<intptr_t
>(kPtrComprCageBaseAlignment);
1325 return static_cast<uint32_t
>(value);
1330 Address base = GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
1331 return base +
static_cast<Address>(
static_cast<uintptr_t
>(value));
1339template <
bool PerformCheck>
1357 CastCheck<std::is_base_of<Data, T>::value &&
1358 !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
1373 Heap* heap()
const {
return heap_; }
1379 return a.heap_ == b.heap_;
1390 Address* allocate_impl(
size_t n);
1391 void deallocate_impl(
Address* p,
size_t n)
noexcept;
1402template <
typename T>
1407 template <
typename HeapOrIsolateT>
1409 template <
typename U>
1412 using std::allocator<T>::allocate;
1413 using std::allocator<T>::deallocate;
1418template <
typename Iterator,
typename =
void>
1420template <
typename Iterator>
1422 Iterator, std::void_t<typename Iterator::iterator_concept>> =
true;
1424template <
typename Iterator,
typename =
void>
1426template <
typename Iterator>
1428 Iterator, std::void_t<typename Iterator::iterator_category>> =
true;
1433template <
typename Iterator,
typename =
void>
1436template <
typename Iterator>
1438 Iterator, std::enable_if_t<kHaveIteratorConcept<Iterator>>> {
1439 using iterator_concept =
typename Iterator::iterator_concept;
1442template <
typename Iterator>
1444 Iterator, std::enable_if_t<kHaveIteratorCategory<Iterator> &&
1445 !kHaveIteratorConcept<Iterator>>> {
1451#if __has_include(<ranges>)
1452 using iterator_concept =
1453 typename std::iterator_traits<Iterator>::iterator_concept;
1461template <
typename Iterator,
typename ElementType =
void>
1465 std::is_void_v<ElementType> ||
1466 (std::is_convertible_v<typename std::iterator_traits<Iterator>::pointer,
1467 std::add_pointer_t<ElementType>> &&
1468 std::is_convertible_v<typename std::iterator_traits<Iterator>::reference,
1469 std::add_lvalue_reference_t<ElementType>>));
1472 typename std::iterator_traits<Iterator>::difference_type;
1474 std::conditional_t<std::is_void_v<ElementType>,
1475 typename std::iterator_traits<Iterator>::value_type,
1478 std::conditional_t<std::is_void_v<ElementType>,
1479 typename std::iterator_traits<Iterator>::pointer,
1480 std::add_pointer_t<ElementType>>;
1482 std::conditional_t<std::is_void_v<ElementType>,
1483 typename std::iterator_traits<Iterator>::reference,
1484 std::add_lvalue_reference_t<ElementType>>;
1486 typename std::iterator_traits<Iterator>::iterator_category;
1493 template <
typename OtherIterator,
typename OtherElementType,
1494 typename = std::enable_if_t<
1495 std::is_convertible_v<OtherIterator, Iterator>>>
1498 : it_(other.base()) {}
1502 return it_.operator->();
1505 template <
typename OtherIterator,
typename OtherElementType>
1509 return it_ == other.base();
1511#if V8_HAVE_SPACESHIP_OPERATOR
1512 template <
typename OtherIterator,
typename OtherElementType>
1513 [[nodiscard]]
constexpr auto operator<=>(
1514 const WrappedIterator<OtherIterator, OtherElementType>& other)
1516 if constexpr (std::three_way_comparable_with<Iterator, OtherIterator>) {
1517 return it_ <=> other.base();
1518 }
else if constexpr (std::totally_ordered_with<Iterator, OtherIterator>) {
1519 if (it_ < other.base()) {
1520 return std::strong_ordering::less;
1522 return (it_ > other.base()) ? std::strong_ordering::greater
1523 : std::strong_ordering::equal;
1525 if (it_ < other.base()) {
1526 return std::partial_ordering::less;
1528 if (other.base() < it_) {
1529 return std::partial_ordering::greater;
1531 return (it_ == other.base()) ? std::partial_ordering::equivalent
1532 : std::partial_ordering::unordered;
1538 template <
typename OtherIterator,
typename OtherElementType>
1542 return it_ != other.base();
1545 template <
typename OtherIterator,
typename OtherElementType>
1549 return it_ < other.
base();
1551 template <
typename OtherIterator,
typename OtherElementType>
1555 return it_ <= other.
base();
1557 template <
typename OtherIterator,
typename OtherElementType>
1561 return it_ > other.
base();
1563 template <
typename OtherIterator,
typename OtherElementType>
1567 return it_ >= other.base();
1611 template <
typename OtherIterator,
typename OtherElementType>
1615 return it_ - other.base();
1622 [[nodiscard]]
constexpr const Iterator&
base() const noexcept {
return it_; }
1639#ifdef V8_ENABLE_DIRECT_HANDLE
1640 static constexpr Address kTaggedNullAddress = 1;
1649 template <
typename T>
1657 template <
template <
typename T,
typename... Ms>
typename H,
typename T,
1660 return handle.template value<T>();
1663#ifdef V8_ENABLE_DIRECT_HANDLE
1665 template <
typename T>
1667 return reinterpret_cast<Address>(value);
1670 template <
typename T,
bool check_null = true,
typename S>
1672 if (check_null && slot ==
nullptr) {
1673 return reinterpret_cast<T*
>(kTaggedNullAddress);
1675 return *
reinterpret_cast<T**
>(slot);
1678 template <
typename T>
1683 template <
typename T>
1685 return reinterpret_cast<T*
>(repr);
1690 template <
typename T>
1695 template <
typename T,
bool check_null = true,
typename S>
1697 return reinterpret_cast<T*
>(slot);
1700 template <
typename T>
1706 template <
typename T>
1708 return reinterpret_cast<T*
>(repr);
1729 template <
typename T1,
typename T2>
1731 if (lhs.IsEmpty())
return rhs.IsEmpty();
1732 if (rhs.IsEmpty())
return false;
1733 return lhs.ptr() == rhs.ptr();
Definition: v8-isolate.h:212
Definition: v8-internal.h:1359
Definition: v8-internal.h:1713
static bool EqualHandles(const T1 &lhs, const T2 &rhs)
Definition: v8-internal.h:1726
Definition: v8-internal.h:855
static Address LoadMap(Address obj)
Definition: v8-internal.h:1131
static constexpr size_t kExternalAllocationSoftLimit
Definition: v8-internal.h:1050
static bool IsExternalTwoByteString(int instance_type)
Definition: v8-internal.h:1144
static const int kIsolateCageBaseOffset
Definition: v8-internal.h:915
static const int kEmbedderDataArrayHeaderSize
Definition: v8-internal.h:881
static const int kHeapObjectMapOffset
Definition: v8-internal.h:866
static const int kEmbedderDataSlotSize
Definition: v8-internal.h:882
static const int kIsolateApiCallbackThunkArgumentOffset
Definition: v8-internal.h:971
static Address ReadExternalPointerField(v8::Isolate *isolate, Address heap_object_ptr, int offset)
Definition: v8-internal.h:1293
static const int kJSAPIObjectWithEmbedderSlotsHeaderSize
Definition: v8-internal.h:877
static constexpr bool HasHeapObjectTag(Address value)
Definition: v8-internal.h:1070
static const int kOddballType
Definition: v8-internal.h:1027
static const int kInferShouldThrowMode
Definition: v8-internal.h:1046
static const int kNewAllocationInfoOffset
Definition: v8-internal.h:927
static Address GetRoot(v8::Isolate *isolate, int index)
Definition: v8-internal.h:1208
static const int kStringEncodingMask
Definition: v8-internal.h:890
static const int kIsolateFastCCallCallerPcOffset
Definition: v8-internal.h:938
static uint8_t GetNodeFlag(Address *obj, int shift)
Definition: v8-internal.h:1161
static const int kIsolateThreadLocalTopOffset
Definition: v8-internal.h:944
static const uint32_t kNumIsolateDataSlots
Definition: v8-internal.h:894
static const int kForeignType
Definition: v8-internal.h:1028
static const int kFirstEmbedderJSApiObjectType
Definition: v8-internal.h:1035
static const int kNumberOfBooleanFlags
Definition: v8-internal.h:896
static uint8_t GetNodeState(Address *obj)
Definition: v8-internal.h:1172
static const int kThreadLocalTopSize
Definition: v8-internal.h:903
static const int kIsolateRootsOffset
Definition: v8-internal.h:978
static const int kExternalPointerTableSize
Definition: v8-internal.h:909
static const int kUndefinedOddballKind
Definition: v8-internal.h:1039
static const int kMapInstanceTypeOffset
Definition: v8-internal.h:867
static constexpr Address AddressToSmi(Address value)
Definition: v8-internal.h:1078
static const int kIsolateStackGuardOffset
Definition: v8-internal.h:916
static const int kLinearAllocationAreaSize
Definition: v8-internal.h:902
static const int kFastCCallAlignmentPaddingSize
Definition: v8-internal.h:932
static const int kDisallowGarbageCollectionAlign
Definition: v8-internal.h:982
static const int kIsolateFastCCallCallerFpOffset
Definition: v8-internal.h:935
static const int kErrorMessageParamSize
Definition: v8-internal.h:897
static void CheckInitialized(v8::Isolate *isolate)
Definition: v8-internal.h:1064
static void UpdateNodeState(Address *obj, uint8_t value)
Definition: v8-internal.h:1177
static constexpr Address IntegralToSmi(T value)
Definition: v8-internal.h:1089
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:1095
static const int kJSObjectType
Definition: v8-internal.h:1030
static const int kBuiltinTier0TableOffset
Definition: v8-internal.h:925
static const int kIsolateLongTaskStatsCounterOffset
Definition: v8-internal.h:942
static const int kNativeContextEmbedderDataOffset
Definition: v8-internal.h:888
static const int kLastJSApiObjectType
Definition: v8-internal.h:1032
static constexpr bool CanHaveInternalField(int instance_type)
Definition: v8-internal.h:1149
static const int kIsolateHandleScopeDataOffset
Definition: v8-internal.h:946
static const int kFirstNonstringType
Definition: v8-internal.h:1026
static const int kEmptyStringRootIndex
Definition: v8-internal.h:1019
static const int kBuiltinTier0EntryTableOffset
Definition: v8-internal.h:922
static const int kFixedArrayHeaderSize
Definition: v8-internal.h:880
static const int kNullOddballKind
Definition: v8-internal.h:1040
static const int kUndefinedValueRootIndex
Definition: v8-internal.h:1014
static const int kExternalTwoByteRepresentationTag
Definition: v8-internal.h:891
static const int kExternalBufferTableSize
Definition: v8-internal.h:910
static constexpr Address IntToSmi(int value)
Definition: v8-internal.h:1083
static const int kDontThrow
Definition: v8-internal.h:1044
static void CheckInitializedImpl(v8::Isolate *isolate)
static void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
Definition: v8-internal.h:1189
static const int kStackGuardSize
Definition: v8-internal.h:895
static const int kNodeStateMask
Definition: v8-internal.h:1023
static const int kNodeStateIsWeakValue
Definition: v8-internal.h:1024
static const int kFirstJSApiObjectType
Definition: v8-internal.h:1031
static const int kStringResourceOffset
Definition: v8-internal.h:868
static const int kErrorMessageParamOffset
Definition: v8-internal.h:920
static const int kExternalPointerTableBasePointerOffset
Definition: v8-internal.h:908
static const int kFalseValueRootIndex
Definition: v8-internal.h:1018
static const int kIsolateRegexpExecVectorArgumentOffset
Definition: v8-internal.h:974
static const int kIsolateFastApiCallTargetOffset
Definition: v8-internal.h:940
static const int kTrueValueRootIndex
Definition: v8-internal.h:1017
static int GetInstanceType(Address obj)
Definition: v8-internal.h:1123
static const int kThrowOnError
Definition: v8-internal.h:1045
static Address ReadTaggedSignedField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1272
static const int kOddballKindOffset
Definition: v8-internal.h:871
static const int kBuiltinTier0TableSize
Definition: v8-internal.h:901
static const int kContinuationPreservedEmbedderDataOffset
Definition: v8-internal.h:976
static Address ReadTaggedPointerField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1261
static const int kNullValueRootIndex
Definition: v8-internal.h:1016
static void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
Definition: v8-internal.h:1182
static Address * GetRootSlot(v8::Isolate *isolate, int index)
Definition: v8-internal.h:1202
static const int kTrustedPointerTableSize
Definition: v8-internal.h:911
static const int kTheHoleValueRootIndex
Definition: v8-internal.h:1015
static constexpr int SmiValue(Address value)
Definition: v8-internal.h:1074
static const int kTablesAlignmentPaddingSize
Definition: v8-internal.h:898
static const int kHandleScopeDataSize
Definition: v8-internal.h:904
static const int kExternalOneByteRepresentationTag
Definition: v8-internal.h:892
static const int kBuiltinTier0EntryTableSize
Definition: v8-internal.h:900
static void UpdateNodeFlag(Address *obj, bool value, int shift)
Definition: v8-internal.h:1166
static void IncrementLongTasksStatsCounter(v8::Isolate *isolate)
Definition: v8-internal.h:1196
static const int kDisallowGarbageCollectionSize
Definition: v8-internal.h:983
static const int kOldAllocationInfoOffset
Definition: v8-internal.h:929
static const int kIsolateEmbedderDataOffset
Definition: v8-internal.h:948
static T ReadRawField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1245
static const int kEmbedderDataSlotExternalPointerOffset
Definition: v8-internal.h:886
static int GetOddballKind(Address obj)
Definition: v8-internal.h:1140
static const int kNodeFlagsOffset
Definition: v8-internal.h:1022
static const int kTrustedPointerTableBasePointerOffset
Definition: v8-internal.h:912
static const int kRegExpStaticResultOffsetsVectorSize
Definition: v8-internal.h:899
static const int kLastEmbedderJSApiObjectType
Definition: v8-internal.h:1036
static const int kVariousBooleanFlagsOffset
Definition: v8-internal.h:918
static constexpr std::optional< Address > TryIntegralToSmi(T value)
Definition: v8-internal.h:1101
static const int kNodeClassIdOffset
Definition: v8-internal.h:1021
static const int kStringRepresentationAndEncodingMask
Definition: v8-internal.h:889
static const int kJSObjectHeaderSize
Definition: v8-internal.h:872
static v8::Isolate * GetIsolateForSandbox(Address obj)
Definition: v8-internal.h:1282
static const int kJSSpecialApiObjectType
Definition: v8-internal.h:1029
Definition: v8-internal.h:1367
StrongRootAllocatorBase(LocalIsolate *isolate)
Definition: v8-internal.h:1399
T value_type
Definition: v8-internal.h:1401
Definition: v8-internal.h:1627
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1687
static T * ReprAsValue(InternalRepresentationType repr)
Definition: v8-internal.h:1703
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1641
static T * SlotAsValue(S *slot)
Definition: v8-internal.h:1692
static T * HandleAsValue(const H< T, Ms... > &handle)
Definition: v8-internal.h:1655
static InternalRepresentationType ValueAsRepr(const T *value)
Definition: v8-internal.h:1697
static bool IsEmpty(T *value)
Definition: v8-internal.h:1646
static constexpr InternalRepresentationType kEmpty
Definition: v8-internal.h:1642
Definition: v8-internal.h:1458
constexpr WrappedIterator & operator-=(difference_type n) noexcept
Definition: v8-internal.h:1604
constexpr WrappedIterator operator--(int) noexcept
Definition: v8-internal.h:1581
constexpr WrappedIterator & operator+=(difference_type n) noexcept
Definition: v8-internal.h:1596
constexpr const Iterator & base() const noexcept
Definition: v8-internal.h:1618
std::conditional_t< std::is_void_v< ElementType >, typename std::iterator_traits< Iterator >::value_type, ElementType > value_type
Definition: v8-internal.h:1472
constexpr WrappedIterator & operator++() noexcept
Definition: v8-internal.h:1567
constexpr pointer operator->() const noexcept
Definition: v8-internal.h:1497
constexpr reference operator[](difference_type n) const noexcept
Definition: v8-internal.h:1613
typename std::iterator_traits< Iterator >::difference_type difference_type
Definition: v8-internal.h:1468
constexpr bool operator!=(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1535
constexpr bool operator>=(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1560
constexpr bool operator<(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1542
std::conditional_t< std::is_void_v< ElementType >, typename std::iterator_traits< Iterator >::reference, std::add_lvalue_reference_t< ElementType > > reference
Definition: v8-internal.h:1480
constexpr WrappedIterator & operator--() noexcept
Definition: v8-internal.h:1577
constexpr WrappedIterator() noexcept=default
constexpr bool operator<=(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1548
constexpr bool operator>(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1554
typename std::iterator_traits< Iterator >::iterator_category iterator_category
Definition: v8-internal.h:1482
constexpr reference operator*() const noexcept
Definition: v8-internal.h:1496
friend constexpr WrappedIterator operator+(difference_type n, const WrappedIterator &x) noexcept
Definition: v8-internal.h:1592
constexpr WrappedIterator operator++(int) noexcept
Definition: v8-internal.h:1571
constexpr WrappedIterator operator-(difference_type n) const noexcept
Definition: v8-internal.h:1600
std::conditional_t< std::is_void_v< ElementType >, typename std::iterator_traits< Iterator >::pointer, std::add_pointer_t< ElementType > > pointer
Definition: v8-internal.h:1476
constexpr bool operator==(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1502
const intptr_t kHeapObjectTagMask
Definition: v8-internal.h:74
constexpr uint64_t kCppHeapPointerMarkBit
Definition: v8-internal.h:377
constexpr int kCodePointerTableEntrySizeLog2
Definition: v8-internal.h:801
constexpr bool kRuntimeGeneratedCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:813
uint32_t ExternalBufferHandle
Definition: v8-internal.h:408
internal::Isolate * IsolateFromNeverReadOnlySpaceObject(Address obj)
constexpr uint64_t kExternalPointerTagShift
Definition: v8-internal.h:519
IndirectPointerHandle TrustedPointerHandle
Definition: v8-internal.h:736
const int kApiSystemPointerSize
Definition: v8-internal.h:64
constexpr bool SandboxIsEnabled()
Definition: v8-internal.h:219
constexpr size_t kExternalBufferTableReservationSize
Definition: v8-internal.h:429
const int kApiDoubleSize
Definition: v8-internal.h:65
constexpr size_t kMaxCppHeapPointers
Definition: v8-internal.h:400
constexpr intptr_t kIntptrAllBitsSet
Definition: v8-internal.h:92
constexpr int GB
Definition: v8-internal.h:56
void VerifyHandleIsNonEmpty(bool is_empty)
const int kApiInt32Size
Definition: v8-internal.h:66
constexpr uint32_t kJSDispatchHandleShift
Definition: v8-internal.h:831
const int kForwardingTagSize
Definition: v8-internal.h:81
uint32_t CppHeapPointerHandle
Definition: v8-internal.h:362
const intptr_t kForwardingTagMask
Definition: v8-internal.h:82
void PrintPropertyCallbackInfo(void *property_callback_info)
IndirectPointerHandle CodePointerHandle
Definition: v8-internal.h:774
constexpr size_t kMaxExternalBufferPointers
Definition: v8-internal.h:439
const int kSmiTagSize
Definition: v8-internal.h:86
const int kApiInt64Size
Definition: v8-internal.h:67
constexpr int kExternalBufferTableEntrySizeLog2
Definition: v8-internal.h:438
constexpr uint64_t kExternalPointerTagMask
Definition: v8-internal.h:517
constexpr int kCodePointerTableEntryCodeObjectOffset
Definition: v8-internal.h:809
constexpr int kTrustedPointerTableEntrySizeLog2
Definition: v8-internal.h:753
constexpr size_t kJSDispatchTableReservationSize
Definition: v8-internal.h:830
constexpr int kTrustedPointerTableEntrySize
Definition: v8-internal.h:752
constexpr uint64_t kCppHeapPointerPayloadShift
Definition: v8-internal.h:379
constexpr ExternalPointer_t kNullExternalPointer
Definition: v8-internal.h:354
Address ExternalPointer_t
Definition: v8-internal.h:351
uint32_t IndirectPointerHandle
Definition: v8-internal.h:716
constexpr CppHeapPointer_t kNullCppHeapPointer
Definition: v8-internal.h:374
const int kApiSizetSize
Definition: v8-internal.h:68
constexpr int kCodePointerTableEntryEntrypointOffset
Definition: v8-internal.h:808
constexpr size_t kMaxExternalPointers
Definition: v8-internal.h:332
constexpr uint64_t kExternalPointerTagMaskWithoutMarkBit
Definition: v8-internal.h:518
constexpr size_t kCodePointerTableReservationSize
Definition: v8-internal.h:779
constexpr TrustedPointerHandle kNullTrustedPointerHandle
Definition: v8-internal.h:748
constexpr ExternalBufferHandle kNullExternalBufferHandle
Definition: v8-internal.h:434
const int kWeakHeapObjectTag
Definition: v8-internal.h:72
constexpr ExternalPointerHandle kNullExternalPointerHandle
Definition: v8-internal.h:355
constexpr uintptr_t kUintptrAllBitsSet
Definition: v8-internal.h:93
uint32_t JSDispatchHandle
Definition: v8-internal.h:823
const int kForwardingTag
Definition: v8-internal.h:80
const intptr_t kHeapObjectReferenceTagMask
Definition: v8-internal.h:75
constexpr bool SmiValuesAre31Bits()
Definition: v8-internal.h:207
constexpr size_t kMaxTrustedPointers
Definition: v8-internal.h:754
bool ShouldThrowOnError(internal::Isolate *isolate)
constexpr uint64_t kCppHeapPointerTagShift
Definition: v8-internal.h:378
constexpr int KB
Definition: v8-internal.h:54
constexpr uint64_t kAllTagsForAndBasedTypeChecking[]
Definition: v8-internal.h:525
constexpr bool kBuiltinCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:814
constexpr uint32_t kTrustedPointerHandleShift
Definition: v8-internal.h:745
constexpr uint32_t kCodePointerHandleShift
Definition: v8-internal.h:783
const int kHeapObjectTag
Definition: v8-internal.h:71
const int kSmiShiftSize
Definition: v8-internal.h:203
constexpr size_t kMaxCodePointers
Definition: v8-internal.h:802
constexpr bool kHaveIteratorCategory
Definition: v8-internal.h:1421
SmiTagging< kApiTaggedSize > PlatformSmiTagging
Definition: v8-internal.h:198
const int kSmiValueSize
Definition: v8-internal.h:204
constexpr size_t kMaxJSDispatchEntries
Definition: v8-internal.h:836
constexpr bool SmiValuesAre32Bits()
Definition: v8-internal.h:208
constexpr IndirectPointerHandle kNullIndirectPointerHandle
Definition: v8-internal.h:719
uintptr_t Address
Definition: v8-internal.h:51
constexpr int kJSDispatchTableEntrySizeLog2
Definition: v8-internal.h:835
void PerformCastCheck(T *data)
Definition: v8-internal.h:1352
void PrintFunctionCallbackInfo(void *function_callback_info)
constexpr size_t kTrustedPointerTableReservationSize
Definition: v8-internal.h:741
uint32_t ExternalPointerHandle
Definition: v8-internal.h:343
const intptr_t kSmiTagMask
Definition: v8-internal.h:87
constexpr uint32_t kExternalBufferHandleShift
Definition: v8-internal.h:430
const int kHeapObjectTagSize
Definition: v8-internal.h:73
const int kSmiMaxValue
Definition: v8-internal.h:206
Address ExternalBuffer_t
Definition: v8-internal.h:416
constexpr bool Is64()
Definition: v8-internal.h:209
constexpr bool kAllCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:815
const int kSmiTag
Definition: v8-internal.h:85
constexpr CodePointerHandle kNullCodePointerHandle
Definition: v8-internal.h:786
Address CppHeapPointer_t
Definition: v8-internal.h:371
constexpr CppHeapPointerHandle kNullCppHeapPointerHandle
Definition: v8-internal.h:375
constexpr int kGarbageCollectionReasonMaxValue
Definition: v8-internal.h:1363
constexpr int kCodePointerTableEntrySize
Definition: v8-internal.h:800
constexpr int kExternalBufferTableEntrySize
Definition: v8-internal.h:437
ExternalPointerTag
Definition: v8-internal.h:636
@ kExternalPointerEvacuationEntryTag
Definition: v8-internal.h:649
@ kAccessorInfoGetterTag
Definition: v8-internal.h:654
@ kFirstSharedTag
Definition: v8-internal.h:654
@ kAccessorInfoSetterTag
Definition: v8-internal.h:654
@ kAnyForeignTag
Definition: v8-internal.h:643
@ kExternalPointerFreeEntryTag
Definition: v8-internal.h:647
@ kAnyExternalPointerTag
Definition: v8-internal.h:640
@ kLastSharedTag
Definition: v8-internal.h:654
@ kExternalPointerNullTag
Definition: v8-internal.h:638
@ kLastManagedResourceTag
Definition: v8-internal.h:654
@ kExternalPointerZappedEntryTag
Definition: v8-internal.h:652
@ kFirstManagedResourceTag
Definition: v8-internal.h:654
@ kFunctionTemplateInfoCallbackTag
Definition: v8-internal.h:654
constexpr uint32_t kCodePointerHandleMarker
Definition: v8-internal.h:795
constexpr JSDispatchHandle kNullJSDispatchHandle
Definition: v8-internal.h:825
const int kSmiMinValue
Definition: v8-internal.h:205
constexpr bool kHaveIteratorConcept
Definition: v8-internal.h:1415
constexpr int kJSDispatchTableEntrySize
Definition: v8-internal.h:834
constexpr int MB
Definition: v8-internal.h:55
constexpr uint64_t kExternalPointerMarkBit
Definition: v8-internal.h:516
Address SandboxedPointer_t
Definition: v8-internal.h:229
const int kApiTaggedSize
Definition: v8-internal.h:188
constexpr bool PointerCompressionIsEnabled()
Definition: v8-internal.h:191
Definition: libplatform.h:15
Definition: v8-internal.h:1336
static void Perform(T *data)
Definition: v8-internal.h:1430
static constexpr bool IsValidSmi(uint64_t value)
Definition: v8-internal.h:140
static constexpr bool IsValidSmi(int64_t value)
Definition: v8-internal.h:133
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:113
static constexpr int SmiToInt(Address value)
Definition: v8-internal.h:105
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:163
static constexpr int SmiToInt(Address value)
Definition: v8-internal.h:155
Definition: v8-internal.h:90
#define EXTERNAL_POINTER_TAG_ENUM(Name, Tag)
Definition: v8-internal.h:632
#define ALL_EXTERNAL_POINTER_TAGS(V)
Definition: v8-internal.h:628
#define CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS(Tag,...)
Definition: v8-internal.h:690
#define SHARED_EXTERNAL_POINTER_TAGS(V)
Definition: v8-internal.h:553
#define MAKE_TAG(HasMarkBit, TypeTag)
Definition: v8-internal.h:633
#define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V)
Definition: v8-internal.h:563
#define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag,...)
Definition: v8-internal.h:688
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_LIKELY(condition)
Definition: v8config.h:650