summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/cppgc/member-storage.cc
blob: b315ecfda2a44edc6556c35cf056bb9a59b29d3d (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
34
35
36
37
38
39
40
41
42
43
// 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.

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

#include "include/cppgc/garbage-collected.h"
#include "include/cppgc/member.h"
#include "src/base/compiler-specific.h"
#include "src/base/macros.h"

namespace cppgc {
namespace internal {

#if defined(CPPGC_POINTER_COMPRESSION)
alignas(api_constants::kCachelineSize) CageBaseGlobal::Base
    CageBaseGlobal::g_base_ = {CageBaseGlobal::kLowerHalfWordMask};
#endif  // defined(CPPGC_POINTER_COMPRESSION)

// Debugging helpers.

#if defined(CPPGC_POINTER_COMPRESSION)
extern "C" V8_DONT_STRIP_SYMBOL V8_EXPORT_PRIVATE void*
_cppgc_internal_Decompress_Compressed_Pointer(uint32_t cmprsd) {
  return CompressedPointer::Decompress(cmprsd);
}
#endif  // !defined(CPPGC_POINTER_COMPRESSION)

class MemberDebugHelper final {
 public:
  static void* Uncompress(MemberBase<DefaultMemberStorage>* m) {
    return const_cast<void*>(m->GetRaw());
  }
};

extern "C" V8_DONT_STRIP_SYMBOL V8_EXPORT_PRIVATE void*
_cppgc_internal_Uncompress_Member(void* m) {
  return MemberDebugHelper::Uncompress(
      static_cast<MemberBase<DefaultMemberStorage>*>(m));
}

}  // namespace internal
}  // namespace cppgc