File indexing completed on 2025-02-23 10:08:49
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) &
0023 ~(api_constants::kPageSize - 1)) +
0024 api_constants::kGuardPageSize);
0025 }
0026 static V8_INLINE const BasePageHandle* FromPayload(const void* payload) {
0027 return FromPayload(const_cast<void*>(payload));
0028 }
0029
0030 HeapHandle& heap_handle() { return heap_handle_; }
0031 const HeapHandle& heap_handle() const { return heap_handle_; }
0032
0033 protected:
0034 explicit BasePageHandle(HeapHandle& heap_handle) : heap_handle_(heap_handle) {
0035 CPPGC_DCHECK(reinterpret_cast<uintptr_t>(this) % api_constants::kPageSize ==
0036 api_constants::kGuardPageSize);
0037 }
0038
0039 HeapHandle& heap_handle_;
0040 };
0041
0042 }
0043 }
0044
0045 #endif