v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
explicit-management.h
Go to the documentation of this file.
1// Copyright 2021 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_EXPLICIT_MANAGEMENT_H_
6#define INCLUDE_CPPGC_EXPLICIT_MANAGEMENT_H_
7
8#include <cstddef>
9
10#include "cppgc/allocation.h"
12#include "cppgc/type-traits.h"
13
14namespace cppgc {
15
16class HeapHandle;
17
18namespace subtle {
19
20template <typename T>
21void FreeUnreferencedObject(HeapHandle& heap_handle, T& object);
22template <typename T>
23bool Resize(T& object, AdditionalBytes additional_bytes);
24
25} // namespace subtle
26
27namespace internal {
28
30 private:
31 V8_EXPORT static void FreeUnreferencedObject(HeapHandle&, void*);
32 V8_EXPORT static bool Resize(void*, size_t);
33
34 template <typename T>
35 friend void subtle::FreeUnreferencedObject(HeapHandle&, T&);
36 template <typename T>
38};
39} // namespace internal
40
41namespace subtle {
42
60template <typename T>
61void FreeUnreferencedObject(HeapHandle& heap_handle, T& object) {
62 static_assert(IsGarbageCollectedTypeV<T>,
63 "Object must be of type GarbageCollected.");
65 &object);
66}
67
89template <typename T>
90bool Resize(T& object, AdditionalBytes additional_bytes) {
91 static_assert(IsGarbageCollectedTypeV<T>,
92 "Object must be of type GarbageCollected.");
94 &object, sizeof(T) + additional_bytes.value);
95}
96
97} // namespace subtle
98} // namespace cppgc
99
100#endif // INCLUDE_CPPGC_EXPLICIT_MANAGEMENT_H_
friend void subtle::FreeUnreferencedObject(HeapHandle &, T &)
friend bool subtle::Resize(T &, AdditionalBytes)
bool Resize(T &object, AdditionalBytes additional_bytes)
void FreeUnreferencedObject(HeapHandle &heap_handle, T &object)
#define V8_EXPORT
Definition v8config.h:578