Expand description
Relocatable off-heap term copies.
One mechanism, three users: thrown error balls must survive the heap rewinding that backtracks to a catch frame; findall/3 must preserve each solution’s template instance across the rewind that discards the goal’s bindings; copy_term/2 is the user-facing form.
A TermBuf stores cells exactly like the heap, except pointer
payloads are indices into the buffer itself. Copy and restore are
both ITERATIVE (a long list is as deep as it is long — recursion
would overflow the C stack) and memoized per source cell, which
preserves variable sharing and keeps cyclic terms (legal without
occurs check) from looping.
Structs§
Functions§
- copy_
to_ buf - Copy
root(a heap word) into a relocatable buffer. - restore_
cells - Materialize a term whose
cellsuse buffer-relative pointer payloads, rooted atroot, onto the machine heap; returns the heap root. The slice-based core ofrestore_from_buf— also used by the fact-table to restore a non-immediate column from its read-only.rodatablob (those blobs are ground, so theTAG_REFarm never fires there). - restore_
from_ buf - Materialize a buffer back onto the machine heap; returns the root.