Copy-on-write pool of capture blocks (OPT D1) — the one capture-slot mechanism for both storages.
More...
|
| constexpr void | reset (std::uint16_t slot_count) |
| | Reset for a new match run: block 0 = all-npos, held by a permanent sentinel ref. The storage grows by allocate (heap for dynamic; a compile-sized static_vec for static, whose capacity bounds the live-block count and so is never exceeded).
|
| |
| constexpr std::size_t * | slots (std::uint32_t b) |
| | Pointer to block b's width slots. Invalidated by any allocate that grows data.
|
| |
| constexpr std::uint32_t | allocate () |
| | A fresh block with refcount 1 (a recycled index if available, else a grown one).
|
| |
| constexpr void | incref (std::uint32_t b) |
| |
| constexpr void | decref (std::uint32_t b) |
| |
| constexpr std::uint32_t | cow_write (std::uint32_t b, std::uint16_t slot, std::size_t value) |
| | Write slots(b)[slot] = value, detaching first if b is shared. Returns the block that now holds the write (a fresh private copy when shared, else b). The one place a block mutates.
|
| |
| constexpr long long | total_refs () const |
| | Sum of all live refcounts — the debug Σ-invariant checks this equals the references the VM actually holds (list blocks + stack frames), catching a leaked or double-freed block.
|
| |
template<typename DataVec, typename RefVec, typename FreeVec>
struct real::detail::basic_capture_pool< DataVec, RefVec, FreeVec >
Copy-on-write pool of capture blocks (OPT D1) — the one capture-slot mechanism for both storages.
A per-thread value model would snapshot all slot_count capture values every time a thread is stepped or emitted — a fifth to a third of match time on capture-heavy loads. Instead, a thread references a block by index; forks (split) share a block (refcount++), and a save — the ONE write — detaches it first if shared (cow_write). No value-journal, no per-thread copy.
Block 0 is the canonical all-npos block: every seed shares it (a permanent sentinel ref keeps it alive), so seeding a position costs one incref, not an allocation — the first save COWs off it. The pool is trivially-copyable indices with a free list; no RAII handles (they would run destructors in the SBO / static thread lists, which run none — the reserve the review named).
Definition at line 78 of file pike.hpp.