File indexing completed on 2025-02-22 10:42:26
0001
0002
0003
0004
0005 #ifndef INCLUDE_CPPGC_LIVENESS_BROKER_H_
0006 #define INCLUDE_CPPGC_LIVENESS_BROKER_H_
0007
0008 #include "cppgc/heap.h"
0009 #include "cppgc/member.h"
0010 #include "cppgc/sentinel-pointer.h"
0011 #include "cppgc/trace-trait.h"
0012 #include "v8config.h" // NOLINT(build/include_directory)
0013
0014 namespace cppgc {
0015
0016 namespace internal {
0017 class LivenessBrokerFactory;
0018 }
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 class V8_EXPORT LivenessBroker final {
0045 public:
0046 template <typename T>
0047 bool IsHeapObjectAlive(const T* object) const {
0048
0049
0050
0051
0052
0053 return !object || object == kSentinelPointer ||
0054 IsHeapObjectAliveImpl(
0055 TraceTrait<T>::GetTraceDescriptor(object).base_object_payload);
0056 }
0057
0058 template <typename T>
0059 bool IsHeapObjectAlive(const WeakMember<T>& weak_member) const {
0060 return IsHeapObjectAlive<T>(weak_member.Get());
0061 }
0062
0063 template <typename T>
0064 bool IsHeapObjectAlive(const UntracedMember<T>& untraced_member) const {
0065 return IsHeapObjectAlive<T>(untraced_member.Get());
0066 }
0067
0068 private:
0069 LivenessBroker() = default;
0070
0071 bool IsHeapObjectAliveImpl(const void*) const;
0072
0073 friend class internal::LivenessBrokerFactory;
0074 };
0075
0076 }
0077
0078 #endif