pub struct ClosureCell {
pub bits: Vec<u64>,
pub kinds: Vec<NativeKind>,
}Expand description
Kind-aware closure capture cell store (§2.7.8 / Q10).
Carries two parallel arrays in lockstep:
bits: Vec<u64>— 8-byte raw payload per cell (the same shape as the existing closure block’s capture slots, but stored separately as a kind-tracked side-store for cells whose kind is not derivable fromClosureLayout::capture_inner_kindalone — i.e. heap captures whoseNativeKind::Ptr(HeapKind)discriminator is finer thanFieldKind::Ptr).kinds: Vec<NativeKind>— 1-byte interpretation per cell.
Index invariant: bits.len() == kinds.len() at every observable
boundary (method entry/exit). Mixed lengths are a bug.
Drop discipline: every cell is released through drop_with_kind
— never bare vw_drop (forbidden #8 per §2.7.7) or “drop only if
heap-shaped” probes (forbidden #7). Inline-scalar kinds are no-op
drops; heap-bearing kinds retire one Arc<T> strong-count share per
the dispatch in KindedSlot::drop.
Construction: every push/pop/read accepts/returns (bits, kind)
lockstep. There is no kind-less constructor — cells are post-proof per
§2.7.5.1, so each cell carries a known NativeKind by construction.
Forbidden shapes (mirror of §2.7.7’s stack-side list):
Vec<KindedSlot>for the cell store (§2.7.5 —KindedSlotis a runtime-tier carrier, not the storage-tier shape).- 16-byte cell slots / packed tag bits in the
u64(§2.1 — 8-byte slot invariant). Vec<Option<NativeKind>>for the kind track (§2.7.5.1 — cells are post-proof; every cell has a concrete kind by construction).NativeKind::Unknown/Pending/Dynamicplaceholders (deleted from the enum).- Bool-default fallback for any cell write (§2.7.7 #9 — the W-series rationalization; surface to supervisor on a kind-source gap instead).
Wave-β consumer migration: the Load*Ptr / Store*Ptr handlers
in executor/variables/mod.rs (the 130 mandatory + 33 sibling sites
cluster B partial-closed leaving as NotImplemented(SURFACE)) will be
migrated by Wave-β cluster B6-variables-loadptr to thread the kind
through the cell-bound read paths via this struct.
Fields§
§bits: Vec<u64>Raw payload — 8-byte per cell. Cell i holds bits[i] interpreted
per kinds[i] (e.g. an Arc::into_raw::<TypedArrayData> raw pointer
when kinds[i] == NativeKind::Ptr(HeapKind::TypedArray), or a native
f64 bit pattern when kinds[i] == NativeKind::Float64).
kinds: Vec<NativeKind>Per-cell kind track. Lockstep with bits per the §2.7.8 index
invariant.
Implementations§
Source§impl ClosureCell
impl ClosureCell
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Create an empty cell store with the given capacity reserved on both parallel tracks.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of live cells. The §2.7.8 index invariant guarantees this
equals self.kinds.len().
Sourcepub unsafe fn push(&mut self, bits: u64, kind: NativeKind)
pub unsafe fn push(&mut self, bits: u64, kind: NativeKind)
Append a cell. The caller transfers ownership of bits’s
strong-count share (for heap kinds) into the cell store; the
matching drop_with_kind discharge happens at pop / truncate /
Drop time.
§Safety
bits must be a valid representation of kind per the
construction-side contract — for heap kinds, the result of
Arc::into_raw::<T> for the matching T; for inline scalars, the
native bit pattern.
Sourcepub fn pop(&mut self) -> Option<(u64, NativeKind)>
pub fn pop(&mut self) -> Option<(u64, NativeKind)>
Remove and return the last (bits, kind). The caller takes
ownership of the share (for heap kinds) and is responsible for
drop_with_kind (or transferring it elsewhere). Pop does NOT
clone — vec.pop() is move-out semantics.
Sourcepub fn read(&self, idx: usize) -> (u64, NativeKind)
pub fn read(&self, idx: usize) -> (u64, NativeKind)
Read cell idx as (bits, kind) without consuming it. The
returned bits is a borrowed copy — for heap kinds the caller
must clone_with_kind(bits, kind) to obtain an independently-
owned share before storing it elsewhere (the cell retains its
share).
§Panics
Panics if idx >= self.len().
Sourcepub fn read_kinded(&self, idx: usize) -> KindedSlot
pub fn read_kinded(&self, idx: usize) -> KindedSlot
Read cell idx and return a runtime-tier KindedSlot carrier
with a freshly-cloned share (for heap kinds; inline scalars are
Copy-equivalent). This is the §2.7.7 retain-on-read pattern,
extended to cells per §2.7.8.
§Panics
Panics if idx >= self.len().
Sourcepub unsafe fn replace(
&mut self,
idx: usize,
bits: u64,
kind: NativeKind,
) -> (u64, NativeKind)
pub unsafe fn replace( &mut self, idx: usize, bits: u64, kind: NativeKind, ) -> (u64, NativeKind)
Overwrite cell idx with a new (bits, kind) pair, returning the
old (bits, kind). The caller is responsible for drop_with_kind
on the returned previous value (or transferring it elsewhere) and
for ensuring the new bits carry one fresh strong-count share for
the new kind.
§Safety
New bits must be a valid representation of new kind per the
construction-side contract (for heap kinds: one strong-count share
from Arc::into_raw::<T> for the matching T).
§Panics
Panics if idx >= self.len().