v8
12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
garbage-collected.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_GARBAGE_COLLECTED_H_
6
#define INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
7
8
#include "
cppgc/internal/api-constants.h
"
9
#include "
cppgc/platform.h
"
10
#include "
cppgc/trace-trait.h
"
11
#include "
cppgc/type-traits.h
"
12
13
namespace
cppgc
{
14
15
class
Visitor;
16
52
template
<
typename
T>
53
class
GarbageCollected
{
54
public
:
55
using
IsGarbageCollectedTypeMarker
= void;
56
using
ParentMostGarbageCollectedType
= T;
57
58
// Must use MakeGarbageCollected.
59
void
*
operator
new
(size_t) =
delete
;
60
void
*
operator
new
[](size_t) =
delete
;
61
// The garbage collector is taking care of reclaiming the object. Also,
62
// virtual destructor requires an unambiguous, accessible 'operator delete'.
63
void
operator
delete
(
void
*) {
64
#ifdef V8_ENABLE_CHECKS
65
internal::Fatal
(
66
"Manually deleting a garbage collected object is not allowed"
);
67
#endif
// V8_ENABLE_CHECKS
68
}
69
void
operator
delete
[](
void
*) =
delete
;
70
71
protected
:
72
GarbageCollected
() =
default
;
73
};
74
93
class
GarbageCollectedMixin
{
94
public
:
95
using
IsGarbageCollectedMixinTypeMarker
= void;
96
101
virtual
void
Trace
(
cppgc::Visitor
*)
const
{}
102
};
103
104
}
// namespace cppgc
105
106
#endif
// INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
api-constants.h
cppgc::GarbageCollected
Definition
garbage-collected.h:53
cppgc::GarbageCollected::ParentMostGarbageCollectedType
T ParentMostGarbageCollectedType
Definition
garbage-collected.h:56
cppgc::GarbageCollected::GarbageCollected
GarbageCollected()=default
cppgc::GarbageCollected::IsGarbageCollectedTypeMarker
void IsGarbageCollectedTypeMarker
Definition
garbage-collected.h:55
cppgc::GarbageCollectedMixin
Definition
garbage-collected.h:93
cppgc::GarbageCollectedMixin::IsGarbageCollectedMixinTypeMarker
void IsGarbageCollectedMixinTypeMarker
Definition
garbage-collected.h:95
cppgc::GarbageCollectedMixin::Trace
virtual void Trace(cppgc::Visitor *) const
Definition
garbage-collected.h:101
cppgc::Visitor
Definition
visitor.h:56
cppgc::internal::Fatal
V8_EXPORT void Fatal(const std::string &reason=std::string(), const SourceLocation &=SourceLocation::Current())
cppgc
Definition
allocation.h:38
platform.h
trace-trait.h
type-traits.h
include
cppgc
garbage-collected.h
Generated on Thu Jul 11 2024 21:30:41 for v8 by
1.9.7