jam 0.0.1
A compacting generational garbage collector for C++26
Loading...
Searching...
No Matches
heap.ccm File Reference
module jam.heap

A double-mapped word arena with bounded parallel compaction. More...

#include <hint.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <atomic>
#include <cassert>
#include <cstddef>
#include <concepts>
#include <compare>
#include <limits>
#include <memory>
#include <map>
#include <tuple>
#include <type_traits>
#include <variant>
#include <utility>
#include <vector>
#include <deque>
#include <unordered_map>
#include <bit>
#include <cstdint>
#include <cstring>
#include <functional>
#include <span>
#include <stdexcept>
import jam.units;
import jam.packed;
import work;
import jam.mapping;
Include dependency graph for heap.ccm:

Go to the source code of this file.

Classes

struct  jam::leaf< T >
 Opt out of value traversal when specializing tracer<T>.Derive tracer<T>, not the heap object, from leaf<T> to suppress value traversal. Ordinary types without hooks or manifests already use this behavior. An allocation-level claim_and_trace hook still takes precedence. Heap storage requirements are separate from this reference-free promise. More...
struct  jam::tracer< T >
 Per-value tracing customization; values without a hook or manifest are leaves.An allocation-only claim_and_trace hook does not describe embedded fields. Scalars and ordinary records without a trace member or manifest contain no managed edges by convention. Records containing managed pointers must enumerate them in a manifest, trace member or tracer specialization. Trivial copyability does not enumerate fields. More...
struct  jam::tracer< T >
 Forward a value hook or a cooperative allocation hook.Visit each live ptr by reference from the supplied value. Nested values share the enclosing allocation's pointer mask. Static trace(visit, ptr<T>) owns allocation claiming and may walk directly between records. More...
struct  jam::tracer< ptr< T > >
 Tag a reference slot and enqueue its target. More...
struct  jam::tracer< weak_ptr< T > >
 Declare a weak field for forwarding without following its target. More...
struct  jam::tracer< std::tuple< Ts... > >
 Visit each tuple element in the enclosing allocation. More...
struct  jam::tracer< std::array< T, N > >
 Visit each array element in the enclosing allocation. More...
struct  jam::tracer< std::variant< Ts... > >
 Visit only the active variant alternative in the enclosing allocation. More...
class  jam::heap_scope
 Bind an existing heap, restoring the previous binding on scope exit.The heap must outlive the scope. Scopes nest on one thread and may re-enter a heap. They neither own the heap nor synchronize access to it. More...
class  jam::ptr< T >
 A typed heap offset, with no root registration or ownership. More...
class  jam::weak_ptr< T >
 A four-byte weak heap field; tracing updates its slot without retaining its target.Construct from a ptr or root. Collection clears the field when its target is unclaimed; minor collection leaves old targets alone. Use lock() to retain a target across collection. There is no control block or external registration: stack copies expire at collection just like ptr, even if the target survives. The field must be listed in its owner's manifest or trace hook. More...
struct  jam::generation_options
 Sizing policy for one generation. Sizes are platform pages. More...
struct  jam::heap_options
 Two generations and one shared worker pool. More...
class  jam::heap
 A circular, double-mapped arena with bounded parallel compaction.Compressed four-byte offsets address two generations of up to 16 GiB each. The high bit selects young; the remaining bits count eight-byte cells. Record alignment up to 64 bytes is retained by dilation and padding between independent rank blocks. Allocation and liveness always use eight-byte cells. Clients trace complete byte-relocatable records; the heap does not infer boundaries or run destructors. This storage contract extends beyond ISO C++ trivial-copy guarantees: moving representation bytes must preserve meaning after ptr fields are forwarded. Raw address-dependent state and required destruction are unsupported. Multiple markers may trace a frozen heap. Join them before compaction, mutation, allocation, or inspecting metadata. Borrows expire on movement. More...
class  jam::heap::root_handle
 A four-byte handle to a collector-updated external root slot.Copies share a registration; moves leave the source detached and null. Operations on registered handles require the owning heap current and a quiescent collector. The heap must outlive all its registered handles. More...
class  jam::heap::visitor
 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...
struct  jam::heap::generation
 One generation's ordered double-mapped arena and collection metadata. More...
class  jam::heap::host
 Borrow a heap whose roots, barriers and reference policy belong to a host runtime. More...
class  jam::heap::host::pin
 Stable alias registration; release through its owning host. More...
struct  jam::heap::host::gap
 Padding retained by pin placement, in destination cells. More...
class  jam::root< T >
 A copyable external root, updated during collection.Four-byte slot index; no heap or registration address is stored. The heap must outlive the root and be current for operations and destruction. More...
class  jam::weak_root< T >
 An external weak slot, updated or cleared by collection without retaining its target.Keep it outside the managed heap. The heap must outlive even an expired attached root. Copies share a registration; moves leave the source detached and expired. Four-byte slot index; operations and destruction require the owning heap current. Operations require a quiescent collector. Old targets remain live during minor collection. More...
class  jam::weak< V >
 An external conditional weak-value handle; registration survives dropped handles.Keep this handle outside the managed heap. Copies share one registration. Finalization expires all copies before the callback runs; resurrection does not rearm it. More...

Concepts

concept  jam::visitor
 A visitor for jam's compressed, alignment-preserving heap.
concept  jam::traceable
 T supports tracing after it is complete.Ordinary trace return types are unrestricted; collection uses their effects. A void claim_and_trace(heap::visitor &) const noexcept member takes priority for allocation tracing and may be virtual. Its override must claim the exact complete object before declaring fields or following targets.

Functions

template<class T, class... Members>
requires (std::is_object_v<Members> && ...)
consteval auto jam::make_manifest (Members T::*... members)
 Describe the pointer-bearing members of T, including embedded values.T may still be incomplete. List pointers and embedded values that contain pointers; unlisted fields are data. Hooks take precedence over the manifest.
template<class T>
 jam::weak_ptr (ptr< T > const &) -> weak_ptr< T >
 Deduce the target type from a strong pointer.
template<class T>
 jam::weak_ptr (root< T > const &) -> weak_ptr< T >
 Deduce the target type from a root.

Detailed Description

A double-mapped word arena with bounded parallel compaction.

Definition in file heap.ccm.