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_
Definition: custom-space.h:24
virtual ~CustomSpaceBase()=default
virtual CustomSpaceIndex GetCustomSpaceIndex() const =0
virtual bool IsCompactable() const =0
Definition: custom-space.h:49
static constexpr bool kSupportsCompaction
Definition: custom-space.h:55
CustomSpaceIndex GetCustomSpaceIndex() const final
Definition: custom-space.h:57
bool IsCompactable() const final
Definition: custom-space.h:60
Definition: allocation.h:38
Definition: custom-space.h:15
size_t value
Definition: custom-space.h:17
constexpr CustomSpaceIndex(size_t value)
Definition: custom-space.h:16
Definition: custom-space.h:69
void Space
Definition: custom-space.h:70
static constexpr bool value
Definition: custom-space.h:77
static constexpr bool value
Definition: custom-space.h:89