5 #ifndef INCLUDE_V8_INTERNAL_H_
6 #define INCLUDE_V8_INTERNAL_H_
11 #include <type_traits>
30 static const Address kNullAddress = 0;
59 template <size_t tagged_ptr_size>
68 struct SmiTagging<4> {
78 return static_cast<int32_t>(
static_cast<uint32_t>(value)) >> shift_bits;
84 return (
static_cast<uintptr_t>(value) -
93 struct SmiTagging<8> {
103 return static_cast<
int>(
static_cast<intptr_t>(value) >> shift_bits);
107 return (value ==
static_cast<int32_t>(value));
111 #ifdef V8_COMPRESS_POINTERS
114 "Pointer compression can be enabled only for 64-bit architectures");
125 #ifdef V8_HEAP_SANDBOX
157 #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
179 ExternalPointer_t pointer,
199 #ifdef V8_MAP_PACKING
220 #ifdef V8_HEAP_SANDBOX
288 #ifdef V8_MAP_PACKING
301 #ifdef V8_ENABLE_CHECKS
302 CheckInitializedImpl(isolate);
325 #ifdef V8_MAP_PACKING
326 map = UnpackMapWord(map);
342 return *addr &
static_cast<uint8_t>(1U << shift);
348 uint8_t mask =
static_cast<uint8_t>(1U << shift);
349 *addr =
static_cast<uint8_t>((*addr & ~mask) | (value << shift));
367 *
reinterpret_cast<
void**>(addr) = data;
375 return *
reinterpret_cast<
void*
const*>(addr);
381 ++(*
reinterpret_cast<size_t*>(addr));
391 template <
typename T>
395 #ifdef V8_COMPRESS_POINTERS
396 if (
sizeof(T) > kApiTaggedSize) {
402 memcpy(&r,
reinterpret_cast<
void*>(addr),
sizeof(T));
406 return *
reinterpret_cast<
const T*>(addr);
411 #ifdef V8_COMPRESS_POINTERS
412 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
413 internal::Address base =
414 GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
415 return base +
static_cast<internal::Address>(
static_cast<uintptr_t>(value));
423 #ifdef V8_COMPRESS_POINTERS
424 uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
425 return static_cast<internal::Address>(
static_cast<uintptr_t>(value));
433 #ifdef V8_HEAP_SANDBOX
434 return internal::IsolateFromNeverReadOnlySpaceObject(obj);
442 const Isolate* isolate, ExternalPointer_t encoded_pointer,
444 #ifdef V8_HEAP_SANDBOX
445 return internal::DecodeExternalPointerImpl(isolate, encoded_pointer, tag);
447 return encoded_pointer;
454 #ifdef V8_HEAP_SANDBOX
455 internal::ExternalPointer_t encoded_value =
456 ReadRawField<uint32_t>(heap_object_ptr, offset);
458 return encoded_value ? DecodeExternalPointer(isolate, encoded_value, tag)
465 #ifdef V8_COMPRESS_POINTERS
487 template <
bool PerformCheck>
506 !std::is_same<
Data, std::remove_cv_t<T>>::value>::Perform(data);
517 uint32_t max_length);
521 uint32_t max_length);