Loading...
Searching...
No Matches
base-page-handle.h
Go to the documentation of this file.
1// Copyright 2022 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
6#define INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
7
8#include "cppgc/heap-handle.h"
11#include "v8config.h" // NOLINT(build/include_directory)
12
13namespace cppgc {
14namespace internal {
15
16// The class is needed in the header to allow for fast access to HeapHandle in
17// the write barrier.
19 public:
20 static V8_INLINE BasePageHandle* FromPayload(void* payload) {
21 return reinterpret_cast<BasePageHandle*>(
22 reinterpret_cast<uintptr_t>(payload) & ~(api_constants::kPageSize - 1));
23 }
24 static V8_INLINE const BasePageHandle* FromPayload(const void* payload) {
25 return FromPayload(const_cast<void*>(payload));
26 }
27
29 const HeapHandle& heap_handle() const { return heap_handle_; }
30
31 protected:
33 CPPGC_DCHECK(reinterpret_cast<uintptr_t>(this) % api_constants::kPageSize ==
34 0);
35 }
36
38};
39
40} // namespace internal
41} // namespace cppgc
42
43#endif // INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
Definition: heap-handle.h:21
Definition: base-page-handle.h:18
HeapHandle & heap_handle_
Definition: base-page-handle.h:37
static const BasePageHandle * FromPayload(const void *payload)
Definition: base-page-handle.h:24
BasePageHandle(HeapHandle &heap_handle)
Definition: base-page-handle.h:32
HeapHandle & heap_handle()
Definition: base-page-handle.h:28
static BasePageHandle * FromPayload(void *payload)
Definition: base-page-handle.h:20
const HeapHandle & heap_handle() const
Definition: base-page-handle.h:29
#define CPPGC_DCHECK(condition)
Definition: logging.h:36
Definition: allocation.h:38
#define V8_INLINE
Definition: v8config.h:499