v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
custom-space.h
Go to the documentation of this file.
1// Copyright 2020 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_CUSTOM_SPACE_H_
6#define INCLUDE_CPPGC_CUSTOM_SPACE_H_
7
8#include <stddef.h>
9
10namespace cppgc {
11
16 constexpr CustomSpaceIndex(size_t value) : value(value) {} // NOLINT
17 size_t value;
18};
19
25 public:
26 virtual ~CustomSpaceBase() = default;
28 virtual bool IsCompactable() const = 0;
29};
30
48template <typename ConcreteCustomSpace>
50 public:
55 static constexpr bool kSupportsCompaction = false;
56
58 return ConcreteCustomSpace::kSpaceIndex;
59 }
60 bool IsCompactable() const final {
61 return ConcreteCustomSpace::kSupportsCompaction;
62 }
63};
64
68template <typename T, typename = void>
69struct SpaceTrait {
70 using Space = void;
71};
72
73namespace internal {
74
75template <typename CustomSpace>
77 static constexpr bool value = CustomSpace::kSupportsCompaction;
78};
79
80template <>
82 // Non-custom spaces are by default not compactable.
83 static constexpr bool value = false;
84};
85
86template <typename T>
88 public:
89 static constexpr bool value =
91};
92
93} // namespace internal
94
95} // namespace cppgc
96
97#endif // INCLUDE_CPPGC_CUSTOM_SPACE_H_
virtual bool IsCompactable() const =0
virtual ~CustomSpaceBase()=default
virtual CustomSpaceIndex GetCustomSpaceIndex() const =0
bool IsCompactable() const final
static constexpr bool kSupportsCompaction
CustomSpaceIndex GetCustomSpaceIndex() const final
constexpr CustomSpaceIndex(size_t value)