Skip to main content

Module kinded_slot

Module kinded_slot 

Source
Expand description

KindedSlot: caller-side runtime-value carrier (ADR-006 §2.7 / Q7).

Pairs a raw 8-byte ValueSlot with the NativeKind that interprets its bits. Used at GENERIC_CARRIER sites — module bindings, frame info, suspension state, intrinsic dispatch, output adapters — where the kind is not statically determined by the surrounding FieldType / schema. STATIC_KIND sites continue to use ValueSlot directly.

§Why a struct, not a sum type

ADR-005 §1’s single-discriminator discipline forbids parallel sum types whose variants project 1:1 to HeapKind. KindedSlot is a struct, not a sum type — the kind is data, not a discriminator. NativeKind is also broader than HeapKind (it includes raw scalars Int64/Float64/Bool with no HeapValue arm). The kind→heap mapping is many-to-one (heap arms only), not 1:1.

§Why explicit Drop / Clone, NOT Copy

ValueSlot itself is Copy (it’s a raw u64). Putting KindedSlot in a Vec would alias-copy the heap pointer on every push/pop/clone and the default Vec::drop would leak refcounts (or, after a clone, double-free them on the second drop). This is the WB2.4 / WB2.5 bug class the typed-slot ABI was designed to prevent.

The reference precedent is TypedObjectStorage::Drop in heap_value.rs:761-889: walk a per-slot NativeKind, dispatch to the matching Arc::decrement_strong_count::<T>. This module mirrors that discipline at the carrier-struct level.

§Forbidden uses (ADR-006 §2.7.2)

  • Do not use KindedSlot where NativeKind is statically known (would re-introduce kind-tag latency the slot ABI just removed).
  • Do not introduce KindedSlot variants (sum-type form).
  • Do not let KindedSlot leak into the typed VM↔JIT slot ABI (docs/runtime-v2-spec.md). The hot stack/JIT path stays ValueSlot-only with kind threaded through opcodes.

See docs/adr/006-value-and-memory-model.md §2.7.

Structs§

KindedSlot
Caller-side runtime-value carrier: a ValueSlot paired with the NativeKind that interprets it. ADR-006 §2.7.