5#ifndef INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
6#define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
15#if defined(CPPGC_CAGED_HEAP)
22 V8_INLINE static uintptr_t OffsetFromAddress(
const void* address) {
23 return reinterpret_cast<uintptr_t
>(address) &
24 (api_constants::kCagedHeapReservationAlignment - 1);
27 V8_INLINE static bool IsWithinCage(
const void* address) {
29 return (
reinterpret_cast<uintptr_t
>(address) &
30 ~(api_constants::kCagedHeapReservationAlignment - 1)) ==
34 V8_INLINE static bool AreWithinCage(
const void* addr1,
const void* addr2) {
35#if defined(CPPGC_2GB_CAGE)
36 static constexpr size_t kHalfWordShift =
sizeof(uint32_t) * CHAR_BIT - 1;
38 static constexpr size_t kHalfWordShift =
sizeof(uint32_t) * CHAR_BIT;
40 static_assert((
static_cast<size_t>(1) << kHalfWordShift) ==
41 api_constants::kCagedHeapReservationSize);
43 return !(((
reinterpret_cast<uintptr_t
>(addr1) ^ g_heap_base_) |
44 (
reinterpret_cast<uintptr_t
>(addr2) ^ g_heap_base_)) >>
48 V8_INLINE static uintptr_t GetBase() {
return g_heap_base_; }
51 friend class CagedHeap;
53 static uintptr_t g_heap_base_;
#define CPPGC_DCHECK(condition)