Loading...
Searching...
No Matches
v8-internal.h
Go to the documentation of this file.
1// Copyright 2018 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_INTERNAL_H_
6#define INCLUDE_V8_INTERNAL_H_
7
8#include <stddef.h>
9#include <stdint.h>
10#include <string.h>
11
12#include <atomic>
13#include <compare>
14#include <concepts>
15#include <iterator>
16#include <limits>
17#include <memory>
18#include <optional>
19#include <type_traits>
20
21#include "v8config.h" // NOLINT(build/include_directory)
22
23namespace v8 {
24
25class Array;
26class Context;
27class Data;
28class Isolate;
29
30namespace internal {
31
32class Heap;
33class LocalHeap;
34class Isolate;
35class IsolateGroup;
36class LocalIsolate;
37
38typedef uintptr_t Address;
39static constexpr Address kNullAddress = 0;
40
41constexpr int KB = 1024;
42constexpr int MB = KB * 1024;
43constexpr int GB = MB * 1024;
44#ifdef V8_TARGET_ARCH_X64
45constexpr size_t TB = size_t{GB} * 1024;
46#endif
47
51const int kApiSystemPointerSize = sizeof(void*);
52const int kApiDoubleSize = sizeof(double);
53const int kApiInt32Size = sizeof(int32_t);
54const int kApiInt64Size = sizeof(int64_t);
55const int kApiSizetSize = sizeof(size_t);
56
57// Tag information for HeapObject.
58const int kHeapObjectTag = 1;
59const int kWeakHeapObjectTag = 3;
60const int kHeapObjectTagSize = 2;
61const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
63
64// Tag information for fowarding pointers stored in object headers.
65// 0b00 at the lowest 2 bits in the header indicates that the map word is a
66// forwarding pointer.
67const int kForwardingTag = 0;
68const int kForwardingTagSize = 2;
69const intptr_t kForwardingTagMask = (1 << kForwardingTagSize) - 1;
70
71// Tag information for Smi.
72const int kSmiTag = 0;
73const int kSmiTagSize = 1;
74const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
75
76template <size_t tagged_ptr_size>
78
79constexpr intptr_t kIntptrAllBitsSet = intptr_t{-1};
80constexpr uintptr_t kUintptrAllBitsSet =
81 static_cast<uintptr_t>(kIntptrAllBitsSet);
82
83// Smi constants for systems where tagged pointer is a 32-bit value.
84template <>
85struct SmiTagging<4> {
86 enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
87
88 static constexpr intptr_t kSmiMinValue =
89 static_cast<intptr_t>(kUintptrAllBitsSet << (kSmiValueSize - 1));
90 static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1);
91
92 V8_INLINE static constexpr int SmiToInt(Address value) {
93 int shift_bits = kSmiTagSize + kSmiShiftSize;
94 // Truncate and shift down (requires >> to be sign extending).
95 return static_cast<int32_t>(static_cast<uint32_t>(value)) >> shift_bits;
96 }
97
98 template <class T, typename std::enable_if_t<std::is_integral_v<T> &&
99 std::is_signed_v<T>>* = nullptr>
100 V8_INLINE static constexpr bool IsValidSmi(T value) {
101 // Is value in range [kSmiMinValue, kSmiMaxValue].
102 // Use unsigned operations in order to avoid undefined behaviour in case of
103 // signed integer overflow.
104 return (static_cast<uintptr_t>(value) -
105 static_cast<uintptr_t>(kSmiMinValue)) <=
106 (static_cast<uintptr_t>(kSmiMaxValue) -
107 static_cast<uintptr_t>(kSmiMinValue));
108 }
109
110 template <class T,
111 typename std::enable_if_t<std::is_integral_v<T> &&
112 std::is_unsigned_v<T>>* = nullptr>
113 V8_INLINE static constexpr bool IsValidSmi(T value) {
114 static_assert(kSmiMaxValue <= std::numeric_limits<uintptr_t>::max());
115 return value <= static_cast<uintptr_t>(kSmiMaxValue);
116 }
117
118 // Same as the `intptr_t` version but works with int64_t on 32-bit builds
119 // without slowing down anything else.
120 V8_INLINE static constexpr bool IsValidSmi(int64_t value) {
121 return (static_cast<uint64_t>(value) -
122 static_cast<uint64_t>(kSmiMinValue)) <=
123 (static_cast<uint64_t>(kSmiMaxValue) -
124 static_cast<uint64_t>(kSmiMinValue));
125 }
126
127 V8_INLINE static constexpr bool IsValidSmi(uint64_t value) {
128 static_assert(kSmiMaxValue <= std::numeric_limits<uint64_t>::max());
129 return value <= static_cast<uint64_t>(kSmiMaxValue);
130 }
131};
132
133// Smi constants for systems where tagged pointer is a 64-bit value.
134template <>
135struct SmiTagging<8> {
136 enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
137
138 static constexpr intptr_t kSmiMinValue =
139 static_cast<intptr_t>(kUintptrAllBitsSet << (kSmiValueSize - 1));
140 static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1);
141
142 V8_INLINE static constexpr int SmiToInt(Address value) {
143 int shift_bits = kSmiTagSize + kSmiShiftSize;
144 // Shift down and throw away top 32 bits.
145 return static_cast<int>(static_cast<intptr_t>(value) >> shift_bits);
146 }
147
148 template <class T, typename std::enable_if_t<std::is_integral_v<T> &&
149 std::is_signed_v<T>>* = nullptr>
150 V8_INLINE static constexpr bool IsValidSmi(T value) {
151 // To be representable as a long smi, the value must be a 32-bit integer.
152 return std::numeric_limits<int32_t>::min() <= value &&
153 value <= std::numeric_limits<int32_t>::max();
154 }
155
156 template <class T,
157 typename std::enable_if_t<std::is_integral_v<T> &&
158 std::is_unsigned_v<T>>* = nullptr>
159 V8_INLINE static constexpr bool IsValidSmi(T value) {
160 return value <= std::numeric_limits<int32_t>::max();
161 }
162};
163
164#ifdef V8_COMPRESS_POINTERS
165// See v8:7703 or src/common/ptr-compr-inl.h for details about pointer
166// compression.
167constexpr size_t kPtrComprCageReservationSize = size_t{1} << 32;
168constexpr size_t kPtrComprCageBaseAlignment = size_t{1} << 32;
169
170static_assert(
172 "Pointer compression can be enabled only for 64-bit architectures");
173const int kApiTaggedSize = kApiInt32Size;
174#else
176#endif
177
180}
181
182#ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
183using PlatformSmiTagging = SmiTagging<kApiInt32Size>;
184#else
186#endif
187
188// TODO(ishell): Consinder adding kSmiShiftBits = kSmiShiftSize + kSmiTagSize
189// since it's used much more often than the inividual constants.
190const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
191const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
192const int kSmiMinValue = static_cast<int>(PlatformSmiTagging::kSmiMinValue);
193const int kSmiMaxValue = static_cast<int>(PlatformSmiTagging::kSmiMaxValue);
194constexpr bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
195constexpr bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
196constexpr bool Is64() { return kApiSystemPointerSize == sizeof(int64_t); }
197
198V8_INLINE static constexpr Address IntToSmi(int value) {
199 return (static_cast<Address>(value) << (kSmiTagSize + kSmiShiftSize)) |
200 kSmiTag;
201}
202
203/*
204 * Sandbox related types, constants, and functions.
205 */
206constexpr bool SandboxIsEnabled() {
207#ifdef V8_ENABLE_SANDBOX
208 return true;
209#else
210 return false;
211#endif
212}
213
214// SandboxedPointers are guaranteed to point into the sandbox. This is achieved
215// for example by storing them as offset rather than as raw pointers.
217
218#ifdef V8_ENABLE_SANDBOX
219
220// Size of the sandbox, excluding the guard regions surrounding it.
221#if defined(V8_TARGET_OS_ANDROID)
222// On Android, most 64-bit devices seem to be configured with only 39 bits of
223// virtual address space for userspace. As such, limit the sandbox to 128GB (a
224// quarter of the total available address space).
225constexpr size_t kSandboxSizeLog2 = 37; // 128 GB
226#elif defined(V8_TARGET_OS_IOS)
227// On iOS, we only get 64 GB of usable virtual address space even with the
228// "jumbo" extended virtual addressing entitlement. Limit the sandbox size to
229// 16 GB so that the base address + size for the emulated virtual address space
230// lies within the 64 GB total virtual address space.
231constexpr size_t kSandboxSizeLog2 = 34; // 16 GB
232#elif defined(V8_HOST_ARCH_RISCV64)
233// Most RISC-V hardware currently uses Sv39 (39-bit VA, 256GB userspace).
234// Limit the sandbox to 128GB (a quarter of Sv39 userspace) to avoid exceeding
235// the available virtual address space. Uses V8_HOST_ARCH so that simulator
236// builds on x64 are not unnecessarily constrained.
237constexpr size_t kSandboxSizeLog2 = 37; // 128 GB
238#elif defined(V8_TARGET_ARCH_LOONG64)
239// Some hardwares like 2k3000 only have 40-bit virtual address space, 39 bits
240// userspace and kernel each.
241constexpr size_t kSandboxSizeLog2 = 37; // 128 GB
242#else
243// Everywhere else use a 1TB sandbox.
244constexpr size_t kSandboxSizeLog2 = 40; // 1 TB
245#endif // V8_TARGET_OS_ANDROID
246constexpr size_t kSandboxSize = 1ULL << kSandboxSizeLog2;
247
248// Required alignment of the sandbox. For simplicity, we require the
249// size of the guard regions to be a multiple of this, so that this specifies
250// the alignment of the sandbox including and excluding surrounding guard
251// regions. The alignment requirement is due to the pointer compression cage
252// being located at the start of the sandbox.
253constexpr size_t kSandboxAlignment = kPtrComprCageBaseAlignment;
254
255// Sandboxed pointers are stored inside the heap as offset from the sandbox
256// base shifted to the left. This way, it is guaranteed that the offset is
257// smaller than the sandbox size after shifting it to the right again. This
258// constant specifies the shift amount.
259constexpr uint64_t kSandboxedPointerShift = 64 - kSandboxSizeLog2;
260
261// On OSes where reserving virtual memory is too expensive to reserve the
262// entire address space backing the sandbox, notably Windows pre 8.1, we create
263// a partially reserved sandbox that doesn't actually reserve most of the
264// memory, and so doesn't have the desired security properties as unrelated
265// memory allocations could end up inside of it, but which still ensures that
266// objects that should be located inside the sandbox are allocated within
267// kSandboxSize bytes from the start of the sandbox. The minimum size of the
268// region that is actually reserved for such a sandbox is specified by this
269// constant and should be big enough to contain the pointer compression cage as
270// well as the ArrayBuffer partition.
271constexpr size_t kSandboxMinimumReservationSize = 8ULL * GB;
272
273static_assert(kSandboxMinimumReservationSize > kPtrComprCageReservationSize,
274 "The minimum reservation size for a sandbox must be larger than "
275 "the pointer compression cage contained within it.");
276
277// The maximum buffer size allowed inside the sandbox. This is mostly dependent
278// on the size of the guard regions around the sandbox: an attacker must not be
279// able to construct a buffer that appears larger than the guard regions and
280// thereby "reach out of" the sandbox.
281constexpr size_t kMaxSafeBufferSizeForSandbox = 32ULL * GB - 1;
282
283constexpr size_t kBoundedSizeShift = 29;
284static_assert(1ULL << (64 - kBoundedSizeShift) ==
285 kMaxSafeBufferSizeForSandbox + 1,
286 "The maximum size of a BoundedSize must be synchronized with the "
287 "kMaxSafeBufferSizeForSandbox");
288constexpr size_t kBoundedSizeMask = (1ULL << (64 - kBoundedSizeShift)) - 1;
289
290// Size of the guard regions surrounding the sandbox. This assumes a worst-case
291// scenario of a 32-bit unsigned index used to access an array of 64-bit values
292// with an additional 32GB (bounded size) offset. In particular, accesses to
293// TypedArrays are effectively computed as
294// `entry_pointer = array->base + array->offset + index * array->element_size`.
295// See also https://crbug.com/40070746 for more details.
296constexpr size_t kSandboxGuardRegionSize =
297 32ULL * GB + (kMaxSafeBufferSizeForSandbox + 1);
298
299static_assert((kSandboxGuardRegionSize % kSandboxAlignment) == 0,
300 "The size of the guard regions around the sandbox must be a "
301 "multiple of its required alignment.");
302static_assert(kMaxSafeBufferSizeForSandbox <= kSandboxGuardRegionSize,
303 "The maximum allowed buffer size must not be larger than the "
304 "sandbox's guard regions");
305
306#if defined(V8_TARGET_OS_ANDROID)
307// On Android, we often won't have sufficient virtual address space available.
308constexpr size_t kAdditionalTrailingGuardRegionSize = 0;
309#else
310// Worst-case, we need 8 (max element size) * 32GB (max ArrayBuffer size) +
311// 32GB (additional bounded size offset for TypedArray access).
312constexpr size_t kAdditionalTrailingGuardRegionSize =
313 288ULL * GB - kSandboxGuardRegionSize;
314#endif
315
316constexpr bool kRequiresTypedArrayAccessMasks =
317 kAdditionalTrailingGuardRegionSize == 0;
318
319#endif // V8_ENABLE_SANDBOX
320
321#ifdef V8_COMPRESS_POINTERS
322
323#ifdef V8_TARGET_OS_ANDROID
324// The size of the virtual memory reservation for an external pointer table.
325// This determines the maximum number of entries in a table. Using a maximum
326// size allows omitting bounds checks on table accesses if the indices are
327// guaranteed (e.g. through shifting) to be below the maximum index. This
328// value must be a power of two.
329constexpr size_t kExternalPointerTableReservationSize = 256 * MB;
330
331// The external pointer table indices stored in HeapObjects as external
332// pointers are shifted to the left by this amount to guarantee that they are
333// smaller than the maximum table size even after the C++ compiler multiplies
334// them by 8 to be used as indexes into a table of 64 bit pointers.
335constexpr uint32_t kExternalPointerIndexShift = 7;
336#elif defined(V8_TARGET_OS_IOS)
337// iOS restricts large memory allocations, with 128 MB being the maximum size we
338// can configure. If we exceed this, SegmentedTable::Initialize will throw a V8
339// out-of-memory error when running the JetStream benchmark
340// (https://browserbench.org/JetStream/).
341constexpr size_t kExternalPointerTableReservationSize = 128 * MB;
342constexpr uint32_t kExternalPointerIndexShift = 8;
343#else
344constexpr size_t kExternalPointerTableReservationSize = 512 * MB;
345constexpr uint32_t kExternalPointerIndexShift = 6;
346#endif // V8_TARGET_OS_ANDROID
347
348// The byte size of an entry in an external pointer table.
349constexpr int kExternalPointerTableEntrySize = 8;
350constexpr int kExternalPointerTableEntrySizeLog2 = 3;
351// The maximum number of entries in an external pointer table.
352constexpr size_t kMaxExternalPointers =
353 kExternalPointerTableReservationSize / kExternalPointerTableEntrySize;
354static_assert((1 << (32 - kExternalPointerIndexShift)) == kMaxExternalPointers,
355 "kExternalPointerTableReservationSize and "
356 "kExternalPointerIndexShift don't match");
357
358#else // !V8_COMPRESS_POINTERS
359
360// Needed for the V8.SandboxedExternalPointersCount histogram.
361constexpr size_t kMaxExternalPointers = 0;
362
363#endif // V8_COMPRESS_POINTERS
364
365constexpr uint64_t kExternalPointerMarkBit = 1ULL << 48;
366constexpr uint64_t kExternalPointerTagShift = 49;
367constexpr uint64_t kExternalPointerTagMask = 0x00fe000000000000ULL;
372constexpr uint64_t kExternalPointerTagAndMarkbitMask = 0x00ff000000000000ULL;
373constexpr uint64_t kExternalPointerPayloadMask = 0xff00ffffffffffffULL;
374
375// A ExternalPointerHandle represents a (opaque) reference to an external
376// pointer that can be stored inside the sandbox. A ExternalPointerHandle has
377// meaning only in combination with an (active) Isolate as it references an
378// external pointer stored in the currently active Isolate's
379// ExternalPointerTable. Internally, an ExternalPointerHandles is simply an
380// index into an ExternalPointerTable that is shifted to the left to guarantee
381// that it is smaller than the size of the table.
382using ExternalPointerHandle = uint32_t;
383
384// ExternalPointers point to objects located outside the sandbox. When the V8
385// sandbox is enabled, these are stored on heap as ExternalPointerHandles,
386// otherwise they are simply raw pointers.
387#ifdef V8_ENABLE_SANDBOX
389#else
391#endif
392
395
396// See `ExternalPointerHandle` for the main documentation. The difference to
397// `ExternalPointerHandle` is that the handle does not represent an arbitrary
398// external pointer but always refers to an object managed by `CppHeap`. The
399// handles are using in combination with a dedicated table for `CppHeap`
400// references.
401using CppHeapPointerHandle = uint32_t;
402
403// The actual pointer to objects located on the `CppHeap`. When pointer
404// compression is enabled these pointers are stored as `CppHeapPointerHandle`.
405// In non-compressed configurations the pointers are simply stored as raw
406// pointers.
407#ifdef V8_COMPRESS_POINTERS
409#else
411#endif
412
415
416constexpr uint64_t kCppHeapPointerMarkBit = 1ULL;
417constexpr uint64_t kCppHeapPointerTagShift = 1;
418constexpr uint64_t kCppHeapPointerPayloadShift = 16;
419
420#ifdef V8_COMPRESS_POINTERS
421// CppHeapPointers use a dedicated pointer table. These constants control the
422// size and layout of the table. See the corresponding constants for the
423// external pointer table for further details.
424constexpr size_t kCppHeapPointerTableReservationSize =
425 kExternalPointerTableReservationSize;
426constexpr uint32_t kCppHeapPointerIndexShift = kExternalPointerIndexShift;
427
428constexpr int kCppHeapPointerTableEntrySize = 8;
429constexpr int kCppHeapPointerTableEntrySizeLog2 = 3;
430constexpr size_t kMaxCppHeapPointers =
431 kCppHeapPointerTableReservationSize / kCppHeapPointerTableEntrySize;
432static_assert((1 << (32 - kCppHeapPointerIndexShift)) == kMaxCppHeapPointers,
433 "kCppHeapPointerTableReservationSize and "
434 "kCppHeapPointerIndexShift don't match");
435
436#else // !V8_COMPRESS_POINTERS
437
438// Needed for the V8.SandboxedCppHeapPointersCount histogram.
439constexpr size_t kMaxCppHeapPointers = 0;
440
441#endif // V8_COMPRESS_POINTERS
442
443// The number of tags reserved for embedder data stored in internal fields. The
444// value is picked arbitrarily, and is slightly larger than the number of tags
445// currently used in Chrome.
446#define V8_EMBEDDER_DATA_TAG_COUNT 15
447
448// The number of tags reserved for pointers stored in v8::External. The value is
449// picked arbitrarily, and is slightly larger than the number of tags currently
450// used in Chrome.
451#define V8_EXTERNAL_POINTER_TAG_COUNT 40
452
453// Generic tag range struct to represent ranges of type tags.
454//
455// When referencing external objects via pointer tables, type tags are
456// frequently necessary to guarantee type safety for the external objects. When
457// support for subtyping is necessary, range-based type checks are used in
458// which all subtypes of a given supertype use contiguous tags. This struct can
459// then be used to represent such a type range.
460//
461// As an example, consider the following type hierarchy:
462//
463// A F
464// / \
465// B E
466// / \
467// C D
468//
469// A potential type id assignment for range-based type checks is
470// {A: 0, B: 1, C: 2, D: 3, E: 4, F: 5}. With that, the type check for type A
471// would check for the range [A, E], while the check for B would check range
472// [B, D], and for F it would simply check [F, F].
473//
474// In addition, there is an option for performance tweaks: if the size of the
475// type range corresponding to a supertype is a power of two and starts at a
476// power of two (e.g. [0x100, 0x13f]), then the compiler can often optimize
477// the type check to use even fewer instructions (essentially replace a AND +
478// SUB with a single AND).
479//
480// Tag ranges can also to a limited degree be used for union types. For
481// example, with the type graph as above, it would be possible to specify a
482// Union(D, E, F) as the tag range [D, F]. However, this only works as long as
483// the (otherwise independent) types that form the union have adjacent tags.
484//
485//
486// There are broadly speaking two options for performing the type check when
487// given the expected type range and the actual tag of the entry.
488//
489// The first option is to simply have the equivalent of
490//
491// CHECK(expected_tag_range.Contains(actual_tag))
492//
493// This is nice and simple, and friendly to both the branch-predictor and the
494// user/developer as it produces clear error messages. However, this approach
495// may result in quite a bit of code being generated, for example for calling
496// RuntimeAbort from generated code or similar.
497//
498// The second option is to generate code such as
499//
500// if (!expected_tag_range.Contains(actual_tag)) return nullptr;
501//
502// With this, we are also guaranteed to crash safely when the returned pointer
503// is used, but this may result in significantly less code being generated, for
504// example because the compiler can implement this with a single conditional
505// select in combination with the zero register (e.g. on Arm).
506//
507// The choice of which approach to use therefore depends on the use case, the
508// performance and code size constraints, and the importance of debuggability.
509template <typename Tag>
510struct TagRange {
511 static_assert(std::is_enum_v<Tag> &&
512 std::is_same_v<std::underlying_type_t<Tag>, uint16_t>,
513 "Tag parameter must be an enum with base type uint16_t");
514
515 // Construct the inclusive tag range [first, last].
516 constexpr TagRange(Tag first, Tag last) : first(first), last(last) {
517#ifdef V8_ENABLE_CHECKS
518 // This would typically be a DCHECK, but that's not available here.
519 if (first > last) __builtin_unreachable(); // Invalid tag range.
520#endif
521 }
522
523 // Construct a tag range consisting of a single tag.
524 //
525 // A single tag is always implicitly convertible to a tag range. This greatly
526 // increases readability as most of the time, the exact tag of a field is
527 // known and so no tag range needs to explicitly be created for it.
528 constexpr TagRange(Tag tag) // NOLINT(runtime/explicit)
529 : first(tag), last(tag) {}
530
531 // Construct an empty tag range.
532 constexpr TagRange() : TagRange(static_cast<Tag>(0)) {}
533
534 // A tag range is considered empty if it only contains the null tag.
535 constexpr bool IsEmpty() const { return first == 0 && last == 0; }
536
537 constexpr size_t Size() const {
538 if (IsEmpty()) {
539 return 0;
540 } else {
541 return last - first + 1;
542 }
543 }
544
545 constexpr bool Contains(Tag tag) const {
546 // Need to perform the math with uint32_t. Otherwise, the uint16_ts would
547 // be promoted to (signed) int, allowing the compiler to (wrongly) assume
548 // that an underflow cannot happen as that would be undefined behavior.
549 return static_cast<uint32_t>(tag) - static_cast<uint32_t>(first) <=
550 static_cast<uint32_t>(last) - static_cast<uint32_t>(first);
551 }
552
553 constexpr bool Contains(TagRange tag_range) const {
554 return tag_range.first >= first && tag_range.last <= last;
555 }
556
557 constexpr bool operator==(const TagRange other) const {
558 return first == other.first && last == other.last;
559 }
560
561 constexpr size_t hash_value() const {
562 static_assert(std::is_same_v<std::underlying_type_t<Tag>, uint16_t>);
563 return (static_cast<size_t>(first) << 16) | last;
564 }
565
566 // Internally we represent tag ranges as closed ranges [first, last].
567 Tag first;
568 Tag last;
569};
570
571#define SHARED_MANAGED_TAG_LIST(V) V(WasmFutexManagedObjectWaitListTag)
572
573#define MANAGED_TAG_LIST(V) \
574 SHARED_MANAGED_TAG_LIST(V) \
575 V(GenericManagedTag) \
576 V(WasmWasmStreamingTag) \
577 V(WasmFuncDataTag) \
578 V(WasmManagedDataTag) \
579 V(WasmNativeModuleTag) \
580 V(WasmInterpreterHandleTag) \
581 V(BackingStoreTag) \
582 V(IcuBreakIteratorTag) \
583 V(IcuListFormatterTag) \
584 V(IcuLocaleTag) \
585 V(IcuSimpleDateFormatTag) \
586 V(IcuDateIntervalFormatTag) \
587 V(IcuRelativeDateTimeFormatterTag) \
588 V(IcuLocalizedNumberFormatterTag) \
589 V(IcuPluralRulesTag) \
590 V(IcuCollatorTag) \
591 V(IcuBreakIteratorWithTextTag) \
592 V(TemporalDurationTag) \
593 V(TemporalInstantTag) \
594 V(TemporalPlainDateTag) \
595 V(TemporalPlainTimeTag) \
596 V(TemporalPlainDateTimeTag) \
597 V(TemporalPlainYearMonthTag) \
598 V(TemporalPlainMonthDayTag) \
599 V(TemporalZonedDateTimeTag) \
600 V(DisplayNamesInternalTag) \
601 V(D8WorkerTag) \
602 V(D8ModuleEmbedderDataTag)
603
604#define FOREIGN_TAG_LIST(V) \
605 V(GenericForeignTag) \
606 V(ApiAccessCheckCallbackTag) \
607 V(ApiAbortScriptExecutionCallbackTag) \
608 V(ApiTemporalHostSystemUTCEpochNanosecondsCallbackTag) \
609 V(CFunctionTag) \
610 V(SyntheticModuleTag) \
611 V(MicrotaskCallbackTag) \
612 V(MicrotaskCallbackDataTag) \
613 V(MessageListenerTag) \
614 V(WaiterQueueForeignTag) \
615 /* Needs to stay last to form a range for resources. */ \
616 MANAGED_TAG_LIST(V)
617
618//
619// External Pointers.
620//
621// When the sandbox is enabled, external pointers are stored in an external
622// pointer table and are referenced from HeapObjects through an index (a
623// "handle"). When stored in the table, the pointers are tagged with per-type
624// tags to prevent type confusion attacks between different external objects.
625//
626// When loading an external pointer, a range of allowed tags can be specified.
627// This way, type hierarchies can be supported. The main requirement for that
628// is that all (transitive) child classes of a given parent class have type ids
629// in the same range, and that there are no unrelated types in that range. For
630// more details about how to assign type tags to types, see the TagRange class.
631//
632// The external pointer sandboxing mechanism ensures that every access to an
633// external pointer field will result in a valid pointer of the expected type
634// even in the presence of an attacker able to corrupt memory inside the
635// sandbox. However, if any data related to the external object is stored
636// inside the sandbox it may still be corrupted and so must be validated before
637// use or moved into the external object. Further, an attacker will always be
638// able to substitute different external pointers of the same type for each
639// other. Therefore, code using external pointers must be written in a
640// "substitution-safe" way, i.e. it must always be possible to substitute
641// external pointers of the same type without causing memory corruption outside
642// of the sandbox. Generally this is achieved by referencing any group of
643// related external objects through a single external pointer.
644//
645// Currently we use bit 62 for the marking bit which should always be unused as
646// it's part of the non-canonical address range. When Arm's top-byte ignore
647// (TBI) is enabled, this bit will be part of the ignored byte, and we assume
648// that the Embedder is not using this byte (really only this one bit) for any
649// other purpose. This bit also does not collide with the memory tagging
650// extension (MTE) which would use bits [56, 60).
651//
652// External pointer tables are also available even when the sandbox is off but
653// pointer compression is on. In that case, the mechanism can be used to ease
654// alignment requirements as it turns unaligned 64-bit raw pointers into
655// aligned 32-bit indices. To "opt-in" to the external pointer table mechanism
656// for this purpose, instead of using the ExternalPointer accessors one needs to
657// use ExternalPointerHandles directly and use them to access the pointers in an
658// ExternalPointerTable.
659//
660// The tag is currently in practice limited to 15 bits since it needs to fit
661// together with a marking bit into the unused parts of a pointer.
662enum ExternalPointerTag : uint16_t {
665
666 // When adding new tags, please ensure that the code using these tags is
667 // "substitution-safe", i.e. still operate safely if external pointers of the
668 // same type are swapped by an attacker. See comment above for more details.
669
670 // Shared external pointers are owned by the shared Isolate and stored in the
671 // shared external pointer table associated with that Isolate, where they can
672 // be accessed from multiple threads at the same time. The objects referenced
673 // in this way must therefore always be thread-safe.
679
680 // External pointers using these tags are kept in a per-Isolate external
681 // pointer table and can only be accessed when this Isolate is active.
683
684 // Placeholders for embedder data.
687
688 // Placeholders for pointers store in v8::External.
692 // This tag is used when a fast-api callback as a parameter of type
693 // `kPointer`. The V8 fast API is only able to use this generic tag, and is
694 // therefore not supposed to be used in Chrome.
700
701 // InterceptorInfo external pointers.
720
722
724
725#define AS_ENUM(name) k##name,
727
728#undef AS_ENUM
729
730 // External resources whose lifetime is tied to their entry in the
731 // external pointer table but which are not referenced via a Managed
738 // The tags are limited to 7 bits, so the last tag is 0x7f.
741
742constexpr const char* ToString(ExternalPointerTag tag) {
743 switch (tag) {
744#define ENUM_CASE(name) \
745 case ExternalPointerTag::k##name: \
746 return #name;
747
749
750#undef ENUM_CASE
751 default:
752 return "Unknown tag";
753 }
755
756using ExternalPointerTagRange = TagRange<ExternalPointerTag>;
757
758#define AS_LIST(name) ExternalPointerTag::k##name,
759
760#define GET_FIRST(LIST) \
761 []() { \
762 ExternalPointerTag items[] = {LIST(AS_LIST)}; \
763 return items[0]; \
764 }()
765
766#define GET_LAST(LIST) \
767 []() { \
768 ExternalPointerTag items[] = {LIST(AS_LIST)}; \
769 return items[(sizeof(items) / sizeof(items[0])) - 1]; \
770 }()
774
784
791
798// kLastManagedResourceTag defined in the enum.
801
809
810#undef AS_LIST
811#undef GET_FIRST
812#undef GET_LAST
813
814// True if the external pointer must be accessed from the shared isolate's
815// external pointer table.
816V8_INLINE static constexpr bool IsSharedExternalPointerType(
817 ExternalPointerTagRange tag_range) {
818 // This range should only be used together with
819 // kAnySharedManagedExternalPointerTagRange in this predicate. Therefore
820 // it is defined in this scope.
821 constexpr ExternalPointerTagRange kAnySharedExternalPointerTagRange(
823 return kAnySharedExternalPointerTagRange.Contains(tag_range) ||
825}
826
827// True if the external pointer may live in a read-only object, in which case
828// the table entry will be in the shared read-only segment of the external
829// pointer table.
830V8_INLINE static constexpr bool IsMaybeReadOnlyExternalPointerType(
831 ExternalPointerTagRange tag_range) {
833}
834
835// True if the external pointer references an external object whose lifetime is
836// tied to the entry in the external pointer table.
837// In this case, the entry in the ExternalPointerTable always points to an
838// object derived from ExternalPointerTable::ManagedResource.
839V8_INLINE static constexpr bool IsManagedExternalPointerType(
840 ExternalPointerTagRange tag_range) {
842}
843
844// When an external poiner field can contain the null external pointer handle,
845// the type checking mechanism needs to also check for null.
846// TODO(saelo): this is mostly a temporary workaround to introduce range-based
847// type checks. In the future, we should either (a) change the type tagging
848// scheme so that null always passes or (b) (more likely) introduce dedicated
849// null entries for those tags that need them (similar to other well-known
850// empty value constants such as the empty fixed array).
851V8_INLINE static constexpr bool ExternalPointerCanBeEmpty(
852 ExternalPointerTagRange tag_range) {
853 return tag_range.Contains(kArrayBufferExtensionTag) ||
854 (tag_range.first <= kLastEmbedderDataTag &&
855 kFirstEmbedderDataTag <= tag_range.last) ||
857}
858
859// Indirect Pointers.
860//
861// When the sandbox is enabled, indirect pointers are used to reference
862// HeapObjects that live outside of the sandbox (but are still managed by V8's
863// garbage collector). When object A references an object B through an indirect
864// pointer, object A will contain a IndirectPointerHandle, i.e. a shifted
865// 32-bit index, which identifies an entry in a pointer table (either the
866// trusted pointer table for TrustedObjects, or the code pointer table if it is
867// a Code object). This table entry then contains the actual pointer to object
868// B. Further, object B owns this pointer table entry, and it is responsible
869// for updating the "self-pointer" in the entry when it is relocated in memory.
870// This way, in contrast to "normal" pointers, indirect pointers never need to
871// be tracked by the GC (i.e. there is no remembered set for them).
872// These pointers do not exist when the sandbox is disabled.
873
874// An IndirectPointerHandle represents a 32-bit index into a pointer table.
875using IndirectPointerHandle = uint32_t;
876
877// A null handle always references an entry that contains nullptr.
879
880// When the sandbox is enabled, indirect pointers are used to implement:
881// - TrustedPointers: an indirect pointer using the trusted pointer table (TPT)
882// and referencing a TrustedObject in one of the trusted heap spaces.
883// - CodePointers, an indirect pointer using the code pointer table (CPT) and
884// referencing a Code object together with its instruction stream.
885
886//
887// Trusted Pointers.
888//
889// A pointer to a TrustedObject.
890// When the sandbox is enabled, these are indirect pointers using the trusted
891// pointer table (TPT). They are used to reference trusted objects (located in
892// one of V8's trusted heap spaces, outside of the sandbox) from inside the
893// sandbox in a memory-safe way. When the sandbox is disabled, these are
894// regular tagged pointers.
897// The size of the virtual memory reservation for the trusted pointer table.
898// As with the external pointer table, a maximum table size in combination with
899// shifted indices allows omitting bounds checks.
901
902// The trusted pointer handles are stored shifted to the left by this amount
903// to guarantee that they are smaller than the maximum table size.
904constexpr uint32_t kTrustedPointerHandleShift = 9;
905
906// A null handle always references an entry that contains nullptr.
909
910// The byte size of an entry in the trusted pointer table.
911constexpr int kTrustedPointerTableEntrySize = 8;
912constexpr int kTrustedPointerTableEntrySizeLog2 = 3;
913// The maximum number of entries in the trusted pointer table.
914constexpr size_t kMaxTrustedPointers =
916static_assert((1 << (32 - kTrustedPointerHandleShift)) == kMaxTrustedPointers,
917 "kTrustedPointerTableReservationSize and "
918 "kTrustedPointerHandleShift don't match");
919
920//
921// Code Pointers.
922//
923// A pointer to a Code object.
924// Essentially a specialized version of a trusted pointer that (when the
925// sandbox is enabled) uses the code pointer table (CPT) instead of the TPT.
926// Each entry in the CPT contains both a pointer to a Code object as well as a
927// pointer to the Code's entrypoint. This allows calling/jumping into Code with
928// one fewer memory access (compared to the case where the entrypoint pointer
929// first needs to be loaded from the Code object). As such, a CodePointerHandle
930// can be used both to obtain the referenced Code object and to directly load
931// its entrypoint.
932//
933// When the sandbox is disabled, these are regular tagged pointers.
934//
935// TODO(498510170): Removing these explicit code pointer handles is work in
936// progress.
939// The size of the virtual memory reservation for the code pointer table.
940// As with the other tables, a maximum table size in combination with shifted
941// indices allows omitting bounds checks.
942constexpr size_t kCodePointerTableReservationSize = 128 * MB;
943
944// Code pointer handles are shifted by a different amount than indirect pointer
945// handles as the tables have a different maximum size.
946constexpr uint32_t kCodePointerHandleShift = 8;
947
948// A null handle always references an entry that contains nullptr.
950
951// It can sometimes be necessary to distinguish a code pointer handle from a
952// trusted pointer handle. A typical example would be a union trusted pointer
953// field that can refer to both Code objects and other trusted objects. To
954// support these use-cases, we use a simple marking scheme where some of the
955// low bits of a code pointer handle are set, while they will be unset on a
956// trusted pointer handle. This way, the correct table to resolve the handle
957// can be determined even in the absence of a type tag.
958constexpr uint32_t kCodePointerHandleMarker = 0x1;
959static_assert(kCodePointerHandleShift > 0);
960static_assert(kTrustedPointerHandleShift > 0);
961
962// The byte size of an entry in a code pointer table.
963constexpr int kCodePointerTableEntrySize = 8;
964constexpr int kCodePointerTableEntrySizeLog2 = 3;
965// The maximum number of entries in a code pointer table.
966constexpr size_t kMaxCodePointers =
968static_assert(
970 "kCodePointerTableReservationSize and kCodePointerHandleShift don't match");
971
974// Constants that can be used to mark places that should be modified once
975// certain types of objects are moved out of the sandbox and into trusted space.
977constexpr bool kBuiltinCodeObjectsLiveInTrustedSpace = false;
981
982// {obj} must be the raw tagged pointer representation of a HeapObject
983// that's guaranteed to never be in ReadOnlySpace.
985 "Use GetCurrentIsolate() instead, which is guaranteed to return the same "
986 "isolate since https://crrev.com/c/6458560.")
989// Returns if we need to throw when an error occurs. This infers the language
990// mode based on the current context and the closure. This returns true if the
991// language mode is strict.
992V8_EXPORT bool ShouldThrowOnError(internal::Isolate* isolate);
993
994struct HandleScopeData final {
995 static constexpr uint32_t kSizeInBytes =
998 Address* next;
999 Address* limit;
1000 int level;
1001 int sealed_level;
1002
1003 void Initialize() {
1004 next = limit = nullptr;
1005 sealed_level = level = 0;
1006 }
1007};
1008
1009static_assert(HandleScopeData::kSizeInBytes == sizeof(HandleScopeData));
1010
1016class Internals {
1017#ifdef V8_MAP_PACKING
1018 V8_INLINE static constexpr Address UnpackMapWord(Address mapword) {
1019 // TODO(wenyuzhao): Clear header metadata.
1020 return mapword ^ kMapWordXorMask;
1021 }
1022#endif
1024 public:
1025 // These values match non-compiler-dependent values defined within
1026 // the implementation of v8.
1027 static const int kHeapObjectMapOffset = 0;
1029 static const int kStringResourceOffset =
1030 1 * kApiTaggedSize + 2 * kApiInt32Size;
1031
1032 static const int kOddballKindOffset = 4 * kApiTaggedSize + kApiDoubleSize;
1033 static const int kJSObjectHeaderSize = 3 * kApiTaggedSize;
1034#ifdef V8_COMPRESS_POINTERS
1037#else // !V8_COMPRESS_POINTERS
1040#endif // !V8_COMPRESS_POINTERS
1041 static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize;
1042 static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize;
1044#ifdef V8_ENABLE_SANDBOX
1046#else
1048#endif
1050 static const int kStringRepresentationAndEncodingMask = 0x0f;
1051 static const int kStringEncodingMask = 0x8;
1052 static const int kExternalTwoByteRepresentationTag = 0x02;
1053 static const int kExternalOneByteRepresentationTag = 0x0a;
1055 // AccessorInfo::data and InterceptorInfo::data field.
1058 static const uint32_t kNumIsolateDataSlots = 4;
1060 static const int kNumberOfBooleanFlags = 6;
1061 static const int kErrorMessageParamSize = 1;
1062 static const int kTablesAlignmentPaddingSize = 1;
1065 static const int kBuiltinTier0TableSize = 7 * kApiSystemPointerSize;
1066 static const int kLinearAllocationAreaSize = 3 * kApiSystemPointerSize;
1067 static const int kThreadLocalTopSize = 30 * kApiSystemPointerSize;
1068 static const int kHandleScopeDataSize =
1071 // ExternalPointerTable and TrustedPointerTable layout guarantees.
1072 static const int kExternalEntityTableBasePointerOffset = 0;
1073 static const int kSegmentedTableSegmentPoolSize = 4;
1074 static const int kExternalEntityTableSize =
1077
1078 // IsolateData layout guarantees.
1079 static const int kIsolateCageBaseOffset = 0;
1080 static const int kIsolateStackGuardOffset =
1084 static const int kErrorMessageParamOffset =
1086 static const int kBuiltinTier0EntryTableOffset =
1089 static const int kBuiltinTier0TableOffset =
1091 static const int kNewAllocationInfoOffset =
1093 static const int kOldAllocationInfoOffset =
1095 static const int kLastYoungAllocationOffset =
1098 static const int kFastCCallAlignmentPaddingSize =
1101 static const int kIsolateFastCCallCallerPcOffset =
1112 static const int kIsolateHandleScopeDataOffset =
1114 static const int kIsolateEmbedderDataOffset =
1116#ifdef V8_COMPRESS_POINTERS
1117 static const int kIsolateExternalPointerTableOffset =
1119 static const int kIsolateSharedExternalPointerTableAddressOffset =
1120 kIsolateExternalPointerTableOffset + kExternalEntityTableSize;
1121 static const int kIsolateCppHeapPointerTableOffset =
1122 kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize;
1123#ifdef V8_ENABLE_SANDBOX
1124 static const int kIsolateTrustedCageBaseOffset =
1125 kIsolateCppHeapPointerTableOffset + kExternalEntityTableSize;
1126 static const int kIsolateTrustedPointerTableOffset =
1127 kIsolateTrustedCageBaseOffset + kApiSystemPointerSize;
1128 static const int kIsolateSharedTrustedPointerTableAddressOffset =
1129 kIsolateTrustedPointerTableOffset + kExternalEntityTableSize;
1130 static const int kIsolateTrustedPointerPublishingScopeOffset =
1131 kIsolateSharedTrustedPointerTableAddressOffset + kApiSystemPointerSize;
1132 static const int kIsolateCodePointerTableBaseAddressOffset =
1133 kIsolateTrustedPointerPublishingScopeOffset + kApiSystemPointerSize;
1134 static const int kIsolateJSDispatchTableOffset =
1135 kIsolateCodePointerTableBaseAddressOffset + kApiSystemPointerSize;
1136#else
1138 kIsolateCppHeapPointerTableOffset + kExternalEntityTableSize;
1139#endif // V8_ENABLE_SANDBOX
1140#else
1141 static const int kIsolateJSDispatchTableOffset =
1143#endif // V8_COMPRESS_POINTERS
1152 static const int kCurrentMicrotaskNativeContextOffset =
1154 static const int kIsolateRootsOffset =
1157#if V8_TARGET_ARCH_PPC64
1158 static constexpr int kFrameCPSlotCount = 1;
1159#else
1160 static constexpr int kFrameCPSlotCount = 0;
1161#endif
1162
1163#if V8_TARGET_ARCH_ARM64
1164 // The padding required to keep SP 16-byte aligned.
1165 static constexpr int kSPAlignmentSlotCount = 1;
1166#else
1167 static constexpr int kSPAlignmentSlotCount = 0;
1168#endif
1170 static const int kFrameTypeApiCallExit = 18;
1171 static const int kFrameTypeApiConstructExit = 19;
1172 static const int kFrameTypeApiNamedAccessorExit = 20;
1174
1175 // Assert scopes
1176 static const int kDisallowGarbageCollectionAlign = alignof(uint32_t);
1177 static const int kDisallowGarbageCollectionSize = sizeof(uint32_t);
1178
1179#if V8_STATIC_ROOTS_BOOL
1180
1181// These constants are copied from static-roots.h and guarded by static asserts.
1182#define EXPORTED_STATIC_ROOTS_PTR_LIST(V) \
1183 V(UndefinedValue, 0x11) \
1184 V(NullValue, 0x2d) \
1185 V(TrueValue, 0x71) \
1186 V(FalseValue, 0x55) \
1187 V(EmptyString, 0x49) \
1188 /* The Hole moves around depending on build flags, so define it */ \
1189 /* separately inside StaticReadOnlyRoot using build macros */ \
1190 V(TheHoleValue, kBuildDependentTheHoleValue)
1191
1192 using Tagged_t = uint32_t;
1193 struct StaticReadOnlyRoot {
1194#ifdef V8_ENABLE_WEBASSEMBLY
1195 static constexpr Tagged_t kBuildDependentTheHoleValue = 0x2fffd;
1196#else
1197 static constexpr Tagged_t kBuildDependentTheHoleValue = 0xfffd;
1198#endif
1199
1200#define DEF_ROOT(name, value) static constexpr Tagged_t k##name = value;
1201 EXPORTED_STATIC_ROOTS_PTR_LIST(DEF_ROOT)
1202#undef DEF_ROOT
1203
1204 // Use 0 for kStringMapLowerBound since string maps are the first maps.
1205 static constexpr Tagged_t kStringMapLowerBound = 0;
1206 static constexpr Tagged_t kStringMapUpperBound = 0x425;
1207
1208#define PLUSONE(...) +1
1209 static constexpr size_t kNumberOfExportedStaticRoots =
1210 2 + EXPORTED_STATIC_ROOTS_PTR_LIST(PLUSONE);
1211#undef PLUSONE
1214#endif // V8_STATIC_ROOTS_BOOL
1216 static const int kUndefinedValueRootIndex = 0;
1217 static const int kTheHoleValueRootIndex = 1;
1218 static const int kNullValueRootIndex = 2;
1219 static const int kTrueValueRootIndex = 3;
1220 static const int kFalseValueRootIndex = 4;
1221 static const int kEmptyStringRootIndex = 5;
1223 static const int kNodeClassIdOffset = 1 * kApiSystemPointerSize;
1224 static const int kNodeFlagsOffset = 1 * kApiSystemPointerSize + 3;
1225 static const int kNodeStateMask = 0x3;
1226 static const int kNodeStateIsWeakValue = 2;
1228 static const int kFirstNonstringType = 0x80;
1229 static const int kOddballType = 0x83;
1230 static const int kForeignType = 0xcc;
1231 static const int kJSSpecialApiObjectType = 0x410;
1232 static const int kJSObjectType = 0x421;
1233 static const int kFirstJSApiObjectType = 0x422;
1234 static const int kLastJSApiObjectType = 0x80A;
1235 // Defines a range [kFirstEmbedderJSApiObjectType, kJSApiObjectTypesCount]
1236 // of JSApiObject instance type values that an embedder can use.
1237 static const int kFirstEmbedderJSApiObjectType = 0;
1240
1241 static const int kUndefinedOddballKind = 4;
1242 static const int kNullOddballKind = 3;
1244 // Constants used by PropertyCallbackInfo to check if we should throw when an
1245 // error occurs.
1246 static const int kDontThrow = 0;
1247 static const int kThrowOnError = 1;
1248 static const int kInferShouldThrowMode = 2;
1249
1250 // Soft limit for AdjustAmountofExternalAllocatedMemory. Trigger an
1251 // incremental GC once the external memory reaches this limit.
1252 static constexpr size_t kExternalAllocationSoftLimit = 64 * 1024 * 1024;
1253
1254#ifdef V8_MAP_PACKING
1255 static const uintptr_t kMapWordMetadataMask = 0xffffULL << 48;
1256 // The lowest two bits of mapwords are always `0b10`
1257 static const uintptr_t kMapWordSignature = 0b10;
1258 // XORing a (non-compressed) map with this mask ensures that the two
1259 // low-order bits are 0b10. The 0 at the end makes this look like a Smi,
1260 // although real Smis have all lower 32 bits unset. We only rely on these
1261 // values passing as Smis in very few places.
1262 static const int kMapWordXorMask = 0b11;
1263#endif
1264
1265 V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
1266 V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
1267#ifdef V8_ENABLE_CHECKS
1269#endif
1270 }
1271
1272 V8_INLINE static constexpr bool HasHeapObjectTag(Address value) {
1273 return (value & kHeapObjectTagMask) == static_cast<Address>(kHeapObjectTag);
1274 }
1275
1276 V8_INLINE static constexpr int SmiValue(Address value) {
1277 return PlatformSmiTagging::SmiToInt(value);
1278 }
1279
1280 V8_INLINE static constexpr Address AddressToSmi(Address value) {
1281 return (value << (kSmiTagSize + PlatformSmiTagging::kSmiShiftSize)) |
1282 kSmiTag;
1283 }
1284
1285 V8_INLINE static constexpr Address IntToSmi(int value) {
1286 return AddressToSmi(static_cast<Address>(value));
1288
1289 template <typename T,
1290 typename std::enable_if_t<std::is_integral_v<T>>* = nullptr>
1291 V8_INLINE static constexpr Address IntegralToSmi(T value) {
1292 return AddressToSmi(static_cast<Address>(value));
1294
1295 template <typename T,
1296 typename std::enable_if_t<std::is_integral_v<T>>* = nullptr>
1297 V8_INLINE static constexpr bool IsValidSmi(T value) {
1298 return PlatformSmiTagging::IsValidSmi(value);
1300
1301 template <typename T,
1302 typename std::enable_if_t<std::is_integral_v<T>>* = nullptr>
1303 static constexpr std::optional<Address> TryIntegralToSmi(T value) {
1304 if (V8_LIKELY(PlatformSmiTagging::IsValidSmi(value))) {
1305 return {AddressToSmi(static_cast<Address>(value))};
1306 }
1307 return {};
1308 }
1309
1310#if V8_STATIC_ROOTS_BOOL
1311 V8_INLINE static bool is_identical(Address obj, Tagged_t constant) {
1312 return static_cast<Tagged_t>(obj) == constant;
1313 }
1314
1315 V8_INLINE static bool CheckInstanceMapRange(Address obj, Tagged_t first_map,
1316 Tagged_t last_map) {
1317 auto map = ReadRawField<Tagged_t>(obj, kHeapObjectMapOffset);
1318#ifdef V8_MAP_PACKING
1319 map = UnpackMapWord(map);
1320#endif
1321 return map >= first_map && map <= last_map;
1322 }
1323#endif
1324
1325 V8_INLINE static int GetInstanceType(Address obj) {
1327#ifdef V8_MAP_PACKING
1328 map = UnpackMapWord(map);
1329#endif
1330 return ReadRawField<uint16_t>(map, kMapInstanceTypeOffset);
1331 }
1332
1333 V8_INLINE static Address LoadMap(Address obj) {
1334 if (!HasHeapObjectTag(obj)) return kNullAddress;
1336#ifdef V8_MAP_PACKING
1337 map = UnpackMapWord(map);
1338#endif
1339 return map;
1340 }
1341
1344 }
1345
1346 V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
1347 int representation = (instance_type & kStringRepresentationAndEncodingMask);
1348 return representation == kExternalTwoByteRepresentationTag;
1349 }
1350
1351 V8_INLINE static bool IsExternalOneByteString(int instance_type) {
1352 int representation = (instance_type & kStringRepresentationAndEncodingMask);
1353 return representation == kExternalOneByteRepresentationTag;
1354 }
1355
1356 V8_INLINE static constexpr bool CanHaveInternalField(int instance_type) {
1357 static_assert(kJSObjectType + 1 == kFirstJSApiObjectType);
1358 static_assert(kJSObjectType < kLastJSApiObjectType);
1360 // Check for IsJSObject() || IsJSSpecialApiObject() || IsJSApiObject()
1361 return instance_type == kJSSpecialApiObjectType ||
1362 // inlined version of base::IsInRange
1363 (static_cast<unsigned>(static_cast<unsigned>(instance_type) -
1364 static_cast<unsigned>(kJSObjectType)) <=
1365 static_cast<unsigned>(kLastJSApiObjectType - kJSObjectType));
1366 }
1367
1368 V8_INLINE static uint8_t GetNodeFlag(Address* obj, int shift) {
1369 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
1370 return *addr & static_cast<uint8_t>(1U << shift);
1371 }
1372
1373 V8_INLINE static void UpdateNodeFlag(Address* obj, bool value, int shift) {
1374 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
1375 uint8_t mask = static_cast<uint8_t>(1U << shift);
1376 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
1377 }
1378
1379 V8_INLINE static uint8_t GetNodeState(Address* obj) {
1380 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
1381 return *addr & kNodeStateMask;
1382 }
1383
1384 V8_INLINE static void UpdateNodeState(Address* obj, uint8_t value) {
1385 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
1386 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
1387 }
1388
1389 V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, uint32_t slot,
1390 void* data) {
1391 Address addr = reinterpret_cast<Address>(isolate) +
1393 *reinterpret_cast<void**>(addr) = data;
1394 }
1395
1396 V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
1397 uint32_t slot) {
1398 Address addr = reinterpret_cast<Address>(isolate) +
1400 return *reinterpret_cast<void* const*>(addr);
1401 }
1402
1404 Address addr =
1405 reinterpret_cast<Address>(isolate) + kIsolateHandleScopeDataOffset;
1406 return reinterpret_cast<HandleScopeData*>(addr);
1407 }
1408
1410 Address addr =
1411 reinterpret_cast<Address>(isolate) + kIsolateLongTaskStatsCounterOffset;
1412 ++(*reinterpret_cast<size_t*>(addr));
1413 }
1414
1415 V8_INLINE static Address* GetRootSlot(v8::Isolate* isolate, int index) {
1416 Address addr = reinterpret_cast<Address>(isolate) + kIsolateRootsOffset +
1418 return reinterpret_cast<Address*>(addr);
1419 }
1420
1421 V8_INLINE static Address GetRoot(v8::Isolate* isolate, int index) {
1422#if V8_STATIC_ROOTS_BOOL
1423 Address base = *reinterpret_cast<Address*>(
1424 reinterpret_cast<uintptr_t>(isolate) + kIsolateCageBaseOffset);
1425 switch (index) {
1426#define DECOMPRESS_ROOT(name, ...) \
1427 case k##name##RootIndex: \
1428 return base + StaticReadOnlyRoot::k##name;
1429 EXPORTED_STATIC_ROOTS_PTR_LIST(DECOMPRESS_ROOT)
1430#undef DECOMPRESS_ROOT
1431#undef EXPORTED_STATIC_ROOTS_PTR_LIST
1432 default:
1433 break;
1434 }
1435#endif // V8_STATIC_ROOTS_BOOL
1436 return *GetRootSlot(isolate, index);
1437 }
1438
1439#ifdef V8_ENABLE_SANDBOX
1440 V8_INLINE static Address* GetExternalPointerTableBase(v8::Isolate* isolate) {
1441 Address addr = reinterpret_cast<Address>(isolate) +
1442 kIsolateExternalPointerTableOffset +
1444 return *reinterpret_cast<Address**>(addr);
1445 }
1446
1447 V8_INLINE static Address* GetSharedExternalPointerTableBase(
1448 v8::Isolate* isolate) {
1449 Address addr = reinterpret_cast<Address>(isolate) +
1450 kIsolateSharedExternalPointerTableAddressOffset;
1451 addr = *reinterpret_cast<Address*>(addr);
1453 return *reinterpret_cast<Address**>(addr);
1455#endif
1456
1457 template <typename T>
1458 V8_INLINE static T ReadRawField(Address heap_object_ptr, int offset) {
1459 Address addr = heap_object_ptr + offset - kHeapObjectTag;
1460#ifdef V8_COMPRESS_POINTERS
1461 if constexpr (sizeof(T) > kApiTaggedSize) {
1462 // TODO(ishell, v8:8875): When pointer compression is enabled 8-byte size
1463 // fields (external pointers, doubles and BigInt data) are only
1464 // kTaggedSize aligned so we have to use unaligned pointer friendly way of
1465 // accessing them in order to avoid undefined behavior in C++ code.
1466 T r;
1467 memcpy(&r, reinterpret_cast<void*>(addr), sizeof(T));
1468 return r;
1469 }
1470#endif
1471 return *reinterpret_cast<const T*>(addr);
1472 }
1473
1474 V8_INLINE static Address ReadTaggedPointerField(Address heap_object_ptr,
1475 int offset) {
1476#ifdef V8_COMPRESS_POINTERS
1477 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
1478 Address base = GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
1479 return base + static_cast<Address>(static_cast<uintptr_t>(value));
1480#else
1481 return ReadRawField<Address>(heap_object_ptr, offset);
1482#endif
1483 }
1484
1485 V8_INLINE static Address ReadTaggedSignedField(Address heap_object_ptr,
1486 int offset) {
1487#ifdef V8_COMPRESS_POINTERS
1488 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
1489 return static_cast<Address>(static_cast<uintptr_t>(value));
1490#else
1491 return ReadRawField<Address>(heap_object_ptr, offset);
1492#endif
1494
1495 // Returns v8::Isolate::Current(), but without needing to include the
1496 // v8-isolate.h header.
1498
1500#ifdef V8_ENABLE_SANDBOX
1501 return GetCurrentIsolate();
1502#else
1503 // Not used in non-sandbox mode.
1504 return nullptr;
1505#endif
1506 }
1507
1508 template <ExternalPointerTagRange tag_range>
1510 Address heap_object_ptr,
1511 int offset) {
1512#ifdef V8_ENABLE_SANDBOX
1513 static_assert(!tag_range.IsEmpty());
1514 // See src/sandbox/external-pointer-table.h. Logic duplicated here so
1515 // it can be inlined and doesn't require an additional call.
1516 Address* table = IsSharedExternalPointerType(tag_range)
1517 ? GetSharedExternalPointerTableBase(isolate)
1518 : GetExternalPointerTableBase(isolate);
1520 ReadRawField<ExternalPointerHandle>(heap_object_ptr, offset);
1521 uint32_t index = handle >> kExternalPointerIndexShift;
1522 std::atomic<Address>* ptr =
1523 reinterpret_cast<std::atomic<Address>*>(&table[index]);
1524 Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed);
1525 ExternalPointerTag actual_tag = static_cast<ExternalPointerTag>(
1527 volatile Address safe_entry;
1528 if (V8_LIKELY(tag_range.Contains(actual_tag))) {
1529 safe_entry = entry & kExternalPointerPayloadMask;
1530 } else {
1531 safe_entry = 0;
1532 }
1533 return safe_entry;
1534#else
1535 return ReadRawField<Address>(heap_object_ptr, offset);
1536#endif // V8_ENABLE_SANDBOX
1537 }
1538
1540 v8::Isolate* isolate, Address heap_object_ptr, int offset,
1541 ExternalPointerTagRange tag_range) {
1542#ifdef V8_ENABLE_SANDBOX
1543 // See src/sandbox/external-pointer-table.h. Logic duplicated here so
1544 // it can be inlined and doesn't require an additional call.
1545 Address* table = IsSharedExternalPointerType(tag_range)
1546 ? GetSharedExternalPointerTableBase(isolate)
1547 : GetExternalPointerTableBase(isolate);
1549 ReadRawField<ExternalPointerHandle>(heap_object_ptr, offset);
1550 uint32_t index = handle >> kExternalPointerIndexShift;
1551 std::atomic<Address>* ptr =
1552 reinterpret_cast<std::atomic<Address>*>(&table[index]);
1553 Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed);
1554 ExternalPointerTag actual_tag = static_cast<ExternalPointerTag>(
1556 // Avoid DCE of the entry logic using volatile.
1557 volatile Address safe_entry;
1558 if (V8_LIKELY(tag_range.Contains(actual_tag))) {
1559 safe_entry = entry & kExternalPointerPayloadMask;
1560 } else {
1561 safe_entry = 0;
1562 }
1563 return safe_entry;
1564#else
1565 return ReadRawField<Address>(heap_object_ptr, offset);
1566#endif // V8_ENABLE_SANDBOX
1567 }
1568
1569#ifdef V8_COMPRESS_POINTERS
1570 V8_INLINE static Address GetPtrComprCageBaseFromOnHeapAddress(Address addr) {
1571 return addr & -static_cast<intptr_t>(kPtrComprCageBaseAlignment);
1572 }
1573
1574 V8_INLINE static uint32_t CompressTagged(Address value) {
1575 return static_cast<uint32_t>(value);
1576 }
1577
1578 V8_INLINE static Address DecompressTaggedField(Address heap_object_ptr,
1579 uint32_t value) {
1580 Address base = GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
1581 return base + static_cast<Address>(static_cast<uintptr_t>(value));
1582 }
1583
1584#endif // V8_COMPRESS_POINTERS
1585};
1587// Only perform cast check for types derived from v8::Data since
1588// other types do not implement the Cast method.
1589template <bool PerformCheck>
1590struct CastCheck {
1591 template <class T>
1592 static void Perform(T* data);
1594
1595template <>
1596template <class T>
1597void CastCheck<true>::Perform(T* data) {
1598 T::Cast(data);
1600
1601template <>
1602template <class T>
1603void CastCheck<false>::Perform(T* data) {}
1604
1605template <class T>
1606V8_INLINE void PerformCastCheck(T* data) {
1607 CastCheck<std::is_base_of_v<Data, T> &&
1608 !std::is_same_v<Data, std::remove_cv_t<T>>>::Perform(data);
1610
1611// A base class for backing stores, which is needed due to vagaries of
1612// how static casts work with std::shared_ptr.
1614
1615// The maximum value in enum GarbageCollectionReason, defined in heap.h.
1616// This is needed for histograms sampling garbage collection reasons.
1618
1619// Base class for the address block allocator compatible with standard
1620// containers, which registers its allocated range as strong roots.
1622 public:
1623 Heap* heap() const { return heap_; }
1625 constexpr bool operator==(const StrongRootAllocatorBase&) const = default;
1627 protected:
1628 explicit StrongRootAllocatorBase(Heap* heap) : heap_(heap) {}
1629 explicit StrongRootAllocatorBase(LocalHeap* heap);
1630 explicit StrongRootAllocatorBase(Isolate* isolate);
1632 explicit StrongRootAllocatorBase(LocalIsolate* isolate);
1633
1634 // Allocate/deallocate a range of n elements of type internal::Address.
1635 Address* allocate_impl(size_t n);
1636 void deallocate_impl(Address* p, size_t n) noexcept;
1637
1638 private:
1639 Heap* heap_;
1640};
1641
1642// The general version of this template behaves just as std::allocator, with
1643// the exception that the constructor takes the isolate as parameter. Only
1644// specialized versions, e.g., internal::StrongRootAllocator<internal::Address>
1645// and internal::StrongRootAllocator<v8::Local<T>> register the allocated range
1646// as strong roots.
1647template <typename T>
1648class StrongRootAllocator : private std::allocator<T> {
1649 public:
1650 using value_type = T;
1652 template <typename HeapOrIsolateT>
1653 explicit StrongRootAllocator(HeapOrIsolateT*) {}
1654 template <typename U>
1655 StrongRootAllocator(const StrongRootAllocator<U>& other) noexcept {}
1656
1657 using std::allocator<T>::allocate;
1658 using std::allocator<T>::deallocate;
1659};
1660
1661template <typename Iterator>
1662concept HasIteratorConcept = requires { typename Iterator::iterator_concept; };
1663
1664template <typename Iterator>
1665concept HasIteratorCategory =
1666 requires { typename Iterator::iterator_category; };
1667
1668// Helper struct that contains an `iterator_concept` type alias only when either
1669// `Iterator` or `std::iterator_traits<Iterator>` do.
1670// Default: no alias.
1671template <typename Iterator>
1673// Use `Iterator::iterator_concept` if available.
1674template <HasIteratorConcept Iterator>
1675struct MaybeDefineIteratorConcept<Iterator> {
1676 using iterator_concept = typename Iterator::iterator_concept;
1677};
1678// Otherwise fall back to `std::iterator_traits<Iterator>` if possible.
1679template <typename Iterator>
1682 using iterator_concept =
1683 typename std::iterator_traits<Iterator>::iterator_concept;
1685
1686template <typename T>
1687struct MaybeDefineIteratorConcept<T*> {
1688 using iterator_concept = std::contiguous_iterator_tag;
1689};
1690
1691// A class of iterators that wrap some different iterator type.
1692// If specified, ElementType is the type of element accessed by the wrapper
1693// iterator; in this case, the actual reference and pointer types of Iterator
1694// must be convertible to ElementType& and ElementType*, respectively.
1695template <typename Iterator, typename ElementType = void>
1696class WrappedIterator : public MaybeDefineIteratorConcept<Iterator> {
1697 public:
1698 static_assert(
1699 std::is_void_v<ElementType> ||
1700 (std::is_convertible_v<typename std::iterator_traits<Iterator>::pointer,
1701 std::add_pointer_t<ElementType>> &&
1702 std::is_convertible_v<typename std::iterator_traits<Iterator>::reference,
1703 std::add_lvalue_reference_t<ElementType>>));
1704
1705 using difference_type =
1706 typename std::iterator_traits<Iterator>::difference_type;
1708 std::conditional_t<std::is_void_v<ElementType>,
1709 typename std::iterator_traits<Iterator>::value_type,
1710 ElementType>;
1711 using pointer =
1712 std::conditional_t<std::is_void_v<ElementType>,
1713 typename std::iterator_traits<Iterator>::pointer,
1714 std::add_pointer_t<ElementType>>;
1716 std::conditional_t<std::is_void_v<ElementType>,
1717 typename std::iterator_traits<Iterator>::reference,
1718 std::add_lvalue_reference_t<ElementType>>;
1720 typename std::iterator_traits<Iterator>::iterator_category;
1721
1722 constexpr WrappedIterator() noexcept = default;
1723 constexpr explicit WrappedIterator(Iterator it) noexcept : it_(it) {}
1724
1725 template <typename OtherIterator, typename OtherElementType>
1726 requires std::is_convertible_v<OtherIterator, Iterator>
1729 : it_(other.base()) {}
1730
1731 [[nodiscard]] constexpr reference operator*() const noexcept { return *it_; }
1732 [[nodiscard]] constexpr pointer operator->() const noexcept {
1733 if constexpr (std::is_pointer_v<Iterator>) {
1734 return it_;
1735 } else {
1736 return it_.operator->();
1738 }
1739
1740 template <typename OtherIterator, typename OtherElementType>
1741 [[nodiscard]] constexpr bool operator==(
1742 const WrappedIterator<OtherIterator, OtherElementType>& other)
1743 const noexcept {
1744 return it_ == other.base();
1745 }
1746
1747 template <typename OtherIterator, typename OtherElementType>
1748 [[nodiscard]] constexpr auto operator<=>(
1750 const noexcept {
1751 if constexpr (std::three_way_comparable_with<Iterator, OtherIterator>) {
1752 return it_ <=> other.base();
1753 } else if constexpr (std::totally_ordered_with<Iterator, OtherIterator>) {
1754 if (it_ < other.base()) {
1755 return std::strong_ordering::less;
1756 }
1757 return (it_ > other.base()) ? std::strong_ordering::greater
1758 : std::strong_ordering::equal;
1759 } else {
1760 if (it_ < other.base()) {
1761 return std::partial_ordering::less;
1762 }
1763 if (other.base() < it_) {
1764 return std::partial_ordering::greater;
1765 }
1766 return (it_ == other.base()) ? std::partial_ordering::equivalent
1767 : std::partial_ordering::unordered;
1768 }
1769 }
1770
1771 constexpr WrappedIterator& operator++() noexcept {
1772 ++it_;
1773 return *this;
1774 }
1775 constexpr WrappedIterator operator++(int) noexcept {
1776 WrappedIterator result(*this);
1777 ++(*this);
1778 return result;
1779 }
1780
1781 constexpr WrappedIterator& operator--() noexcept {
1782 --it_;
1783 return *this;
1784 }
1785 constexpr WrappedIterator operator--(int) noexcept {
1786 WrappedIterator result(*this);
1787 --(*this);
1788 return result;
1789 }
1790 [[nodiscard]] constexpr WrappedIterator operator+(
1791 difference_type n) const noexcept {
1792 WrappedIterator result(*this);
1793 result += n;
1794 return result;
1795 }
1796 [[nodiscard]] friend constexpr WrappedIterator operator+(
1797 difference_type n, const WrappedIterator& x) noexcept {
1798 return x + n;
1799 }
1801 it_ += n;
1802 return *this;
1803 }
1804 [[nodiscard]] constexpr WrappedIterator operator-(
1805 difference_type n) const noexcept {
1806 return *this + -n;
1807 }
1809 return *this += -n;
1810 }
1811 template <typename OtherIterator, typename OtherElementType>
1812 [[nodiscard]] constexpr auto operator-(
1814 const noexcept {
1815 return it_ - other.base();
1816 }
1817 [[nodiscard]] constexpr reference operator[](
1818 difference_type n) const noexcept {
1819 return it_[n];
1820 }
1821
1822 [[nodiscard]] constexpr const Iterator& base() const noexcept { return it_; }
1823
1824 private:
1825 Iterator it_;
1826};
1828// Helper functions about values contained in handles.
1829// A value is either an indirect pointer or a direct pointer, depending on
1830// whether direct local support is enabled.
1831class ValueHelper final {
1832 public:
1833 // ValueHelper::InternalRepresentationType is an abstract type that
1834 // corresponds to the internal representation of v8::Local and essentially
1835 // to what T* really is (these two are always in sync). This type is used in
1836 // methods like GetDataFromSnapshotOnce that need access to a handle's
1837 // internal representation. In particular, if `x` is a `v8::Local<T>`, then
1838 // `v8::Local<T>::FromRepr(x.repr())` gives exactly the same handle as `x`.
1839#ifdef V8_ENABLE_DIRECT_HANDLE
1840 static constexpr Address kTaggedNullAddress = 1;
1843 static constexpr InternalRepresentationType kEmpty = kTaggedNullAddress;
1844#else
1846 static constexpr InternalRepresentationType kEmpty = nullptr;
1847#endif // V8_ENABLE_DIRECT_HANDLE
1848
1849 template <typename T>
1850 V8_INLINE static bool IsEmpty(T* value) {
1851 return ValueAsRepr(value) == kEmpty;
1852 }
1853
1854 // Returns a handle's "value" for all kinds of abstract handles. For Local,
1855 // it is equivalent to `*handle`. The variadic parameters support handle
1856 // types with extra type parameters, like `Persistent<T, M>`.
1857 template <template <typename T, typename... Ms> typename H, typename T,
1858 typename... Ms>
1859 V8_INLINE static T* HandleAsValue(const H<T, Ms...>& handle) {
1860 return handle.template value<T>();
1861 }
1862
1863#ifdef V8_ENABLE_DIRECT_HANDLE
1864
1865 template <typename T>
1866 V8_INLINE static Address ValueAsAddress(const T* value) {
1867 return reinterpret_cast<Address>(value);
1868 }
1869
1870 template <typename T, bool check_null = true, typename S>
1871 V8_INLINE static T* SlotAsValue(S* slot) {
1872 if (check_null && slot == nullptr) {
1873 return reinterpret_cast<T*>(kTaggedNullAddress);
1874 }
1875 return *reinterpret_cast<T**>(slot);
1876 }
1877
1878 template <typename T>
1879 V8_INLINE static InternalRepresentationType ValueAsRepr(const T* value) {
1880 return reinterpret_cast<InternalRepresentationType>(value);
1881 }
1882
1883 template <typename T>
1885 return reinterpret_cast<T*>(repr);
1886 }
1888#else // !V8_ENABLE_DIRECT_HANDLE
1889
1890 template <typename T>
1891 V8_INLINE static Address ValueAsAddress(const T* value) {
1892 return *reinterpret_cast<const Address*>(value);
1893 }
1894
1895 template <typename T, bool check_null = true, typename S>
1896 V8_INLINE static T* SlotAsValue(S* slot) {
1897 return reinterpret_cast<T*>(slot);
1898 }
1899
1900 template <typename T>
1901 V8_INLINE static InternalRepresentationType ValueAsRepr(const T* value) {
1902 return const_cast<InternalRepresentationType>(
1903 reinterpret_cast<const Address*>(value));
1904 }
1905
1906 template <typename T>
1908 return reinterpret_cast<T*>(repr);
1909 }
1910
1911#endif // V8_ENABLE_DIRECT_HANDLE
1912};
1917class HandleHelper final {
1918 public:
1929 template <typename T1, typename T2>
1930 V8_INLINE static bool EqualHandles(const T1& lhs, const T2& rhs) {
1931 if (lhs.IsEmpty()) return rhs.IsEmpty();
1932 if (rhs.IsEmpty()) return false;
1933 return lhs.ptr() == rhs.ptr();
1934 }
1935};
1936
1937V8_EXPORT void VerifyHandleIsNonEmpty(bool is_empty);
1938
1939// These functions are here just to match friend declarations in
1940// XxxCallbackInfo classes allowing these functions to access the internals
1941// of the info objects. These functions are supposed to be called by debugger
1942// macros.
1943void PrintFunctionCallbackInfo(void* function_callback_info);
1944void PrintPropertyCallbackInfo(void* property_callback_info);
1945
1946} // namespace internal
1947} // namespace v8
1948
1949#endif // INCLUDE_V8_INTERNAL_H_
Definition: v8-isolate.h:291
Definition: v8-internal.h:1609
Definition: v8-internal.h:1913
static bool EqualHandles(const T1 &lhs, const T2 &rhs)
Definition: v8-internal.h:1926
static Address LoadMap(Address obj)
Definition: v8-internal.h:1329
static constexpr size_t kExternalAllocationSoftLimit
Definition: v8-internal.h:1248
static bool IsExternalTwoByteString(int instance_type)
Definition: v8-internal.h:1342
static const int kIsolateCageBaseOffset
Definition: v8-internal.h:1075
static const int kEmbedderDataArrayHeaderSize
Definition: v8-internal.h:1038
static const int kHeapObjectMapOffset
Definition: v8-internal.h:1023
static const int kEmbedderDataSlotSize
Definition: v8-internal.h:1039
static const int kIsolateApiCallbackThunkArgumentOffset
Definition: v8-internal.h:1140
static Address ReadExternalPointerField(v8::Isolate *isolate, Address heap_object_ptr, int offset)
Definition: v8-internal.h:1505
static const int kJSAPIObjectWithEmbedderSlotsHeaderSize
Definition: v8-internal.h:1034
static constexpr bool HasHeapObjectTag(Address value)
Definition: v8-internal.h:1268
static const int kOddballType
Definition: v8-internal.h:1225
static const int kInferShouldThrowMode
Definition: v8-internal.h:1244
static const int kNewAllocationInfoOffset
Definition: v8-internal.h:1087
static Address GetRoot(v8::Isolate *isolate, int index)
Definition: v8-internal.h:1417
static const int kStringEncodingMask
Definition: v8-internal.h:1047
static const int kIsolateFastCCallCallerPcOffset
Definition: v8-internal.h:1097
static uint8_t GetNodeFlag(Address *obj, int shift)
Definition: v8-internal.h:1364
static const int kIsolateThreadLocalTopOffset
Definition: v8-internal.h:1106
static const uint32_t kNumIsolateDataSlots
Definition: v8-internal.h:1054
static const int kForeignType
Definition: v8-internal.h:1226
static const int kFirstEmbedderJSApiObjectType
Definition: v8-internal.h:1233
static const int kNumberOfBooleanFlags
Definition: v8-internal.h:1056
static uint8_t GetNodeState(Address *obj)
Definition: v8-internal.h:1375
static const int kThreadLocalTopSize
Definition: v8-internal.h:1063
static const int kIsolateRootsOffset
Definition: v8-internal.h:1150
static const int kFrameTypeApiCallExit
Definition: v8-internal.h:1166
static const int kUndefinedOddballKind
Definition: v8-internal.h:1237
static const int kMapInstanceTypeOffset
Definition: v8-internal.h:1024
static constexpr Address AddressToSmi(Address value)
Definition: v8-internal.h:1276
static const int kIsolateStackGuardOffset
Definition: v8-internal.h:1076
static const int kLinearAllocationAreaSize
Definition: v8-internal.h:1062
static const int kFastCCallAlignmentPaddingSize
Definition: v8-internal.h:1094
static const int kDisallowGarbageCollectionAlign
Definition: v8-internal.h:1172
static const int kIsolateFastCCallCallerFpOffset
Definition: v8-internal.h:1100
static const int kErrorMessageParamSize
Definition: v8-internal.h:1057
static const int kSegmentedTableSegmentPoolSize
Definition: v8-internal.h:1069
static void CheckInitialized(v8::Isolate *isolate)
Definition: v8-internal.h:1262
static void UpdateNodeState(Address *obj, uint8_t value)
Definition: v8-internal.h:1380
static constexpr Address IntegralToSmi(T value)
Definition: v8-internal.h:1287
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:1293
static const int kJSObjectType
Definition: v8-internal.h:1228
static const int kExternalEntityTableBasePointerOffset
Definition: v8-internal.h:1068
static const int kBuiltinTier0TableOffset
Definition: v8-internal.h:1085
static const int kIsolateLongTaskStatsCounterOffset
Definition: v8-internal.h:1104
static const int kNativeContextEmbedderDataOffset
Definition: v8-internal.h:1045
static const int kLastJSApiObjectType
Definition: v8-internal.h:1230
static constexpr bool CanHaveInternalField(int instance_type)
Definition: v8-internal.h:1352
static constexpr int kSPAlignmentSlotCount
Definition: v8-internal.h:1163
static const int kIsolateHandleScopeDataOffset
Definition: v8-internal.h:1108
static const int kFirstNonstringType
Definition: v8-internal.h:1224
static const int kEmptyStringRootIndex
Definition: v8-internal.h:1217
static const int kBuiltinTier0EntryTableOffset
Definition: v8-internal.h:1082
static const int kFrameTypeApiIndexedAccessorExit
Definition: v8-internal.h:1169
static const int kFixedArrayHeaderSize
Definition: v8-internal.h:1037
static const int kNullOddballKind
Definition: v8-internal.h:1238
static const int kUndefinedValueRootIndex
Definition: v8-internal.h:1212
static const int kExternalTwoByteRepresentationTag
Definition: v8-internal.h:1048
static constexpr Address IntToSmi(int value)
Definition: v8-internal.h:1281
static const int kDontThrow
Definition: v8-internal.h:1242
static void CheckInitializedImpl(v8::Isolate *isolate)
static void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
Definition: v8-internal.h:1392
static const int kStackGuardSize
Definition: v8-internal.h:1055
static const int kNodeStateMask
Definition: v8-internal.h:1221
static HandleScopeData * GetHandleScopeData(v8::Isolate *isolate)
Definition: v8-internal.h:1399
static const int kNodeStateIsWeakValue
Definition: v8-internal.h:1222
static const int kFirstJSApiObjectType
Definition: v8-internal.h:1229
static const int kStringResourceOffset
Definition: v8-internal.h:1025
static bool IsExternalOneByteString(int instance_type)
Definition: v8-internal.h:1347
static const int kErrorMessageParamOffset
Definition: v8-internal.h:1080
static const int kCurrentMicrotaskNativeContextOffset
Definition: v8-internal.h:1148
static const int kFalseValueRootIndex
Definition: v8-internal.h:1216
static const int kIsolateRegexpExecVectorArgumentOffset
Definition: v8-internal.h:1142
static const int kIsolateFastApiCallTargetOffset
Definition: v8-internal.h:1102
static const int kTrueValueRootIndex
Definition: v8-internal.h:1215
static int GetInstanceType(Address obj)
Definition: v8-internal.h:1321
static const int kThrowOnError
Definition: v8-internal.h:1243
static Address ReadTaggedSignedField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1481
static const int kOddballKindOffset
Definition: v8-internal.h:1028
static const int kBuiltinTier0TableSize
Definition: v8-internal.h:1061
static const int kExternalEntityTableSize
Definition: v8-internal.h:1070
static const int kFrameTypeApiConstructExit
Definition: v8-internal.h:1167
static const int kContinuationPreservedEmbedderDataOffset
Definition: v8-internal.h:1144
static const int kLastYoungAllocationOffset
Definition: v8-internal.h:1091
static const int kCurrentMicrotaskQueueOffset
Definition: v8-internal.h:1146
static Address ReadTaggedPointerField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1470
static const int kFrameTypeApiNamedAccessorExit
Definition: v8-internal.h:1168
static const int kNullValueRootIndex
Definition: v8-internal.h:1214
static void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
Definition: v8-internal.h:1385
static Address * GetRootSlot(v8::Isolate *isolate, int index)
Definition: v8-internal.h:1411
static const int kIsolateJSDispatchTableOffset
Definition: v8-internal.h:1137
static const int kTheHoleValueRootIndex
Definition: v8-internal.h:1213
static constexpr int SmiValue(Address value)
Definition: v8-internal.h:1272
static const int kTablesAlignmentPaddingSize
Definition: v8-internal.h:1058
static const int kHandleScopeDataSize
Definition: v8-internal.h:1064
static const int kExternalOneByteRepresentationTag
Definition: v8-internal.h:1049
static const int kBuiltinTier0EntryTableSize
Definition: v8-internal.h:1060
static void UpdateNodeFlag(Address *obj, bool value, int shift)
Definition: v8-internal.h:1369
static const int kCallbackInfoDataOffset
Definition: v8-internal.h:1052
static void IncrementLongTasksStatsCounter(v8::Isolate *isolate)
Definition: v8-internal.h:1405
static const int kDisallowGarbageCollectionSize
Definition: v8-internal.h:1173
static const int kOldAllocationInfoOffset
Definition: v8-internal.h:1089
static const int kIsolateEmbedderDataOffset
Definition: v8-internal.h:1110
static T ReadRawField(Address heap_object_ptr, int offset)
Definition: v8-internal.h:1454
static v8::Isolate * GetCurrentIsolate()
static constexpr int kFrameCPSlotCount
Definition: v8-internal.h:1156
static const int kEmbedderDataSlotExternalPointerOffset
Definition: v8-internal.h:1043
static v8::Isolate * GetCurrentIsolateForSandbox()
Definition: v8-internal.h:1495
static int GetOddballKind(Address obj)
Definition: v8-internal.h:1338
static const int kNodeFlagsOffset
Definition: v8-internal.h:1220
static const int kRegExpStaticResultOffsetsVectorSize
Definition: v8-internal.h:1059
static const int kLastEmbedderJSApiObjectType
Definition: v8-internal.h:1234
static const int kVariousBooleanFlagsOffset
Definition: v8-internal.h:1078
static constexpr std::optional< Address > TryIntegralToSmi(T value)
Definition: v8-internal.h:1299
static const int kNodeClassIdOffset
Definition: v8-internal.h:1219
static const int kStringRepresentationAndEncodingMask
Definition: v8-internal.h:1046
static const int kJSObjectHeaderSize
Definition: v8-internal.h:1029
static const int kJSSpecialApiObjectType
Definition: v8-internal.h:1227
Definition: v8-internal.h:1617
StrongRootAllocatorBase(LocalIsolate *isolate)
Definition: v8-internal.h:1644
T value_type
Definition: v8-internal.h:1646
Definition: v8-internal.h:1827
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1887
static T * ReprAsValue(InternalRepresentationType repr)
Definition: v8-internal.h:1903
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1841
static T * SlotAsValue(S *slot)
Definition: v8-internal.h:1892
static T * HandleAsValue(const H< T, Ms... > &handle)
Definition: v8-internal.h:1855
static InternalRepresentationType ValueAsRepr(const T *value)
Definition: v8-internal.h:1897
static bool IsEmpty(T *value)
Definition: v8-internal.h:1846
static constexpr InternalRepresentationType kEmpty
Definition: v8-internal.h:1842
Definition: v8-internal.h:1692
constexpr WrappedIterator & operator-=(difference_type n) noexcept
Definition: v8-internal.h:1804
constexpr WrappedIterator operator--(int) noexcept
Definition: v8-internal.h:1781
constexpr WrappedIterator & operator+=(difference_type n) noexcept
Definition: v8-internal.h:1796
constexpr const Iterator & base() const noexcept
Definition: v8-internal.h:1818
std::conditional_t< std::is_void_v< ElementType >, typename std::iterator_traits< Iterator >::value_type, ElementType > value_type
Definition: v8-internal.h:1706
constexpr WrappedIterator & operator++() noexcept
Definition: v8-internal.h:1767
constexpr pointer operator->() const noexcept
Definition: v8-internal.h:1728
constexpr reference operator[](difference_type n) const noexcept
Definition: v8-internal.h:1813
typename std::iterator_traits< Iterator >::difference_type difference_type
Definition: v8-internal.h:1702
constexpr auto operator<=>(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1744
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:1714
constexpr WrappedIterator & operator--() noexcept
Definition: v8-internal.h:1777
constexpr WrappedIterator() noexcept=default
typename std::iterator_traits< Iterator >::iterator_category iterator_category
Definition: v8-internal.h:1716
constexpr reference operator*() const noexcept
Definition: v8-internal.h:1727
friend constexpr WrappedIterator operator+(difference_type n, const WrappedIterator &x) noexcept
Definition: v8-internal.h:1792
constexpr WrappedIterator operator++(int) noexcept
Definition: v8-internal.h:1771
constexpr WrappedIterator operator-(difference_type n) const noexcept
Definition: v8-internal.h:1800
std::conditional_t< std::is_void_v< ElementType >, typename std::iterator_traits< Iterator >::pointer, std::add_pointer_t< ElementType > > pointer
Definition: v8-internal.h:1710
constexpr bool operator==(const WrappedIterator< OtherIterator, OtherElementType > &other) const noexcept
Definition: v8-internal.h:1737
Definition: v8-internal.h:1661
Definition: v8-internal.h:1658
const intptr_t kHeapObjectTagMask
Definition: v8-internal.h:61
constexpr uint64_t kCppHeapPointerMarkBit
Definition: v8-internal.h:416
constexpr int kCodePointerTableEntrySizeLog2
Definition: v8-internal.h:960
constexpr bool kRuntimeGeneratedCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:972
internal::Isolate * IsolateFromNeverReadOnlySpaceObject(Address obj)
constexpr uint64_t kExternalPointerTagShift
Definition: v8-internal.h:366
IndirectPointerHandle TrustedPointerHandle
Definition: v8-internal.h:891
const int kApiSystemPointerSize
Definition: v8-internal.h:51
constexpr const char * ToString(ExternalPointerTag tag)
Definition: v8-internal.h:740
constexpr bool SandboxIsEnabled()
Definition: v8-internal.h:206
const int kApiDoubleSize
Definition: v8-internal.h:52
constexpr size_t kMaxCppHeapPointers
Definition: v8-internal.h:439
constexpr intptr_t kIntptrAllBitsSet
Definition: v8-internal.h:79
constexpr int GB
Definition: v8-internal.h:43
void VerifyHandleIsNonEmpty(bool is_empty)
const int kApiInt32Size
Definition: v8-internal.h:53
const int kForwardingTagSize
Definition: v8-internal.h:68
uint32_t CppHeapPointerHandle
Definition: v8-internal.h:401
const intptr_t kForwardingTagMask
Definition: v8-internal.h:69
void PrintPropertyCallbackInfo(void *property_callback_info)
constexpr ExternalPointerTagRange kAnyManagedResourceExternalPointerTag(kFirstManagedResourceTag, kLastManagedResourceTag)
IndirectPointerHandle CodePointerHandle
Definition: v8-internal.h:933
constexpr uint64_t kExternalPointerPayloadMask
Definition: v8-internal.h:373
const int kSmiTagSize
Definition: v8-internal.h:73
const int kApiInt64Size
Definition: v8-internal.h:54
constexpr ExternalPointerTagRange kAnyExternalPointerTagRange(kFirstExternalPointerTag, kLastExternalPointerTag)
constexpr uint64_t kExternalPointerTagMask
Definition: v8-internal.h:367
constexpr int kCodePointerTableEntryCodeObjectOffset
Definition: v8-internal.h:968
constexpr int kTrustedPointerTableEntrySizeLog2
Definition: v8-internal.h:908
constexpr int kTrustedPointerTableEntrySize
Definition: v8-internal.h:907
constexpr uint64_t kCppHeapPointerPayloadShift
Definition: v8-internal.h:418
constexpr ExternalPointer_t kNullExternalPointer
Definition: v8-internal.h:393
Address ExternalPointer_t
Definition: v8-internal.h:390
uint32_t IndirectPointerHandle
Definition: v8-internal.h:871
constexpr CppHeapPointer_t kNullCppHeapPointer
Definition: v8-internal.h:413
const int kApiSizetSize
Definition: v8-internal.h:55
constexpr uint64_t kExternalPointerTagAndMarkbitMask
Definition: v8-internal.h:372
constexpr size_t kMaxExternalPointers
Definition: v8-internal.h:361
constexpr ExternalPointerTagRange kAnySharedManagedExternalPointerTagRange(kFirstSharedManagedExternalPointerTag, kLastSharedManagedExternalPointerTag)
constexpr size_t kCodePointerTableReservationSize
Definition: v8-internal.h:938
constexpr TrustedPointerHandle kNullTrustedPointerHandle
Definition: v8-internal.h:903
const int kWeakHeapObjectTag
Definition: v8-internal.h:59
constexpr ExternalPointerHandle kNullExternalPointerHandle
Definition: v8-internal.h:394
constexpr ExternalPointerTagRange kAnyMaybeReadOnlyExternalPointerTagRange(kFirstMaybeReadOnlyExternalPointerTag, kLastMaybeReadOnlyExternalPointerTag)
constexpr ExternalPointerTag kFirstSharedManagedExternalPointerTag
Definition: v8-internal.h:798
constexpr uintptr_t kUintptrAllBitsSet
Definition: v8-internal.h:80
const int kForwardingTag
Definition: v8-internal.h:67
const intptr_t kHeapObjectReferenceTagMask
Definition: v8-internal.h:62
constexpr bool SmiValuesAre31Bits()
Definition: v8-internal.h:194
constexpr size_t kMaxTrustedPointers
Definition: v8-internal.h:910
bool ShouldThrowOnError(internal::Isolate *isolate)
constexpr uint64_t kCppHeapPointerTagShift
Definition: v8-internal.h:417
constexpr ExternalPointerTagRange kAnyInterceptorInfoExternalPointerTagRange(kFirstInterceptorInfoExternalPointerTag, kLastInterceptorInfoExternalPointerTag)
constexpr ExternalPointerTag kFirstManagedExternalPointerTag
Definition: v8-internal.h:781
constexpr int KB
Definition: v8-internal.h:41
constexpr bool kBuiltinCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:973
constexpr uint32_t kTrustedPointerHandleShift
Definition: v8-internal.h:900
constexpr uint32_t kCodePointerHandleShift
Definition: v8-internal.h:942
constexpr ExternalPointerTagRange kAnyManagedExternalPointerTagRange(kFirstManagedExternalPointerTag, kLastManagedExternalPointerTag)
const int kHeapObjectTag
Definition: v8-internal.h:58
const int kSmiShiftSize
Definition: v8-internal.h:190
constexpr size_t kMaxCodePointers
Definition: v8-internal.h:962
SmiTagging< kApiTaggedSize > PlatformSmiTagging
Definition: v8-internal.h:185
ExternalPointerTag
Definition: v8-internal.h:662
@ kApiIndexedPropertyDescriptorCallbackTag
Definition: v8-internal.h:713
@ kFirstMaybeReadOnlyExternalPointerTag
Definition: v8-internal.h:696
@ kExternalPointerEvacuationEntryTag
Definition: v8-internal.h:734
@ kFirstSharedExternalPointerTag
Definition: v8-internal.h:674
@ kApiNamedPropertyDefinerCallbackTag
Definition: v8-internal.h:707
@ kLastSharedExternalPointerTag
Definition: v8-internal.h:678
@ kApiIndexedPropertySetterCallbackTag
Definition: v8-internal.h:712
@ kLastExternalPointerTag
Definition: v8-internal.h:737
@ kLastExternalTypeTag
Definition: v8-internal.h:690
@ kApiIndexedPropertyGetterCallbackTag
Definition: v8-internal.h:711
@ kApiNamedPropertyDescriptorCallbackTag
Definition: v8-internal.h:706
@ kAccessorInfoGetterTag
Definition: v8-internal.h:698
@ kApiIndexedPropertyDefinerCallbackTag
Definition: v8-internal.h:714
@ kFirstExternalTypeTag
Definition: v8-internal.h:689
@ kExternalStringResourceTag
Definition: v8-internal.h:676
@ kAccessorInfoSetterTag
Definition: v8-internal.h:699
@ kApiNamedPropertyDeleterCallbackTag
Definition: v8-internal.h:708
@ kApiNamedPropertyGetterCallbackTag
Definition: v8-internal.h:704
@ kApiNamedPropertySetterCallbackTag
Definition: v8-internal.h:705
@ kApiIndexedPropertyIndexOfCallbackTag
Definition: v8-internal.h:717
@ kApiIndexedPropertyEnumeratorCallbackTag
Definition: v8-internal.h:716
@ kExternalPointerFreeEntryTag
Definition: v8-internal.h:735
@ kFirstInterceptorInfoExternalPointerTag
Definition: v8-internal.h:702
@ kWaiterQueueNodeTag
Definition: v8-internal.h:675
@ kExternalPointerNullTag
Definition: v8-internal.h:664
@ kExternalStringResourceDataTag
Definition: v8-internal.h:677
@ kWasmStackMemoryTag
Definition: v8-internal.h:723
@ kLastManagedResourceTag
Definition: v8-internal.h:731
@ kFastApiExternalTypeTag
Definition: v8-internal.h:695
@ kExternalPointerZappedEntryTag
Definition: v8-internal.h:733
@ kApiNamedPropertyQueryCallbackTag
Definition: v8-internal.h:703
@ kFirstEmbedderDataTag
Definition: v8-internal.h:685
@ kApiIndexedPropertyQueryCallbackTag
Definition: v8-internal.h:710
@ kApiIndexedPropertyDeleterCallbackTag
Definition: v8-internal.h:715
@ kLastInterceptorInfoExternalPointerTag
Definition: v8-internal.h:718
@ kNativeContextMicrotaskQueueTag
Definition: v8-internal.h:682
@ kLastMaybeReadOnlyExternalPointerTag
Definition: v8-internal.h:721
@ kLastEmbedderDataTag
Definition: v8-internal.h:686
@ kArrayBufferExtensionTag
Definition: v8-internal.h:730
@ kFirstExternalPointerTag
Definition: v8-internal.h:663
@ kApiNamedPropertyEnumeratorCallbackTag
Definition: v8-internal.h:709
@ kFunctionTemplateInfoCallbackTag
Definition: v8-internal.h:697
const int kSmiValueSize
Definition: v8-internal.h:191
constexpr ExternalPointerTag kLastSharedManagedExternalPointerTag
Definition: v8-internal.h:800
constexpr ExternalPointerTagRange kAnyForeignExternalPointerTagRange(kFirstForeignExternalPointerTag, kLastForeignExternalPointerTag)
constexpr bool SmiValuesAre32Bits()
Definition: v8-internal.h:195
constexpr ExternalPointerTag kLastManagedExternalPointerTag
Definition: v8-internal.h:783
TagRange< ExternalPointerTag > ExternalPointerTagRange
Definition: v8-internal.h:752
constexpr ExternalPointerTag kFirstForeignExternalPointerTag
Definition: v8-internal.h:771
constexpr IndirectPointerHandle kNullIndirectPointerHandle
Definition: v8-internal.h:874
uintptr_t Address
Definition: v8-internal.h:38
void PerformCastCheck(T *data)
Definition: v8-internal.h:1602
void PrintFunctionCallbackInfo(void *function_callback_info)
constexpr size_t kTrustedPointerTableReservationSize
Definition: v8-internal.h:896
uint32_t ExternalPointerHandle
Definition: v8-internal.h:382
const intptr_t kSmiTagMask
Definition: v8-internal.h:74
const int kHeapObjectTagSize
Definition: v8-internal.h:60
const int kSmiMaxValue
Definition: v8-internal.h:193
constexpr bool Is64()
Definition: v8-internal.h:196
constexpr bool kAllCodeObjectsLiveInTrustedSpace
Definition: v8-internal.h:974
const int kSmiTag
Definition: v8-internal.h:72
constexpr ExternalPointerTag kFirstManagedResourceTag
Definition: v8-internal.h:792
constexpr CodePointerHandle kNullCodePointerHandle
Definition: v8-internal.h:945
Address CppHeapPointer_t
Definition: v8-internal.h:410
constexpr CppHeapPointerHandle kNullCppHeapPointerHandle
Definition: v8-internal.h:414
constexpr int kGarbageCollectionReasonMaxValue
Definition: v8-internal.h:1613
constexpr int kCodePointerTableEntrySize
Definition: v8-internal.h:959
constexpr uint32_t kCodePointerHandleMarker
Definition: v8-internal.h:954
const int kSmiMinValue
Definition: v8-internal.h:192
constexpr int MB
Definition: v8-internal.h:42
constexpr uint64_t kExternalPointerShiftedTagMask
Definition: v8-internal.h:368
constexpr uint64_t kExternalPointerMarkBit
Definition: v8-internal.h:365
Address SandboxedPointer_t
Definition: v8-internal.h:216
const int kApiTaggedSize
Definition: v8-internal.h:175
constexpr bool PointerCompressionIsEnabled()
Definition: v8-internal.h:178
constexpr ExternalPointerTag kLastForeignExternalPointerTag
Definition: v8-internal.h:773
Definition: libplatform.h:15
Definition: v8-internal.h:1586
static void Perform(T *data)
Definition: v8-internal.h:990
static constexpr uint32_t kSizeInBytes
Definition: v8-internal.h:991
typename Iterator::iterator_concept iterator_concept
Definition: v8-internal.h:1672
Definition: v8-internal.h:1668
static constexpr bool IsValidSmi(uint64_t value)
Definition: v8-internal.h:127
static constexpr bool IsValidSmi(int64_t value)
Definition: v8-internal.h:120
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:100
static constexpr int SmiToInt(Address value)
Definition: v8-internal.h:92
static constexpr bool IsValidSmi(T value)
Definition: v8-internal.h:150
static constexpr int SmiToInt(Address value)
Definition: v8-internal.h:142
Definition: v8-internal.h:77
Definition: v8-internal.h:510
constexpr size_t Size() const
Definition: v8-internal.h:537
constexpr bool IsEmpty() const
Definition: v8-internal.h:535
Tag last
Definition: v8-internal.h:568
Tag first
Definition: v8-internal.h:567
constexpr bool operator==(const TagRange other) const
Definition: v8-internal.h:557
constexpr bool Contains(Tag tag) const
Definition: v8-internal.h:545
constexpr TagRange()
Definition: v8-internal.h:532
constexpr TagRange(Tag tag)
Definition: v8-internal.h:528
constexpr size_t hash_value() const
Definition: v8-internal.h:561
constexpr TagRange(Tag first, Tag last)
Definition: v8-internal.h:516
constexpr bool Contains(TagRange tag_range) const
Definition: v8-internal.h:553
#define FOREIGN_TAG_LIST(V)
Definition: v8-internal.h:604
#define AS_ENUM(name)
Definition: v8-internal.h:725
#define V8_EXTERNAL_POINTER_TAG_COUNT
Definition: v8-internal.h:451
#define MANAGED_TAG_LIST(V)
Definition: v8-internal.h:573
#define SHARED_MANAGED_TAG_LIST(V)
Definition: v8-internal.h:571
#define ENUM_CASE(name)
#define GET_FIRST(LIST)
Definition: v8-internal.h:756
#define V8_EMBEDDER_DATA_TAG_COUNT
Definition: v8-internal.h:446
#define GET_LAST(LIST)
Definition: v8-internal.h:762
#define V8_EXPORT
Definition: v8config.h:856
#define V8_INLINE
Definition: v8config.h:510
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:623
#define V8_LIKELY(condition)
Definition: v8config.h:670