File indexing completed on 2026-04-25 08:15:55
0001
0002
0003
0004
0005 #ifndef INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
0006 #define INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
0007
0008 #include "cppgc/heap-handle.h"
0009 #include "cppgc/internal/api-constants.h"
0010 #include "cppgc/internal/logging.h"
0011 #include "v8config.h" // NOLINT(build/include_directory)
0012
0013 namespace cppgc {
0014 namespace internal {
0015
0016
0017
0018 class BasePageHandle {
0019 public:
0020 static V8_INLINE BasePageHandle* FromPayload(void* payload) {
0021 return reinterpret_cast<BasePageHandle*>(
0022 reinterpret_cast<uintptr_t>(payload) & ~(api_constants::kPageSize - 1));
0023 }
0024 static V8_INLINE const BasePageHandle* FromPayload(const void* payload) {
0025 return FromPayload(const_cast<void*>(payload));
0026 }
0027
0028 HeapHandle& heap_handle() { return heap_handle_; }
0029 const HeapHandle& heap_handle() const { return heap_handle_; }
0030
0031 protected:
0032 explicit BasePageHandle(HeapHandle& heap_handle) : heap_handle_(heap_handle) {
0033 CPPGC_DCHECK(reinterpret_cast<uintptr_t>(this) % api_constants::kPageSize ==
0034 0);
0035 }
0036
0037 HeapHandle& heap_handle_;
0038 };
0039
0040 }
0041 }
0042
0043 #endif