V8  latest master commit
V8 is Google's open source JavaScript engine
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/trace-trait.h"
11 #include "v8config.h" // NOLINT(build/include_directory)
12 
13 namespace cppgc {
14 
15 namespace internal {
16 class LivenessBrokerFactory;
17 } // namespace internal
18 
20  public:
21  template <typename T>
22  bool IsHeapObjectAlive(const T* object) const {
23  return object &&
24  IsHeapObjectAliveImpl(
25  TraceTrait<T>::GetTraceDescriptor(object).base_object_payload);
26  }
27 
28  template <typename T>
29  bool IsHeapObjectAlive(const WeakMember<T>& weak_member) const {
30  return (weak_member != kSentinelPointer) &&
31  IsHeapObjectAlive<T>(weak_member.Get());
32  }
33 
34  template <typename T>
35  bool IsHeapObjectAlive(const UntracedMember<T>& untraced_member) const {
36  return (untraced_member != kSentinelPointer) &&
37  IsHeapObjectAlive<T>(untraced_member.Get());
38  }
39 
40  private:
41  LivenessBroker() = default;
42 
43  bool IsHeapObjectAliveImpl(const void*) const;
44 
45  friend class internal::LivenessBrokerFactory;
46 };
47 
48 } // namespace cppgc
49 
50 #endif // INCLUDE_CPPGC_LIVENESS_BROKER_H_
cppgc::LivenessBroker::IsHeapObjectAlive
bool IsHeapObjectAlive(const T *object) const
Definition: liveness-broker.h:22
cppgc::LivenessBroker::IsHeapObjectAlive
bool IsHeapObjectAlive(const UntracedMember< T > &untraced_member) const
Definition: liveness-broker.h:35
cppgc
Definition: allocation.h:18
v8config.h
V8_EXPORT
#define V8_EXPORT
Definition: v8config.h:467
cppgc::internal::BasicMember
Definition: pointer-policies.h:112
cppgc::LivenessBroker
Definition: liveness-broker.h:19
trace-trait.h
cppgc::internal::BasicMember::Get
T * Get() const
Definition: member.h:109
cppgc::kSentinelPointer
constexpr internal::SentinelPointer kSentinelPointer
Definition: pointer-policies.h:129
cppgc::LivenessBroker::IsHeapObjectAlive
bool IsHeapObjectAlive(const WeakMember< T > &weak_member) const
Definition: liveness-broker.h:29
member.h
cppgc::TraceTrait
Definition: trace-trait.h:35
heap.h