Coverage Report

Created: 2025-10-31 09:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/node/deps/v8/include/cppgc/internal/base-page-handle.h
Line
Count
Source
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"
9
#include "cppgc/internal/api-constants.h"
10
#include "cppgc/internal/logging.h"
11
#include "v8config.h"  // NOLINT(build/include_directory)
12
13
namespace cppgc {
14
namespace internal {
15
16
// The class is needed in the header to allow for fast access to HeapHandle in
17
// the write barrier.
18
class BasePageHandle {
19
 public:
20
0
  static V8_INLINE BasePageHandle* FromPayload(void* payload) {
21
0
    return reinterpret_cast<BasePageHandle*>(
22
0
        reinterpret_cast<uintptr_t>(payload) & ~(api_constants::kPageSize - 1));
23
0
  }
24
0
  static V8_INLINE const BasePageHandle* FromPayload(const void* payload) {
25
0
    return FromPayload(const_cast<void*>(payload));
26
0
  }
27
28
0
  HeapHandle& heap_handle() { return heap_handle_; }
29
0
  const HeapHandle& heap_handle() const { return heap_handle_; }
30
31
 protected:
32
0
  explicit BasePageHandle(HeapHandle& heap_handle) : heap_handle_(heap_handle) {
33
0
    CPPGC_DCHECK(reinterpret_cast<uintptr_t>(this) % api_constants::kPageSize ==
34
0
                 0);
35
0
  }
36
37
  HeapHandle& heap_handle_;
38
};
39
40
}  // namespace internal
41
}  // namespace cppgc
42
43
#endif  // INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_