summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/cppgc/member-storage.h
blob: 829bea28d5db2a12cc2d93832ce401a8c8d6b194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_HEAP_CPPGC_MEMBER_STORAGE_H_
#define V8_HEAP_CPPGC_MEMBER_STORAGE_H_

#include "include/cppgc/internal/member-storage.h"

namespace cppgc {
namespace internal {

#if defined(CPPGC_POINTER_COMPRESSION)
class CageBaseGlobalUpdater final {
 public:
  CageBaseGlobalUpdater() = delete;
  static void UpdateCageBase(uintptr_t cage_base) {
    CPPGC_DCHECK(CageBaseGlobal::IsBaseConsistent());
    CPPGC_DCHECK(0u == (cage_base & CageBaseGlobal::kLowerHalfWordMask));
    CageBaseGlobal::g_base_ = cage_base | CageBaseGlobal::kLowerHalfWordMask;
  }

  static uintptr_t GetCageBase() {
    CPPGC_DCHECK(CageBaseGlobal::IsBaseConsistent());
    return CageBaseGlobal::g_base_ & ~CageBaseGlobal::kLowerHalfWordMask;
  }
};
#endif  // defined(CPPGC_POINTER_COMPRESSION)

}  // namespace internal
}  // namespace cppgc

#endif  // V8_HEAP_CPPGC_MEMBER_STORAGE_H_