5 #ifndef INCLUDE_V8_INTERNAL_H_ 6 #define INCLUDE_V8_INTERNAL_H_ 10 #include <type_traits> 26 static const Address kNullAddress = 0;
48 template <
size_t tagged_ptr_size>
58 return static_cast<int>(static_cast<intptr_t>(value)) >> shift_bits;
72 return static_cast<uintptr_t>(value) + 0x40000000U < 0x80000000U;
83 return static_cast<int>(static_cast<intptr_t>(value) >> shift_bits);
87 return (value == static_cast<int32_t>(value));
91 #ifdef V8_COMPRESS_POINTERS 94 "Pointer compression can be enabled only for 64-bit architectures");
97 #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH 135 #ifdef V8_COMPRESS_POINTERS 195 #ifdef V8_ENABLE_CHECKS 205 return PlatformSmiTagging::SmiToInt(value);
209 return internal::IntToSmi(value);
213 return PlatformSmiTagging::IsValidSmi(value);
233 return *addr & static_cast<uint8_t>(1U << shift);
239 uint8_t mask = static_cast<uint8_t>(1U << shift);
240 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
258 *reinterpret_cast<void**>(addr) = data;
266 return *reinterpret_cast<void* const*>(addr);
273 return reinterpret_cast<internal::Address*>(addr);
276 template <
typename T>
280 return *reinterpret_cast<const T*>(addr);
285 #ifdef V8_COMPRESS_POINTERS 286 int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
288 return root + static_cast<internal::Address>(static_cast<intptr_t>(value));
290 return ReadRawField<internal::Address>(heap_object_ptr, offset);
296 #ifdef V8_COMPRESS_POINTERS 297 int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
298 return static_cast<internal::Address>(static_cast<intptr_t>(value));
300 return ReadRawField<internal::Address>(heap_object_ptr, offset);
306 #ifdef V8_COMPRESS_POINTERS 307 int32_t value = ReadRawField<int32_t>(heap_object_ptr, offset);
311 root_mask & GetRootFromOnHeapAddress(heap_object_ptr);
312 return root_or_zero +
313 static_cast<internal::Address>(static_cast<intptr_t>(value));
315 return ReadRawField<internal::Address>(heap_object_ptr, offset);
319 #ifdef V8_COMPRESS_POINTERS 320 static constexpr
size_t kPtrComprHeapReservationSize =
size_t{1} << 32;
321 static constexpr
size_t kPtrComprIsolateRootBias =
322 kPtrComprHeapReservationSize / 2;
323 static constexpr
size_t kPtrComprIsolateRootAlignment =
size_t{1} << 32;
327 return (addr + kPtrComprIsolateRootBias) &
328 -static_cast<intptr_t>(kPtrComprIsolateRootAlignment);
333 template <
typename T>
337 A ctx = *reinterpret_cast<const A*>(context);
339 I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
341 I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
342 return I::ReadRawField<T>(embedder_data, value_offset);
344 #endif // V8_COMPRESS_POINTERS 349 template <
bool PerformCheck>
382 #endif // INCLUDE_V8_INTERNAL_H_ static const int kJSApiObjectType
const intptr_t kSmiTagMask
static V8_INLINE internal::Address ReadTaggedPointerField(internal::Address heap_object_ptr, int offset)
static V8_INLINE uint8_t GetNodeState(internal::Address *obj)
static V8_INLINE T ReadEmbedderData(const v8::Context *context, int index)
static const int kOddballKindOffset
static V8_INLINE int GetOddballKind(const internal::Address obj)
static const int kEmbedderDataSlotSize
static constexpr int kExternalAllocationSoftLimit
static const int kFirstNonstringType
static const int kNullValueRootIndex
static const uint32_t kNumIsolateDataSlots
static V8_INLINE void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
static const int kNodeIsActiveShift
static const int kExternalMemoryLimitOffset
static const int kExternalMemoryAtLastMarkCompactOffset
static const int kThrowOnError
static V8_INLINE internal::Address ReadTaggedAnyField(internal::Address heap_object_ptr, int offset)
SmiTagging< kApiTaggedSize > PlatformSmiTagging
static V8_INLINE int SmiValue(const internal::Address value)
static const int kStringResourceOffset
static const int kJSObjectHeaderSize
const intptr_t kHeapObjectTagMask
static const int kNodeStateIsNearDeathValue
V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate *isolate)
static const int kNodeFlagsOffset
static const int kFixedArrayHeaderSize
static const int kTheHoleValueRootIndex
static const int kNodeStateIsPendingValue
static const int kNodeStateIsWeakValue
static V8_INLINE bool IsExternalTwoByteString(int instance_type)
const int kApiSystemPointerSize
static const int kMapInstanceTypeOffset
static V8_INLINE bool HasHeapObjectTag(const internal::Address value)
static const int kNativeContextEmbedderDataOffset
static const int kInferShouldThrowMode
constexpr bool SmiValuesAre31Bits()
static V8_INLINE int GetInstanceType(const internal::Address obj)
static V8_INLINE void CheckInitialized(v8::Isolate *isolate)
V8_INLINE void PerformCastCheck(T *data)
static V8_INLINE constexpr internal::Address IntToSmi(int value)
constexpr bool SmiValuesAre32Bits()
static V8_INLINE T ReadRawField(internal::Address heap_object_ptr, int offset)
static const int kEmbedderDataArrayHeaderSize
static const int kDontThrow
static const int kUndefinedValueRootIndex
static V8_INLINE void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
static const int kOddballType
static V8_INLINE constexpr bool IsValidSmi(intptr_t value)
static const int kFalseValueRootIndex
static const int kEmptyStringRootIndex
static const int kNodeIsIndependentShift
V8_EXPORT internal::Isolate * IsolateFromNeverReadOnlySpaceObject(Address obj)
static V8_INLINE constexpr bool IsValidSmi(intptr_t value)
static V8_INLINE int SmiToInt(const internal::Address value)
static const int kHeapObjectMapOffset
static V8_INLINE void UpdateNodeState(internal::Address *obj, uint8_t value)
static V8_INLINE constexpr bool IsValidSmi(intptr_t value)
static V8_INLINE internal::Address * GetRoot(v8::Isolate *isolate, int index)
static const int kFullStringRepresentationMask
static V8_INLINE int SmiToInt(const internal::Address value)
const int kWeakHeapObjectTag
static const int kUndefinedOddballKind
const int kHeapObjectTagSize
static V8_INLINE internal::Address ReadTaggedSignedField(internal::Address heap_object_ptr, int offset)
static V8_INLINE uint8_t GetNodeFlag(internal::Address *obj, int shift)
static V8_INLINE void UpdateNodeFlag(internal::Address *obj, bool value, int shift)
static const int kNodeStateMask
static const int kStringEncodingMask
static const int kExternalTwoByteRepresentationTag
static const int kTrueValueRootIndex
static V8_EXPORT void CheckInitializedImpl(v8::Isolate *isolate)
static const int kJSSpecialApiObjectType
static const int kForeignType
static const int kIsolateRootsOffset
static void Perform(T *data)
static const int kIsolateEmbedderDataOffset
static const int kNullOddballKind
static const int kExternalOneByteRepresentationTag
static const int kExternalMemoryOffset
static const int kNodeClassIdOffset
static const int kJSObjectType
static const int kForeignAddressOffset