pub struct GcHandle<'a> { /* private fields */ }Expand description
A short-lived handle returned by state.gc() for GC operations.
In Phases A–C all methods are no-ops. Phase D replaces with real GC.
Implementations§
Source§impl<'a> GcHandle<'a>
impl<'a> GcHandle<'a>
Sourcepub fn check_step(&self)
pub fn check_step(&self)
macros.tsv: luaC_checkGC → state.gc().check_step()
Phase D-2: drives implicit collection when the heap’s byte threshold
is exceeded. Without this hook, loops that allocate without an
explicit collectgarbage() call (e.g. closure.lua’s
while x[1] do local a = A..A end GC-driven loop) never settle.
Sourcepub fn full_collect(&self)
pub fn full_collect(&self)
macros.tsv: luaC_fullgc → state.gc().full_collect()
Sourcepub fn generational_step(&self) -> bool
pub fn generational_step(&self) -> bool
Run one generational collection step.
Sourcepub fn incremental_step(&self, work_units: isize) -> bool
pub fn incremental_step(&self, work_units: isize) -> bool
Run one budgeted incremental step of the GC.
work_units is the number of GC work units the step is allowed to
perform (one gray trace, one sweep visit, or one phase transition).
Returns true if the step completed a cycle and the collector is
now in the Pause state; false otherwise.
Mirrors collect_via_heap for the post-mark weak-table /
finalizer-promotion logic, but only the atomic-phase transition will
invoke the snapshot-walking hook — propagate and sweep steps reuse
the snapshot but never execute it. The snapshot is rebuilt on every
call; the cost is O(weak_tables_registry) per step.
Sourcepub fn run_until_gc_state_for_test(&self, target: GcState) -> bool
pub fn run_until_gc_state_for_test(&self, target: GcState) -> bool
TestC/debug helper: run the incremental collector until a specific heap
state is entered, preserving the same weak-table/finalizer post-mark
hooks as Self::incremental_step. This is intentionally not used for
normal pacing; it exists so official tests can inspect mid-cycle colors.
Sourcepub fn prune_weak_tables_mark_only(&self)
pub fn prune_weak_tables_mark_only(&self)
Run only the weak-table atomic cleanup used by legacy generational callers that need mark/prune behavior without sweeping.
Explicit generational steps now use Self::generational_step, which
performs a young sweep. This helper remains for call sites that only
need the weak-table atomic pass.
Sourcepub fn change_mode(&self, mode: GcKind)
pub fn change_mode(&self, mode: GcKind)
Set the GC kind (incremental/generational).
Sourcepub fn fix_object<T: Trace + 'static>(&self, _o: &GcRef<T>)
pub fn fix_object<T: Trace + 'static>(&self, _o: &GcRef<T>)
Phase-B stub for luaC_fix(L, o) — pin an object so GC won’t collect it.
Sourcepub fn free_all_objects(&self)
pub fn free_all_objects(&self)
Free all collectable objects (called during state teardown).
PORT NOTE: In Phases A–C, Rc drop chains handle deallocation automatically.
Sourcepub fn barrier(&self, p: &dyn Any, v: &LuaValue)
pub fn barrier(&self, p: &dyn Any, v: &LuaValue)
GC write barrier for a TValue.
macros.tsv: luaC_barrier → state.gc().barrier(p, v)
Sourcepub fn barrier_back(&self, p: &dyn Any, v: &LuaValue)
pub fn barrier_back(&self, p: &dyn Any, v: &LuaValue)
Backward write barrier.
macros.tsv: luaC_barrierback → state.gc().barrier_back(p, v)
Sourcepub fn obj_barrier(&self, p: &dyn Any, o: &dyn Any)
pub fn obj_barrier(&self, p: &dyn Any, o: &dyn Any)
Object write barrier.
macros.tsv: luaC_objbarrier → state.gc().obj_barrier(p, o)
Sourcepub fn obj_barrier_back(&self, p: &dyn Any, o: &dyn Any)
pub fn obj_barrier_back(&self, p: &dyn Any, o: &dyn Any)
Backward object write barrier.