v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
liveness-broker.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_LIVENESS_BROKER_H_
6
#define INCLUDE_CPPGC_LIVENESS_BROKER_H_
7
8
#include "
cppgc/heap.h
"
9
#include "
cppgc/member.h
"
10
#include "
cppgc/sentinel-pointer.h
"
11
#include "
cppgc/trace-trait.h
"
12
#include "
v8config.h
"
// NOLINT(build/include_directory)
13
14
namespace
cppgc
{
15
16
namespace
internal
{
17
class
LivenessBrokerFactory;
18
}
// namespace internal
19
44
class
V8_EXPORT
LivenessBroker
final {
45
public
:
46
template
<
typename
T>
47
bool
IsHeapObjectAlive
(
const
T*
object
)
const
{
48
// - nullptr objects are considered alive to allow weakness to be used from
49
// stack while running into a conservative GC. Treating nullptr as dead
50
// would mean that e.g. custom collections could not be strongified on
51
// stack.
52
// - Sentinel pointers are also preserved in weakness and not cleared.
53
return
!
object
||
object
==
kSentinelPointer
||
54
IsHeapObjectAliveImpl(
55
TraceTrait<T>::GetTraceDescriptor
(
object
).base_object_payload);
56
}
57
58
template
<
typename
T>
59
bool
IsHeapObjectAlive
(
const
WeakMember<T>
& weak_member)
const
{
60
return
IsHeapObjectAlive<T>(weak_member.Get());
61
}
62
63
template
<
typename
T>
64
bool
IsHeapObjectAlive
(
const
UntracedMember<T>
& untraced_member)
const
{
65
return
IsHeapObjectAlive<T>(untraced_member.Get());
66
}
67
68
private
:
69
LivenessBroker
() =
default
;
70
71
bool
IsHeapObjectAliveImpl(
const
void
*)
const
;
72
73
friend
class
internal::LivenessBrokerFactory
;
74
};
75
76
}
// namespace cppgc
77
78
#endif
// INCLUDE_CPPGC_LIVENESS_BROKER_H_
cppgc::LivenessBroker
Definition
liveness-broker.h:44
cppgc::LivenessBroker::IsHeapObjectAlive
bool IsHeapObjectAlive(const T *object) const
Definition
liveness-broker.h:47
cppgc::LivenessBroker::IsHeapObjectAlive
bool IsHeapObjectAlive(const WeakMember< T > &weak_member) const
Definition
liveness-broker.h:59
cppgc::LivenessBroker::IsHeapObjectAlive
bool IsHeapObjectAlive(const UntracedMember< T > &untraced_member) const
Definition
liveness-broker.h:64
cppgc::LivenessBroker::LivenessBroker
LivenessBroker()=default
cppgc::internal::BasicMember
Definition
type-traits.h:21
cppgc::internal::LivenessBrokerFactory
Definition
liveness-broker.h:14
heap.h
member.h
cppgc
Definition
cross-heap-remembered-set.h:14
cppgc::kSentinelPointer
constexpr internal::SentinelPointer kSentinelPointer
Definition
sentinel-pointer.h:35
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
sentinel-pointer.h
cppgc::TraceTrait
Definition
trace-trait.h:105
trace-trait.h
v8config.h
V8_EXPORT
#define V8_EXPORT
Definition
v8config.h:800
include
cppgc
liveness-broker.h
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0