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

Borrow a heap whose roots, barriers and reference policy belong to a host runtime. More...

Public Types

enum class  generation
 Select the arena for raw allocation or publication.

Public Member Functions

 host (heap &storage, std::size_t prefix) noexcept
 Reserve an identical guard in both fresh, fixed-size generations.
 ~host () noexcept
 Release the capability after finishing its last collection.
void publish (generation which, void *target, std::size_t skip, std::size_t count) const noexcept
 Publish one generation at a stable VM-owned address.
offset allocate (generation which, std::size_t words) noexcept
 Allocate raw cells in either generation, preserving the tag bit. A host may subdivide the extent; scanner claims determine record boundaries.
void begin (bool minor) noexcept
 Start a VM-owned marking epoch; the VM supplies barriers and weak policy.
template<class Trace>
requires std::is_nothrow_invocable_v<Trace &, visitor &, offset>
void trace (std::span< offset const > roots, Trace &&trace, std::size_t marker_limit=1, bool old_owners=false) noexcept
 Drain roots using jam's ordinary frontier and persistent worker pool.
bool marked (offset at) const noexcept
 Exact collected-generation liveness; old objects are live during minors.
bool prepare (bool promote=false) noexcept
 Freeze both forwarding tables after resolving all reference policies.
offset forward (offset at) const noexcept
 Repair a root while original objects and both forwarding tables remain intact.
void finish () noexcept
 Move with the original SIMD kernel and pack only after both moves finish.

Detailed Description

Borrow a heap whose roots, barriers and reference policy belong to a host runtime.

See hosting a runtime. One capability per heap; it must not outlive the heap. Ordinary Jam roots and collection are excluded.

Definition at line 1847 of file heap.ccm.

Constructor & Destructor Documentation

◆ host()

jam::heap::host::host ( heap & storage,
std::size_t prefix )
inlineexplicitnoexcept

Reserve an identical guard in both fresh, fixed-size generations.

Parameters
storageFresh heap borrowed for the capability lifetime.
prefixGuard size in eight-byte cells, a positive native-page multiple.
Precondition
Sole host capability; no ordinary Jam allocations, roots or collection.

Definition at line 1861 of file heap.ccm.

Member Function Documentation

◆ allocate()

offset jam::heap::host::allocate ( generation which,
std::size_t words )
inlinenodiscardnoexcept

Allocate raw cells in either generation, preserving the tag bit. A host may subdivide the extent; scanner claims determine record boundaries.

Precondition
Positive extent fits the selected generation; no active collection.

Definition at line 1893 of file heap.ccm.

◆ begin()

void jam::heap::host::begin ( bool minor)
inlinenoexcept

Start a VM-owned marking epoch; the VM supplies barriers and weak policy.

Precondition
No jam roots, weak registrations, remembered slots or active collection.

Definition at line 1899 of file heap.ccm.

◆ finish()

void jam::heap::host::finish ( )
inlinenoexcept

Move with the original SIMD kernel and pack only after both moves finish.

Precondition
VM roots and old remembered fields have been repaired. Republish both aliases before resuming mutators. Majors need no combined-live-size fit in either generation.

Definition at line 1974 of file heap.ccm.

◆ prepare()

bool jam::heap::host::prepare ( bool promote = false)
inlinenodiscardnoexcept

Freeze both forwarding tables after resolving all reference policies.

Returns
False if whole-nursery promotion does not fit. No forwarding is then visible; Retry without promotion in the same epoch; no further tracing is allowed. Majors retain both generations separately.

Definition at line 1943 of file heap.ccm.

◆ publish()

void jam::heap::host::publish ( generation which,
void * target,
std::size_t skip,
std::size_t count ) const
inlinenoexcept

Publish one generation at a stable VM-owned address.

Precondition
Fixed capacity, no shrink, stopped mutators; skip/count are page multiples. target corresponds to cell skip, not cell zero. The host owns the reservation.

Definition at line 1880 of file heap.ccm.

◆ trace()

template<class Trace>
requires std::is_nothrow_invocable_v<Trace &, visitor &, offset>
void jam::heap::host::trace ( std::span< offset const > roots,
Trace && trace,
std::size_t marker_limit = 1,
bool old_owners = false )
inlinenoexcept

Drain roots using jam's ordinary frontier and persistent worker pool.

Precondition
Marking phase; callbacks claim full objects before enumerating fields. marker_limit=1 keeps callbacks on the caller (e.g. a registered VM thread). old_owners admits dirty old source jobs in a minor; their targets remain young-only.

Definition at line 1921 of file heap.ccm.


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