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
53static constexpr Address kNullAddress = 0;
55constexpr int KB = 1024;
56constexpr int MB =
KB * 1024;
57constexpr int GB =
MB * 1024;
58#ifdef V8_TARGET_ARCH_X64
59constexpr size_t TB =
size_t{
GB} * 1024;
90template <
size_t tagged_ptr_size>
109 return static_cast<int32_t
>(
static_cast<uint32_t
>(value)) >> shift_bits;
112 template <
class T,
typename std::enable_if_t<std::is_
integral_v<T> &&
113 std::is_
signed_v<T>>* =
nullptr>
118 return (
static_cast<uintptr_t
>(value) -
125 typename std::enable_if_t<std::is_integral_v<T> &&
126 std::is_unsigned_v<T>>* =
nullptr>
128 static_assert(kSmiMaxValue <= std::numeric_limits<uintptr_t>::max());
135 return (
static_cast<uint64_t
>(value) -
142 static_assert(kSmiMaxValue <= std::numeric_limits<uint64_t>::max());
159 return static_cast<int>(
static_cast<intptr_t
>(value) >> shift_bits);
162 template <
class T,
typename std::enable_if_t<std::is_
integral_v<T> &&
163 std::is_
signed_v<T>>* =
nullptr>
166 return std::numeric_limits<int32_t>::min() <= value &&
167 value <= std::numeric_limits<int32_t>::max();
171 typename std::enable_if_t<std::is_integral_v<T> &&
172 std::is_unsigned_v<T>>* =
nullptr>
174 return value <= std::numeric_limits<int32_t>::max();
178#ifdef V8_COMPRESS_POINTERS
181constexpr size_t kPtrComprCageReservationSize =
size_t{1} << 32;
182constexpr size_t kPtrComprCageBaseAlignment =
size_t{1} << 32;
186 "Pointer compression can be enabled only for 64-bit architectures");
196#ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
206const int kSmiMinValue =
static_cast<int>(PlatformSmiTagging::kSmiMinValue);
207const int kSmiMaxValue =
static_cast<int>(PlatformSmiTagging::kSmiMaxValue);
221#ifdef V8_ENABLE_SANDBOX
232#ifdef V8_ENABLE_SANDBOX
235#if defined(V8_TARGET_OS_ANDROID)
239constexpr size_t kSandboxSizeLog2 = 37;
242constexpr size_t kSandboxSizeLog2 = 40;
244constexpr size_t kSandboxSize = 1ULL << kSandboxSizeLog2;
251constexpr size_t kSandboxAlignment = kPtrComprCageBaseAlignment;
257constexpr uint64_t kSandboxedPointerShift = 64 - kSandboxSizeLog2;
265constexpr size_t kSandboxGuardRegionSize = 32ULL *
GB + 4ULL *
GB;
267static_assert((kSandboxGuardRegionSize % kSandboxAlignment) == 0,
268 "The size of the guard regions around the sandbox must be a "
269 "multiple of its required alignment.");
281constexpr size_t kSandboxMinimumReservationSize = 8ULL *
GB;
283static_assert(kSandboxMinimumReservationSize > kPtrComprCageReservationSize,
284 "The minimum reservation size for a sandbox must be larger than "
285 "the pointer compression cage contained within it.");
291constexpr size_t kMaxSafeBufferSizeForSandbox = 32ULL *
GB - 1;
292static_assert(kMaxSafeBufferSizeForSandbox <= kSandboxGuardRegionSize,
293 "The maximum allowed buffer size must not be larger than the "
294 "sandbox's guard regions");
296constexpr size_t kBoundedSizeShift = 29;
297static_assert(1ULL << (64 - kBoundedSizeShift) ==
298 kMaxSafeBufferSizeForSandbox + 1,
299 "The maximum size of a BoundedSize must be synchronized with the "
300 "kMaxSafeBufferSizeForSandbox");
304#ifdef V8_COMPRESS_POINTERS
306#ifdef V8_TARGET_OS_ANDROID
312constexpr size_t kExternalPointerTableReservationSize = 256 *
MB;
318constexpr uint32_t kExternalPointerIndexShift = 7;
320constexpr size_t kExternalPointerTableReservationSize = 512 *
MB;
321constexpr uint32_t kExternalPointerIndexShift = 6;
325constexpr int kExternalPointerTableEntrySize = 8;
326constexpr int kExternalPointerTableEntrySizeLog2 = 3;
328 kExternalPointerTableReservationSize / kExternalPointerTableEntrySize;
330 "kExternalPointerTableReservationSize and "
331 "kExternalPointerIndexShift don't match");
352#ifdef V8_ENABLE_SANDBOX
372#ifdef V8_COMPRESS_POINTERS
385#ifdef V8_COMPRESS_POINTERS
389constexpr size_t kCppHeapPointerTableReservationSize =
390 kExternalPointerTableReservationSize;
391constexpr uint32_t kCppHeapPointerIndexShift = kExternalPointerIndexShift;
393constexpr int kCppHeapPointerTableEntrySize = 8;
394constexpr int kCppHeapPointerTableEntrySizeLog2 = 3;
396 kCppHeapPointerTableReservationSize / kCppHeapPointerTableEntrySize;
398 "kCppHeapPointerTableReservationSize and "
399 "kCppHeapPointerIndexShift don't match");
488 0b00001111, 0b00010111, 0b00011011, 0b00011101, 0b00011110, 0b00100111,
489 0b00101011, 0b00101101, 0b00101110, 0b00110011, 0b00110101, 0b00110110,
490 0b00111001, 0b00111010, 0b00111100, 0b01000111, 0b01001011, 0b01001101,
491 0b01001110, 0b01010011, 0b01010101, 0b01010110, 0b01011001, 0b01011010,
492 0b01011100, 0b01100011, 0b01100101, 0b01100110, 0b01101001, 0b01101010,
493 0b01101100, 0b01110001, 0b01110010, 0b01110100, 0b01111000, 0b10000111,
494 0b10001011, 0b10001101, 0b10001110, 0b10010011, 0b10010101, 0b10010110,
495 0b10011001, 0b10011010, 0b10011100, 0b10100011, 0b10100101, 0b10100110,
496 0b10101001, 0b10101010, 0b10101100, 0b10110001, 0b10110010, 0b10110100,
497 0b10111000, 0b11000011, 0b11000101, 0b11000110, 0b11001001, 0b11001010,
498 0b11001100, 0b11010001, 0b11010010, 0b11010100, 0b11011000, 0b11100001,
499 0b11100010, 0b11100100, 0b11101000, 0b11110000};
502 ((kAllTagsForAndBasedTypeChecking[i] << kExternalPointerTagShift) | \
503 kExternalPointerMarkBit)
515#define SHARED_EXTERNAL_POINTER_TAGS(V) \
516 V(kFirstSharedTag, TAG(0)) \
517 V(kWaiterQueueNodeTag, TAG(0)) \
518 V(kExternalStringResourceTag, TAG(1)) \
519 V(kExternalStringResourceDataTag, TAG(2)) \
520 V(kLastSharedTag, TAG(2))
525#define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V) \
526 V(kNativeContextMicrotaskQueueTag, TAG(5)) \
527 V(kEmbedderDataSlotPayloadTag, TAG(6)) \
531 V(kExternalObjectValueTag, TAG(7)) \
532 V(kFunctionTemplateInfoCallbackTag, TAG(8)) \
533 V(kAccessorInfoGetterTag, TAG(9)) \
534 V(kAccessorInfoSetterTag, TAG(10)) \
535 V(kWasmInternalFunctionCallTargetTag, TAG(11)) \
536 V(kWasmTypeInfoNativeTypeTag, TAG(12)) \
537 V(kWasmExportedFunctionDataSignatureTag, TAG(13)) \
538 V(kWasmContinuationJmpbufTag, TAG(14)) \
539 V(kWasmStackMemoryTag, TAG(15)) \
540 V(kWasmIndirectFunctionTargetTag, TAG(16)) \
542 V(kGenericForeignTag, TAG(20)) \
543 V(kApiNamedPropertyQueryCallbackTag, TAG(21)) \
544 V(kApiNamedPropertyGetterCallbackTag, TAG(22)) \
545 V(kApiNamedPropertySetterCallbackTag, TAG(23)) \
546 V(kApiNamedPropertyDescriptorCallbackTag, TAG(24)) \
547 V(kApiNamedPropertyDefinerCallbackTag, TAG(25)) \
548 V(kApiNamedPropertyDeleterCallbackTag, TAG(26)) \
549 V(kApiIndexedPropertyQueryCallbackTag, TAG(27)) \
550 V(kApiIndexedPropertyGetterCallbackTag, TAG(28)) \
551 V(kApiIndexedPropertySetterCallbackTag, TAG(29)) \
552 V(kApiIndexedPropertyDescriptorCallbackTag, TAG(30)) \
553 V(kApiIndexedPropertyDefinerCallbackTag, TAG(31)) \
554 V(kApiIndexedPropertyDeleterCallbackTag, TAG(32)) \
555 V(kApiIndexedPropertyEnumeratorCallbackTag, TAG(33)) \
556 V(kApiAccessCheckCallbackTag, TAG(34)) \
557 V(kApiAbortScriptExecutionCallbackTag, TAG(35)) \
558 V(kSyntheticModuleTag, TAG(36)) \
559 V(kMicrotaskCallbackTag, TAG(37)) \
560 V(kMicrotaskCallbackDataTag, TAG(38)) \
561 V(kCFunctionTag, TAG(39)) \
562 V(kCFunctionInfoTag, TAG(40)) \
563 V(kMessageListenerTag, TAG(41)) \
564 V(kWaiterQueueForeignTag, TAG(42)) \
566 V(kFirstManagedResourceTag, TAG(50)) \
567 V(kGenericManagedTag, TAG(50)) \
568 V(kWasmWasmStreamingTag, TAG(51)) \
569 V(kWasmFuncDataTag, TAG(52)) \
570 V(kWasmManagedDataTag, TAG(53)) \
571 V(kWasmNativeModuleTag, TAG(54)) \
572 V(kIcuBreakIteratorTag, TAG(55)) \
573 V(kIcuUnicodeStringTag, TAG(56)) \
574 V(kIcuListFormatterTag, TAG(57)) \
575 V(kIcuLocaleTag, TAG(58)) \
576 V(kIcuSimpleDateFormatTag, TAG(59)) \
577 V(kIcuDateIntervalFormatTag, TAG(60)) \
578 V(kIcuRelativeDateTimeFormatterTag, TAG(61)) \
579 V(kIcuLocalizedNumberFormatterTag, TAG(62)) \
580 V(kIcuPluralRulesTag, TAG(63)) \
581 V(kIcuCollatorTag, TAG(64)) \
582 V(kDisplayNamesInternalTag, TAG(65)) \
586 V(kArrayBufferExtensionTag, TAG(66)) \
587 V(kLastManagedResourceTag, TAG(66)) \
590#define ALL_EXTERNAL_POINTER_TAGS(V) \
591 SHARED_EXTERNAL_POINTER_TAGS(V) \
592 PER_ISOLATE_EXTERNAL_POINTER_TAGS(V)
594#define EXTERNAL_POINTER_TAG_ENUM(Name, Tag) Name = Tag,
595#define MAKE_TAG(HasMarkBit, TypeTag) \
596 ((static_cast<uint64_t>(TypeTag) << kExternalPointerTagShift) | \
597 (HasMarkBit ? kExternalPointerMarkBit : 0))
621#undef EXTERNAL_POINTER_TAG_ENUM
627V8_INLINE static constexpr bool IsSharedExternalPointerType(
635V8_INLINE static constexpr bool IsMaybeReadOnlyExternalPointerType(
645V8_INLINE static constexpr bool IsManagedExternalPointerType(
651#define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \
652 static_assert(IsSharedExternalPointerType(Tag));
653#define CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS(Tag, ...) \
654 static_assert(!IsSharedExternalPointerType(Tag));
659#undef CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS
660#undef CHECK_SHARED_EXTERNAL_POINTER_TAGS
662#undef SHARED_EXTERNAL_POINTER_TAGS
663#undef EXTERNAL_POINTER_TAGS
723 "kTrustedPointerTableReservationSize and "
724 "kTrustedPointerHandleShift don't match");
772 "kCodePointerTableReservationSize and kCodePointerHandleShift don't match");
802 return mapword ^ kMapWordXorMask;
816#ifdef V8_COMPRESS_POINTERS
826#ifdef V8_ENABLE_SANDBOX
892#ifdef V8_COMPRESS_POINTERS
893 static const int kIsolateExternalPointerTableOffset =
895 static const int kIsolateSharedExternalPointerTableAddressOffset =
897 static const int kIsolateCppHeapPointerTableOffset =
899#ifdef V8_ENABLE_SANDBOX
900 static const int kIsolateTrustedCageBaseOffset =
902 static const int kIsolateTrustedPointerTableOffset =
904 static const int kIsolateSharedTrustedPointerTableAddressOffset =
927#if V8_STATIC_ROOTS_BOOL
930#define EXPORTED_STATIC_ROOTS_PTR_LIST(V) \
931 V(UndefinedValue, 0x11) \
934 V(FalseValue, 0x55) \
935 V(EmptyString, 0x49) \
936 V(TheHoleValue, 0x761)
938 using Tagged_t = uint32_t;
939 struct StaticReadOnlyRoot {
940#define DEF_ROOT(name, value) static constexpr Tagged_t k##name = value;
941 EXPORTED_STATIC_ROOTS_PTR_LIST(DEF_ROOT)
945 static constexpr Tagged_t kStringMapLowerBound = 0;
946 static constexpr Tagged_t kStringMapUpperBound = 0x425;
948#define PLUSONE(...) +1
949 static constexpr size_t kNumberOfExportedStaticRoots =
950 2 + EXPORTED_STATIC_ROOTS_PTR_LIST(PLUSONE);
995 static const uintptr_t kMapWordMetadataMask = 0xffffULL << 48;
997 static const uintptr_t kMapWordSignature = 0b10;
1002 static const int kMapWordXorMask = 0b11;
1007#ifdef V8_ENABLE_CHECKS
1017 return PlatformSmiTagging::SmiToInt(value);
1029 template <
typename T,
1030 typename std::enable_if_t<std::is_integral_v<T>>* =
nullptr>
1035 template <
typename T,
1036 typename std::enable_if_t<std::is_integral_v<T>>* =
nullptr>
1038 return PlatformSmiTagging::IsValidSmi(value);
1041 template <
typename T,
1042 typename std::enable_if_t<std::is_integral_v<T>>* =
nullptr>
1044 if (
V8_LIKELY(PlatformSmiTagging::IsValidSmi(value))) {
1050#if V8_STATIC_ROOTS_BOOL
1052 return static_cast<Tagged_t
>(obj) == constant;
1055 V8_INLINE static bool CheckInstanceMapRange(
Address obj, Tagged_t first_map,
1056 Tagged_t last_map) {
1058#ifdef V8_MAP_PACKING
1059 map = UnpackMapWord(map);
1061 return map >= first_map && map <= last_map;
1067#ifdef V8_MAP_PACKING
1068 map = UnpackMapWord(map);
1076#ifdef V8_MAP_PACKING
1077 map = UnpackMapWord(map);
1098 (
static_cast<unsigned>(
static_cast<unsigned>(instance_type) -
1105 return *addr &
static_cast<uint8_t
>(1U << shift);
1110 uint8_t mask =
static_cast<uint8_t
>(1U << shift);
1111 *addr =
static_cast<uint8_t
>((*addr & ~mask) | (value << shift));
1121 *addr =
static_cast<uint8_t
>((*addr & ~kNodeStateMask) | value);
1128 *
reinterpret_cast<void**
>(addr) = data;
1135 return *
reinterpret_cast<void* const*
>(addr);
1141 ++(*
reinterpret_cast<size_t*
>(addr));
1147 return reinterpret_cast<Address*
>(addr);
1151#if V8_STATIC_ROOTS_BOOL
1155#define DECOMPRESS_ROOT(name, ...) \
1156 case k##name##RootIndex: \
1157 return base + StaticReadOnlyRoot::k##name;
1158 EXPORTED_STATIC_ROOTS_PTR_LIST(DECOMPRESS_ROOT)
1159#undef DECOMPRESS_ROOT
1160#undef EXPORTED_STATIC_ROOTS_PTR_LIST
1168#ifdef V8_ENABLE_SANDBOX
1171 kIsolateExternalPointerTableOffset +
1173 return *
reinterpret_cast<Address**
>(addr);
1179 kIsolateSharedExternalPointerTableAddressOffset;
1180 addr = *
reinterpret_cast<Address*
>(addr);
1182 return *
reinterpret_cast<Address**
>(addr);
1186 template <
typename T>
1189#ifdef V8_COMPRESS_POINTERS
1196 memcpy(&r,
reinterpret_cast<void*
>(addr),
sizeof(T));
1200 return *
reinterpret_cast<const T*
>(addr);
1205#ifdef V8_COMPRESS_POINTERS
1206 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
1207 Address base = GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
1208 return base +
static_cast<Address>(
static_cast<uintptr_t
>(value));
1210 return ReadRawField<Address>(heap_object_ptr, offset);
1216#ifdef V8_COMPRESS_POINTERS
1217 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
1218 return static_cast<Address>(
static_cast<uintptr_t
>(value));
1220 return ReadRawField<Address>(heap_object_ptr, offset);
1225#ifdef V8_ENABLE_SANDBOX
1234 template <ExternalPo
interTag tag>
1238#ifdef V8_ENABLE_SANDBOX
1242 Address* table = IsSharedExternalPointerType(tag)
1243 ? GetSharedExternalPointerTableBase(isolate)
1244 : GetExternalPointerTableBase(isolate);
1246 ReadRawField<ExternalPointerHandle>(heap_object_ptr, offset);
1247 uint32_t index = handle >> kExternalPointerIndexShift;
1248 std::atomic<Address>* ptr =
1249 reinterpret_cast<std::atomic<Address>*
>(&table[index]);
1250 Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed);
1251 return entry & ~tag;
1253 return ReadRawField<Address>(heap_object_ptr, offset);
1257#ifdef V8_COMPRESS_POINTERS
1259 return addr & -
static_cast<intptr_t
>(kPtrComprCageBaseAlignment);
1263 return static_cast<uint32_t
>(value);
1268 Address base = GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
1269 return base +
static_cast<Address>(
static_cast<uintptr_t
>(value));
1277template <
bool PerformCheck>
1295 CastCheck<std::is_base_of<Data, T>::value &&
1296 !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
1311 Heap* heap()
const {
return heap_; }
1317 return a.heap_ == b.heap_;
1328 Address* allocate_impl(
size_t n);
1329 void deallocate_impl(
Address* p,
size_t n)
noexcept;
1340template <
typename T>
1345 template <
typename HeapOrIsolateT>
1347 template <
typename U>
1350 using std::allocator<T>::allocate;
1351 using std::allocator<T>::deallocate;
1356template <
typename Iterator,
typename =
void>
1358template <
typename Iterator>
1360 Iterator, std::void_t<typename Iterator::iterator_concept>> =
true;
1362template <
typename Iterator,
typename =
void>
1364template <
typename Iterator>
1366 Iterator, std::void_t<typename Iterator::iterator_category>> =
true;
1371template <
typename Iterator,
typename =
void>
1374template <
typename Iterator>
1376 Iterator, std::enable_if_t<kHaveIteratorConcept<Iterator>>> {
1377 using iterator_concept =
typename Iterator::iterator_concept;
1380template <
typename Iterator>
1382 Iterator, std::enable_if_t<kHaveIteratorCategory<Iterator> &&
1383 !kHaveIteratorConcept<Iterator>>> {
1389#if __has_include(<ranges>)
1390 using iterator_concept =
1391 typename std::iterator_traits<Iterator>::iterator_concept;
1399template <
typename Iterator,
typename ElementType =
void>
1403 std::is_void_v<ElementType> ||
1404 (std::is_convertible_v<typename std::iterator_traits<Iterator>::pointer,
1405 std::add_pointer_t<ElementType>> &&
1406 std::is_convertible_v<typename std::iterator_traits<Iterator>::reference,
1407 std::add_lvalue_reference_t<ElementType>>));
1410 typename std::iterator_traits<Iterator>::difference_type;
1412 std::conditional_t<std::is_void_v<ElementType>,
1413 typename std::iterator_traits<Iterator>::value_type,
1416 std::conditional_t<std::is_void_v<ElementType>,
1417 typename std::iterator_traits<Iterator>::pointer,
1418 std::add_pointer_t<ElementType>>;
1420 std::conditional_t<std::is_void_v<ElementType>,
1421 typename std::iterator_traits<Iterator>::reference,
1422 std::add_lvalue_reference_t<ElementType>>;
1424 typename std::iterator_traits<Iterator>::iterator_category;
1431 template <
typename OtherIterator,
typename OtherElementType,
1432 typename = std::enable_if_t<
1433 std::is_convertible_v<OtherIterator, Iterator>>>
1436 : it_(other.base()) {}
1440 return it_.operator->();
1443 template <
typename OtherIterator,
typename OtherElementType>
1447 return it_ == other.base();
1449#if V8_HAVE_SPACESHIP_OPERATOR
1450 template <
typename OtherIterator,
typename OtherElementType>
1451 [[nodiscard]]
constexpr auto operator<=>(
1452 const WrappedIterator<OtherIterator, OtherElementType>& other)
1454 if constexpr (std::three_way_comparable_with<Iterator, OtherIterator>) {
1455 return it_ <=> other.base();
1456 }
else if constexpr (std::totally_ordered_with<Iterator, OtherIterator>) {
1457 if (it_ < other.base()) {
1458 return std::strong_ordering::less;
1460 return (it_ > other.base()) ? std::strong_ordering::greater
1461 : std::strong_ordering::equal;
1463 if (it_ < other.base()) {
1464 return std::partial_ordering::less;
1466 if (other.base() < it_) {
1467 return std::partial_ordering::greater;
1469 return (it_ == other.base()) ? std::partial_ordering::equivalent
1470 : std::partial_ordering::unordered;
1476 template <
typename OtherIterator,
typename OtherElementType>
1480 return it_ != other.base();
1483 template <
typename OtherIterator,
typename OtherElementType>
1487 return it_ < other.
base();
1489 template <
typename OtherIterator,
typename OtherElementType>
1493 return it_ <= other.
base();
1495 template <
typename OtherIterator,
typename OtherElementType>
1499 return it_ > other.
base();
1501 template <
typename OtherIterator,
typename OtherElementType>
1505 return it_ >= other.base();
1549 template <
typename OtherIterator,
typename OtherElementType>
1553 return it_ - other.base();
1560 [[nodiscard]]
constexpr const Iterator&
base() const noexcept {
return it_; }
1577#ifdef V8_ENABLE_DIRECT_HANDLE
1578 static constexpr Address kTaggedNullAddress = 1;
1587 template <
typename T>
1595 template <
template <
typename T,
typename... Ms>
typename H,
typename T,
1598 return handle.template value<T>();
1601#ifdef V8_ENABLE_DIRECT_HANDLE
1603 template <
typename T>
1605 return reinterpret_cast<Address>(value);
1608 template <
typename T,
bool check_null = true,
typename S>
1610 if (check_null && slot ==
nullptr) {
1611 return reinterpret_cast<T*
>(kTaggedNullAddress);
1613 return *
reinterpret_cast<T**
>(slot);
1616 template <
typename T>
1621 template <
typename T>
1623 return reinterpret_cast<T*
>(repr);
1628 template <
typename T>
1633 template <
typename T,
bool check_null = true,
typename S>
1635 return reinterpret_cast<T*
>(slot);
1638 template <
typename T>
1644 template <
typename T>
1646 return reinterpret_cast<T*
>(repr);
1667 template <
typename T1,
typename T2>
1669 if (lhs.IsEmpty())
return rhs.IsEmpty();
1670 if (rhs.IsEmpty())
return false;
1671 return lhs.ptr() == rhs.ptr();
Definition: v8-isolate.h:261
Definition: v8-internal.h:1297
Definition: v8-internal.h:1651
static bool EqualHandles(const T1 &lhs, const T2 &rhs)
Definition: v8-internal.h:1664
Definition: v8-internal.h:794
static Address LoadMap(Address obj)
Definition: v8-internal.h:1069
static constexpr size_t kExternalAllocationSoftLimit
Definition: v8-internal.h:988
static bool IsExternalTwoByteString(int instance_type)
Definition: v8-internal.h:1082
static const int kIsolateCageBaseOffset
Definition: v8-internal.h:853
static const int kEmbedderDataArrayHeaderSize
Definition: v8-internal.h:820
static const int kHeapObjectMapOffset
Definition: v8-internal.h:805
static const int kEmbedderDataSlotSize
Definition: v8-internal.h:821
static const int kIsolateApiCallbackThunkArgumentOffset
Definition: v8-internal.h:909
static Address ReadExternalPointerField(v8::Isolate *isolate, Address heap_object_ptr, int offset)
Definition: v8-internal.h:1231
static const int kJSAPIObjectWithEmbedderSlotsHeaderSize
Definition: v8-internal.h:816
static constexpr bool HasHeapObjectTag(Address value)
Definition: v8-internal.h:1008
static const int kOddballType
Definition: v8-internal.h:965
static const int kInferShouldThrowMode
Definition: v8-internal.h:984
static const int kNewAllocationInfoOffset
Definition: v8-internal.h:865
static Address GetRoot(v8::Isolate *isolate, int index)
Definition: v8-internal.h:1146
static const int kStringEncodingMask
Definition: v8-internal.h:829
static const int kIsolateFastCCallCallerPcOffset
Definition: v8-internal.h:876
static uint8_t GetNodeFlag(Address *obj, int shift)
Definition: v8-internal.h:1099
static const int kIsolateThreadLocalTopOffset
Definition: v8-internal.h:882
static const uint32_t kNumIsolateDataSlots
Definition: v8-internal.h:833
static const int kForeignType
Definition: v8-internal.h:966
static const int kFirstEmbedderJSApiObjectType
Definition: v8-internal.h:973
static const int kNumberOfBooleanFlags
Definition: v8-internal.h:835
static uint8_t GetNodeState(Address *obj)
Definition: v8-internal.h:1110
static const int kThreadLocalTopSize
Definition: v8-internal.h:842
static const int kIsolateRootsOffset
Definition: v8-internal.h:916
static const int kExternalPointerTableSize
Definition: v8-internal.h:848
static const int kUndefinedOddballKind
Definition: v8-internal.h:977
static const int kMapInstanceTypeOffset
Definition: v8-internal.h:806
static constexpr Address AddressToSmi(Address value)
Definition: v8-internal.h:1016
static const int kIsolateStackGuardOffset
Definition: v8-internal.h:854
static const int kLinearAllocationAreaSize
Definition: v8-internal.h:841
static const int kFastCCallAlignmentPaddingSize
Definition: v8-internal.h:870
static const int kDisallowGarbageCollectionAlign
Definition: v8-internal.h:920
static const int kIsolateFastCCallCallerFpOffset
Definition: v8-internal.h:873
static const int kErrorMessageParamSize
Definition: v8-internal.h:836
static void CheckInitialized(v8::Isolate *isolate)
Definition: v8-internal.h:1002
static void UpdateNodeState(Address *obj, uint8_t value)
Definition: v8-internal.h:1115
static constexpr Address IntegralToSmi(T value)
Definition: v8-internal.h:1027
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:1033
static const int kJSObjectType
Definition: v8-internal.h:968
static const int kBuiltinTier0TableOffset
Definition: v8-internal.h:863
static const int kIsolateLongTaskStatsCounterOffset
Definition: v8-internal.h:880
static const int kNativeContextEmbedderDataOffset
Definition: v8-internal.h:827
static const int kLastJSApiObjectType
Definition: v8-internal.h:970
static constexpr bool CanHaveInternalField(int instance_type)
Definition: v8-internal.h:1087
static const int kIsolateHandleScopeDataOffset
Definition: v8-internal.h:884
static const int kFirstNonstringType
Definition: v8-internal.h:964
static const int kEmptyStringRootIndex
Definition: v8-internal.h:957
static const int kBuiltinTier0EntryTableOffset
Definition: v8-internal.h:860
static const int kFixedArrayHeaderSize
Definition: v8-internal.h:819
static const int kNullOddballKind
Definition: v8-internal.h:978
static const int kUndefinedValueRootIndex
Definition: v8-internal.h:952
static const int kExternalTwoByteRepresentationTag
Definition: v8-internal.h:830
static constexpr Address IntToSmi(int value)
Definition: v8-internal.h:1021
static const int kDontThrow
Definition: v8-internal.h:982
static void CheckInitializedImpl(v8::Isolate *isolate)
static void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
Definition: v8-internal.h:1127
static const int kStackGuardSize
Definition: v8-internal.h:834
static const int kNodeStateMask
Definition: v8-internal.h:961
static const int kNodeStateIsWeakValue
Definition: v8-internal.h:962
static const int kFirstJSApiObjectType
Definition: v8-internal.h:969
static const int kStringResourceOffset
Definition: v8-internal.h:807
static const int kErrorMessageParamOffset
Definition: v8-internal.h:858
static const int kExternalPointerTableBasePointerOffset
Definition: v8-internal.h:847
static const int kFalseValueRootIndex
Definition: v8-internal.h:956
static const int kIsolateRegexpExecVectorArgumentOffset
Definition: v8-internal.h:912
static const int kIsolateFastApiCallTargetOffset
Definition: v8-internal.h:878
static const int kTrueValueRootIndex
Definition: v8-internal.h:955
static int GetInstanceType(Address obj)
Definition: v8-internal.h:1061
static const int kThrowOnError
Definition: v8-internal.h:983
static Address ReadTaggedSignedField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1210
static const int kOddballKindOffset
Definition: v8-internal.h:810
static const int kBuiltinTier0TableSize
Definition: v8-internal.h:840
static const int kContinuationPreservedEmbedderDataOffset
Definition: v8-internal.h:914
static Address ReadTaggedPointerField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1199
static const int kNullValueRootIndex
Definition: v8-internal.h:954
static void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
Definition: v8-internal.h:1120
static Address * GetRootSlot(v8::Isolate *isolate, int index)
Definition: v8-internal.h:1140
static const int kTrustedPointerTableSize
Definition: v8-internal.h:849
static const int kTheHoleValueRootIndex
Definition: v8-internal.h:953
static constexpr int SmiValue(Address value)
Definition: v8-internal.h:1012
static const int kTablesAlignmentPaddingSize
Definition: v8-internal.h:837
static const int kHandleScopeDataSize
Definition: v8-internal.h:843
static const int kExternalOneByteRepresentationTag
Definition: v8-internal.h:831
static const int kBuiltinTier0EntryTableSize
Definition: v8-internal.h:839
static void UpdateNodeFlag(Address *obj, bool value, int shift)
Definition: v8-internal.h:1104
static void IncrementLongTasksStatsCounter(v8::Isolate *isolate)
Definition: v8-internal.h:1134
static const int kDisallowGarbageCollectionSize
Definition: v8-internal.h:921
static const int kOldAllocationInfoOffset
Definition: v8-internal.h:867
static const int kIsolateEmbedderDataOffset
Definition: v8-internal.h:886
static T ReadRawField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1183
static const int kEmbedderDataSlotExternalPointerOffset
Definition: v8-internal.h:825
static int GetOddballKind(Address obj)
Definition: v8-internal.h:1078
static const int kNodeFlagsOffset
Definition: v8-internal.h:960
static const int kTrustedPointerTableBasePointerOffset
Definition: v8-internal.h:850
static const int kRegExpStaticResultOffsetsVectorSize
Definition: v8-internal.h:838
static const int kLastEmbedderJSApiObjectType
Definition: v8-internal.h:974
static const int kVariousBooleanFlagsOffset
Definition: v8-internal.h:856
static constexpr std::optional< Address > TryIntegralToSmi(T value)
Definition: v8-internal.h:1039
static const int kNodeClassIdOffset
Definition: v8-internal.h:959
static const int kStringRepresentationAndEncodingMask
Definition: v8-internal.h:828
static const int kJSObjectHeaderSize
Definition: v8-internal.h:811
static v8::Isolate * GetIsolateForSandbox(Address obj)
Definition: v8-internal.h:1220
static const int kJSSpecialApiObjectType
Definition: v8-internal.h:967
Definition: v8-internal.h:1305
StrongRootAllocatorBase(LocalIsolate *isolate)
Definition: v8-internal.h:1337
T value_type
Definition: v8-internal.h:1339
Definition: v8-internal.h:1565
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1625
static T * ReprAsValue(InternalRepresentationType repr)
Definition: v8-internal.h:1641
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1579
static T * SlotAsValue(S *slot)
Definition: v8-internal.h:1630
static T * HandleAsValue(const H< T, Ms... > &handle)
Definition: v8-internal.h:1593
static InternalRepresentationType ValueAsRepr(const T *value)
Definition: v8-internal.h:1635
static bool IsEmpty(T *value)
Definition: v8-internal.h:1584
static constexpr InternalRepresentationType kEmpty
Definition: v8-internal.h:1580
Definition: v8-internal.h:1396
constexpr WrappedIterator & operator-=(difference_type n) noexcept
Definition: v8-internal.h:1542
constexpr WrappedIterator operator--(int) noexcept
Definition: v8-internal.h:1519
constexpr WrappedIterator & operator+=(difference_type n) noexcept
Definition: v8-internal.h:1534
constexpr const Iterator & base() const noexcept
Definition: v8-internal.h:1556
std::conditional_t< std::is_void_v< ElementType >, typename std::iterator_traits< Iterator >::value_type, ElementType > value_type
Definition: v8-internal.h:1410
constexpr WrappedIterator & operator++() noexcept
Definition: v8-internal.h:1505
constexpr pointer operator->() const noexcept
Definition: v8-internal.h:1435
constexpr reference operator[](difference_type n) const noexcept
Definition: v8-internal.h:1551
typename std::iterator_traits< Iterator >::difference_type difference_type
Definition: v8-internal.h:1406
constexpr bool operator!=(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1473
constexpr bool operator>=(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1498
constexpr bool operator<(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1480
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:1418
constexpr WrappedIterator & operator--() noexcept
Definition: v8-internal.h:1515
constexpr WrappedIterator() noexcept=default
constexpr bool operator<=(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1486
constexpr bool operator>(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1492
typename std::iterator_traits< Iterator >::iterator_category iterator_category
Definition: v8-internal.h:1420
constexpr reference operator*() const noexcept
Definition: v8-internal.h:1434
friend constexpr WrappedIterator operator+(difference_type n, const WrappedIterator &x) noexcept
Definition: v8-internal.h:1530
constexpr WrappedIterator operator++(int) noexcept
Definition: v8-internal.h:1509
constexpr WrappedIterator operator-(difference_type n) const noexcept
Definition: v8-internal.h:1538
std::conditional_t< std::is_void_v< ElementType >, typename std::iterator_traits< Iterator >::pointer, std::add_pointer_t< ElementType > > pointer
Definition: v8-internal.h:1414
constexpr bool operator==(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1440
const intptr_t kHeapObjectTagMask
Definition: v8-internal.h:75
constexpr uint64_t kCppHeapPointerMarkBit
Definition: v8-internal.h:381
constexpr int kCodePointerTableEntrySizeLog2
Definition: v8-internal.h:763
constexpr bool kRuntimeGeneratedCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:775
internal::Isolate * IsolateFromNeverReadOnlySpaceObject(Address obj)
constexpr uint64_t kExternalPointerTagShift
Definition: v8-internal.h:481
IndirectPointerHandle TrustedPointerHandle
Definition: v8-internal.h:698
const int kApiSystemPointerSize
Definition: v8-internal.h:65
constexpr bool SandboxIsEnabled()
Definition: v8-internal.h:220
const int kApiDoubleSize
Definition: v8-internal.h:66
constexpr size_t kMaxCppHeapPointers
Definition: v8-internal.h:404
constexpr intptr_t kIntptrAllBitsSet
Definition: v8-internal.h:93
constexpr int GB
Definition: v8-internal.h:57
void VerifyHandleIsNonEmpty(bool is_empty)
const int kApiInt32Size
Definition: v8-internal.h:67
const int kForwardingTagSize
Definition: v8-internal.h:82
uint32_t CppHeapPointerHandle
Definition: v8-internal.h:366
const intptr_t kForwardingTagMask
Definition: v8-internal.h:83
void PrintPropertyCallbackInfo(void *property_callback_info)
IndirectPointerHandle CodePointerHandle
Definition: v8-internal.h:736
const int kSmiTagSize
Definition: v8-internal.h:87
const int kApiInt64Size
Definition: v8-internal.h:68
constexpr uint64_t kExternalPointerTagMask
Definition: v8-internal.h:479
constexpr int kCodePointerTableEntryCodeObjectOffset
Definition: v8-internal.h:771
constexpr int kTrustedPointerTableEntrySizeLog2
Definition: v8-internal.h:715
constexpr int kTrustedPointerTableEntrySize
Definition: v8-internal.h:714
constexpr uint64_t kCppHeapPointerPayloadShift
Definition: v8-internal.h:383
constexpr ExternalPointer_t kNullExternalPointer
Definition: v8-internal.h:358
Address ExternalPointer_t
Definition: v8-internal.h:355
uint32_t IndirectPointerHandle
Definition: v8-internal.h:678
constexpr CppHeapPointer_t kNullCppHeapPointer
Definition: v8-internal.h:378
const int kApiSizetSize
Definition: v8-internal.h:69
constexpr int kCodePointerTableEntryEntrypointOffset
Definition: v8-internal.h:770
constexpr size_t kMaxExternalPointers
Definition: v8-internal.h:336
constexpr uint64_t kExternalPointerTagMaskWithoutMarkBit
Definition: v8-internal.h:480
constexpr size_t kCodePointerTableReservationSize
Definition: v8-internal.h:741
constexpr TrustedPointerHandle kNullTrustedPointerHandle
Definition: v8-internal.h:710
const int kWeakHeapObjectTag
Definition: v8-internal.h:73
constexpr ExternalPointerHandle kNullExternalPointerHandle
Definition: v8-internal.h:359
constexpr uintptr_t kUintptrAllBitsSet
Definition: v8-internal.h:94
const int kForwardingTag
Definition: v8-internal.h:81
const intptr_t kHeapObjectReferenceTagMask
Definition: v8-internal.h:76
constexpr bool SmiValuesAre31Bits()
Definition: v8-internal.h:208
constexpr size_t kMaxTrustedPointers
Definition: v8-internal.h:716
bool ShouldThrowOnError(internal::Isolate *isolate)
constexpr uint64_t kCppHeapPointerTagShift
Definition: v8-internal.h:382
constexpr int KB
Definition: v8-internal.h:55
constexpr uint64_t kAllTagsForAndBasedTypeChecking[]
Definition: v8-internal.h:487
constexpr bool kBuiltinCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:776
constexpr uint32_t kTrustedPointerHandleShift
Definition: v8-internal.h:707
constexpr uint32_t kCodePointerHandleShift
Definition: v8-internal.h:745
const int kHeapObjectTag
Definition: v8-internal.h:72
const int kSmiShiftSize
Definition: v8-internal.h:204
constexpr size_t kMaxCodePointers
Definition: v8-internal.h:764
constexpr bool kHaveIteratorCategory
Definition: v8-internal.h:1359
SmiTagging< kApiTaggedSize > PlatformSmiTagging
Definition: v8-internal.h:199
const int kSmiValueSize
Definition: v8-internal.h:205
constexpr bool SmiValuesAre32Bits()
Definition: v8-internal.h:209
constexpr IndirectPointerHandle kNullIndirectPointerHandle
Definition: v8-internal.h:681
uintptr_t Address
Definition: v8-internal.h:52
void PerformCastCheck(T *data)
Definition: v8-internal.h:1290
void PrintFunctionCallbackInfo(void *function_callback_info)
constexpr size_t kTrustedPointerTableReservationSize
Definition: v8-internal.h:703
uint32_t ExternalPointerHandle
Definition: v8-internal.h:347
const intptr_t kSmiTagMask
Definition: v8-internal.h:88
const int kHeapObjectTagSize
Definition: v8-internal.h:74
const int kSmiMaxValue
Definition: v8-internal.h:207
constexpr bool Is64()
Definition: v8-internal.h:210
constexpr bool kAllCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:777
const int kSmiTag
Definition: v8-internal.h:86
constexpr CodePointerHandle kNullCodePointerHandle
Definition: v8-internal.h:748
Address CppHeapPointer_t
Definition: v8-internal.h:375
constexpr CppHeapPointerHandle kNullCppHeapPointerHandle
Definition: v8-internal.h:379
constexpr int kGarbageCollectionReasonMaxValue
Definition: v8-internal.h:1301
constexpr int kCodePointerTableEntrySize
Definition: v8-internal.h:762
ExternalPointerTag
Definition: v8-internal.h:598
@ kExternalPointerEvacuationEntryTag
Definition: v8-internal.h:611
@ kAccessorInfoGetterTag
Definition: v8-internal.h:616
@ kFirstSharedTag
Definition: v8-internal.h:616
@ kAccessorInfoSetterTag
Definition: v8-internal.h:616
@ kAnyForeignTag
Definition: v8-internal.h:605
@ kExternalPointerFreeEntryTag
Definition: v8-internal.h:609
@ kAnyExternalPointerTag
Definition: v8-internal.h:602
@ kLastSharedTag
Definition: v8-internal.h:616
@ kExternalPointerNullTag
Definition: v8-internal.h:600
@ kLastManagedResourceTag
Definition: v8-internal.h:616
@ kExternalPointerZappedEntryTag
Definition: v8-internal.h:614
@ kFirstManagedResourceTag
Definition: v8-internal.h:616
@ kFunctionTemplateInfoCallbackTag
Definition: v8-internal.h:616
constexpr uint32_t kCodePointerHandleMarker
Definition: v8-internal.h:757
const int kSmiMinValue
Definition: v8-internal.h:206
constexpr bool kHaveIteratorConcept
Definition: v8-internal.h:1353
constexpr int MB
Definition: v8-internal.h:56
constexpr uint64_t kExternalPointerMarkBit
Definition: v8-internal.h:478
Address SandboxedPointer_t
Definition: v8-internal.h:230
const int kApiTaggedSize
Definition: v8-internal.h:189
constexpr bool PointerCompressionIsEnabled()
Definition: v8-internal.h:192
Definition: libplatform.h:15
Definition: v8-internal.h:1274
static void Perform(T *data)
Definition: v8-internal.h:1368
static constexpr bool IsValidSmi(uint64_t value)
Definition: v8-internal.h:141
static constexpr bool IsValidSmi(int64_t value)
Definition: v8-internal.h:134
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:114
static constexpr int SmiToInt(Address value)
Definition: v8-internal.h:106
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:164
static constexpr int SmiToInt(Address value)
Definition: v8-internal.h:156
Definition: v8-internal.h:91
#define EXTERNAL_POINTER_TAG_ENUM(Name, Tag)
Definition: v8-internal.h:594
#define ALL_EXTERNAL_POINTER_TAGS(V)
Definition: v8-internal.h:590
#define CHECK_NON_SHARED_EXTERNAL_POINTER_TAGS(Tag,...)
Definition: v8-internal.h:652
#define SHARED_EXTERNAL_POINTER_TAGS(V)
Definition: v8-internal.h:515
#define MAKE_TAG(HasMarkBit, TypeTag)
Definition: v8-internal.h:595
#define PER_ISOLATE_EXTERNAL_POINTER_TAGS(V)
Definition: v8-internal.h:525
#define CHECK_SHARED_EXTERNAL_POINTER_TAGS(Tag,...)
Definition: v8-internal.h:650
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_LIKELY(condition)
Definition: v8config.h:650