5#ifndef INCLUDE_CPPGC_INTERNAL_POINTER_POLICIES_H_
6#define INCLUDE_CPPGC_INTERNAL_POINTER_POLICIES_H_
11#include "cppgc/internal/member-storage.h"
12#include "cppgc/internal/write-barrier.h"
13#include "cppgc/sentinel-pointer.h"
14#include "cppgc/source-location.h"
15#include "cppgc/type-traits.h"
22class PersistentRegion;
23class CrossThreadPersistentRegion;
28class UntracedMemberTag;
36#if defined(CPPGC_POINTER_COMPRESSION)
44#ifdef CPPGC_SLIM_WRITE_BARRIER
45 if (V8_UNLIKELY(WriteBarrier::IsEnabled()))
46 WriteBarrier::CombinedWriteBarrierSlow<SlotType>(slot);
48 WriteBarrier::
Params params;
49 const WriteBarrier::
Type type =
51 WriteBarrier(type, params, slot, value);
59 "Assigning storages of Member and UncompressedMember is not supported");
60#ifdef CPPGC_SLIM_WRITE_BARRIER
61 if (V8_UNLIKELY(WriteBarrier::IsEnabled()))
62 WriteBarrier::CombinedWriteBarrierSlow<SlotType>(slot);
64 WriteBarrier::
Params params;
65 const WriteBarrier::
Type type =
66 WriteBarrier::GetWriteBarrierType(slot, storage, params);
67 WriteBarrier(type, params, slot, storage
.Load());
71#if defined(CPPGC_POINTER_COMPRESSION)
77 "Assigning storages of Member and UncompressedMember is not supported");
78#ifdef CPPGC_SLIM_WRITE_BARRIER
92 const WriteBarrier::
Params& params,
93 const void* slot,
const void* value) {
96 WriteBarrier::GenerationalBarrier<
111#if defined(CPPGC_POINTER_COMPRESSION)
124 bool check_off_heap_assignments);
129template <
bool kCheckOffHeapAssignments>
133 template <
typename T>
138 CheckPointersImplTrampoline<T>::Call(
139 this,
static_cast<
const T*>(raw_pointer.Load()));
141#if defined(CPPGC_POINTER_COMPRESSION)
142 template <
typename T>
151 template <
typename T>
156 CheckPointersImplTrampoline<T>::Call(
this, ptr);
160 template <
typename T,
bool = IsCompleteV<T>>
161 struct CheckPointersImplTrampoline {
163 policy->CheckPointerImpl(ptr,
false, kCheckOffHeapAssignments);
167 template <
typename T>
168 struct CheckPointersImplTrampoline<T,
true> {
170 policy->CheckPointerImpl(ptr, IsGarbageCollectedTypeV<T>,
171 kCheckOffHeapAssignments);
178 template <
typename T>
180 template <
typename T>
182#if defined(CPPGC_POINTER_COMPRESSION)
183 template <
typename T>
188#ifdef CPPGC_ENABLE_SLOW_API_CHECKS
206 constexpr SourceLocation
Location()
const {
return location_; }
222 SourceLocation location_;
227 constexpr SourceLocation
Location()
const {
return {}; }
234#if CPPGC_SUPPORTS_OBJECT_NAMES
241 using IsStrongPersistent = std::true_type;
246 using IsStrongPersistent = std::false_type;
251 using IsStrongPersistent = std::true_type;
257 using IsStrongPersistent = std::false_type;
263template <
typename T,
typename WeaknessPolicy,
264 typename LocationPolicy = DefaultLocationPolicy,
265 typename CheckingPolicy = DefaultCrossThreadPersistentCheckingPolicy>
267template <
typename T,
typename WeaknessPolicy,
268 typename LocationPolicy = DefaultLocationPolicy,
269 typename CheckingPolicy = DefaultPersistentCheckingPolicy>
271template <
typename T,
typename WeaknessTag,
typename WriteBarrierPolicy,
272 typename CheckingPolicy = DefaultMemberCheckingPolicy,
273 typename StorageType = DefaultMemberStorage>
friend class internal::BasicPersistent
friend class BasicCrossThreadPersistent
V8_INLINE void CheckPointer(T *)
V8_INLINE void CheckPointer(RawPointer)
constexpr SourceLocation Location() const
constexpr IgnoreLocationPolicy(SourceLocation)
constexpr IgnoreLocationPolicy()=default
constexpr SourceLocation Location() const
KeepLocationPolicy & operator=(const KeepLocationPolicy &)=delete
constexpr KeepLocationPolicy(SourceLocation location)
KeepLocationPolicy(KeepLocationPolicy &&)=default
KeepLocationPolicy & operator=(KeepLocationPolicy &&)=default
KeepLocationPolicy(const KeepLocationPolicy &)=delete
constexpr KeepLocationPolicy()=default
V8_INLINE const void * Load() const
V8_INLINE bool IsSentinel() const
V8_INLINE bool IsCleared() const
void CheckPointerImpl(const void *ptr, bool points_to_payload, bool check_off_heap_assignments)
void CheckPointer(const T *ptr)
V8_INLINE void CheckPointer(RawPointer raw_pointer)
static V8_INLINE void DijkstraMarkingBarrier(const Params ¶ms, const void *object)
static V8_INLINE Type GetWriteBarrierType(const void *slot, const void *value, Params ¶ms)
constexpr internal::SentinelPointer kSentinelPointer
static V8_INLINE void InitializingBarrier(const void *, RawPointer storage)
static V8_INLINE void AssigningBarrier(const void *slot, const void *value)
static V8_INLINE void AssigningBarrier(const void *slot, RawPointer storage)
static V8_INLINE void InitializingBarrier(const void *, const void *)
static V8_INLINE void AssigningBarrier(const void *, const void *)
static V8_INLINE void InitializingBarrier(const void *, RawPointer storage)
static V8_INLINE void AssigningBarrier(const void *, MemberStorage)
static V8_INLINE void InitializingBarrier(const void *, const void *)
static V8_EXPORT CrossThreadPersistentRegion & GetPersistentRegion(const void *object)
static V8_EXPORT PersistentRegion & GetPersistentRegion(const void *object)
static V8_EXPORT CrossThreadPersistentRegion & GetPersistentRegion(const void *object)
static V8_EXPORT PersistentRegion & GetPersistentRegion(const void *object)