jam 0.0.1
A compacting generational garbage collector for C++26
Loading...
Searching...
No Matches
jam::heap::visitor Class Reference
Word heap | module jam

One marker's claim and edge-discovery interface.Only a successful claimant visits the record's fields. The visitor is borrowed for one callback and must not escape it. More...

Public Types

using heap_type = heap
 Heap accepted by this visitor.

Public Member Functions

bool claim (offset start, std::size_t words=1, std::size_t alignment_bytes=8) noexcept
 Claim a complete record; exactly one marker wins traversal.
template<class T>
T const * claim_target (ptr< T > const &value) noexcept
 Claim a typed target without declaring the pointer's source slot.
template<class T>
T const * claim_target (T const *value) noexcept
 Claim the complete object from its allocation-level hook.
template<class T>
void pointer (ptr< T > const &value) noexcept
 Declare one pointer slot without following or claiming its target.
template<class T>
void pointer (weak_ptr< T > const &value) noexcept
 Declare a weak slot without following or claiming its target.
void pointers (word bits, std::size_t first_slot=0) noexcept
 OR a pattern of pointer slots into the current record's metadata. Bit zero names the 32-bit slot at first_slot, relative to the record start. Zero bits leave existing declarations unchanged. No targets are claimed.
template<class T>
T const * claim (ptr< T > const &value) noexcept
 Declare a pointer slot, then claim its target as with claim_target(). Null and already-claimed targets still have their source slot declared.
offset field (offset cell, unsigned slot=0) noexcept
 Declare a managed field and enqueue its nonnull target for tracing.
void target (offset at) noexcept
 Enqueue an external/wide target without declaring a narrow source slot.
template<class T>
requires (!detail::is_ptr<T> && !detail::is_weak_ptr<T>) && detail::visits<T, visitor>
void operator() (T const &value) noexcept
 Walk an embedded value without claiming cells again. Parts share the current allocation's pointer mask. Tuple views may name those parts, but ptr fields must retain their original heap addresses.
template<class T>
ptr< T > operator() (ptr< T > const &value) noexcept
 Declare a typed field and enqueue its nonnull target.
template<class T>
void operator() (weak_ptr< T > const &value) noexcept
 Declare a weak field for forwarding; never enqueue its target.
template<class... Ts>
requires (sizeof...(Ts) != 1) && (detail::visits<Ts, visitor> && ...)
void operator() (Ts const &... values) noexcept
 Visit parts in order, preserving their addresses; an empty pack does nothing.
void poll () noexcept
 Service overdue stochastic donations without leaving this walker. Long cooperative hooks should poll periodically after enqueueing branches.

Friends

template<class T>
struct jam::tracer

Detailed Description

One marker's claim and edge-discovery interface.

Only a successful claimant visits the record's fields. The visitor is borrowed for one callback and must not escape it.

Definition at line 950 of file heap.ccm.

Member Function Documentation

◆ claim()

bool jam::heap::visitor::claim ( offset start,
std::size_t words = 1,
std::size_t alignment_bytes = 8 )
inlinenodiscardnoexcept

Claim a complete record; exactly one marker wins traversal.

Precondition
All tracers agree on disjoint record starts, extents and alignments.

Definition at line 1041 of file heap.ccm.

◆ claim_target() [1/2]

template<class T>
T const * jam::heap::visitor::claim_target ( ptr< T > const & value)
inlinenodiscardnoexcept

Claim a typed target without declaring the pointer's source slot.

Returns
Its in-place address, or nullptr for null or an earlier claim. A successful claim makes this the current record for pointer declarations. Decorate its outgoing slots before claiming another target. Failure leaves the current record unchanged; the returned address cannot escape marking.

Definition at line 1051 of file heap.ccm.

◆ claim_target() [2/2]

template<class T>
T const * jam::heap::visitor::claim_target ( T const * value)
inlinenodiscardnoexcept

Claim the complete object from its allocation-level hook.

Precondition
value is null or the complete allocation's start, with exact type T. An override must pass its own this, not a base-class view of the object.

Definition at line 1065 of file heap.ccm.

◆ field()

offset jam::heap::visitor::field ( offset cell,
unsigned slot = 0 )
inlinenoexcept

Declare a managed field and enqueue its nonnull target for tracing.

Returns
The stored offset, usable until compaction starts.
Precondition
The field belongs to a claimed record, or an explicitly scanned dirty old owner in a hosted minor collection.

Definition at line 1127 of file heap.ccm.

◆ operator()()

template<class T>
ptr< T > jam::heap::visitor::operator() ( ptr< T > const & value)
inlinenoexcept

Declare a typed field and enqueue its nonnull target.

Precondition
The field is a subobject of the supplied tracing value, not a copy. The field's type supplies both its width and target type. A null field is declared but follows no target. The return value expires on collection.

Definition at line 1151 of file heap.ccm.

◆ pointer() [1/2]

template<class T>
void jam::heap::visitor::pointer ( ptr< T > const & value)
inlinenoexcept

Declare one pointer slot without following or claiming its target.

Precondition
The field is a subobject of the current successfully claimed record.

Definition at line 1085 of file heap.ccm.

◆ pointer() [2/2]

template<class T>
void jam::heap::visitor::pointer ( weak_ptr< T > const & value)
inlinenoexcept

Declare a weak slot without following or claiming its target.

Precondition
The field belongs to the current successfully claimed record.

Definition at line 1093 of file heap.ccm.

◆ pointers()

void jam::heap::visitor::pointers ( word bits,
std::size_t first_slot = 0 )
inlinenoexcept

OR a pattern of pointer slots into the current record's metadata. Bit zero names the 32-bit slot at first_slot, relative to the record start. Zero bits leave existing declarations unchanged. No targets are claimed.

Precondition
Every set bit names a complete managed pointer field in this record.

Definition at line 1100 of file heap.ccm.


The documentation for this class was generated from the following file: