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 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 prune_weak_tables_mark_only(&self)
pub fn prune_weak_tables_mark_only(&self)
Run only the weak-table atomic cleanup used by a generational step.
C-Lua’s genstep performs young/full generational work and includes
weak-table clearing at the atomic boundary. This heap does not model
ages yet; this mark-only pass gives explicit generational steps the
weak cleanup they need without sweeping objects from suspended threads.
Sourcepub fn change_mode(&self, mode: GcKind)
pub fn change_mode(&self, mode: GcKind)
Set the GC kind (incremental/generational).
itself is Rc-based, so the only observable effect is the mode flag
returned by lua_gc(LUA_GCGEN) / lua_gc(LUA_GCINC) on the next call.
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) — no-op in Phases A–C
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) — no-op
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) — no-op
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.