shape_jit/ffi/references.rs
1//! Reference FFI Functions for JIT — `&array[index] = value` lowering.
2//!
3//! ## Status: SURFACE (ADR-006 §2.7.4 / W10 jit-playbook §5)
4//!
5//! Pre-strict-typing this module mutated an `unified_array::UnifiedArray`
6//! through `JitArray::from_heap_bits_mut`, decoded the index via
7//! `unbox_number` (a `tag_bits` decode hidden inside the deleted ValueWord
8//! API), and wrote raw `u64` element bits via `arr.set_boxed`. Both ends
9//! are W-series defection-attractor pipeline (CLAUDE.md "Forbidden
10//! Patterns": "Runtime tag_bits dispatch" + the deleted UnifiedArray heap
11//! layout — see `jit_array.rs` SURFACE comment for the layout-deletion
12//! audit).
13//!
14//! The strict-typing rebuild target reads the array directly as
15//! `Arc<TypedArrayData>` per-element-kind arm (§2.7.6/Q8) and writes
16//! through the matching `TypedArray<T>::set` instantiation, with the
17//! element kind sourced from the JIT-stamped call signature per §2.7.5
18//! (no decode of the receiver bits, no fabricated element kind).
19//!
20//! Until the kinded array-FFI rebuild lands (W11 / deeper Phase-2c),
21//! the entry point below routes to `todo!()` so consumers fail loudly
22//! at the JIT-emitted `call jit_set_index_ref` site.
23
24/// Set an array element through a reference pointer.
25///
26/// SURFACE (W10 jit-playbook §5 / ADR-006 §2.7.4): the deleted
27/// `JitArray::from_heap_bits_mut` walked the deleted `UnifiedArray`
28/// layout. The kinded rebuild reads `Arc<TypedArrayData>` per the
29/// receiver's stamped `NativeKind::Ptr(HeapKind::TypedArray)` companion
30/// and dispatches to the per-element `TypedArray<T>::set` instantiation.
31#[unsafe(no_mangle)]
32pub extern "C" fn jit_set_index_ref(_ref_ptr: *mut u64, _index: u64, _value: u64) {
33 todo!(
34 "phase-2c §2.7.4 / W10 jit-playbook §5: JitArray rebuild — \
35 jit_set_index_ref. The deleted UnifiedArray heap layout (see \
36 jit_array.rs SURFACE) blocks ref-into-array element mutation. \
37 The kinded rebuild target reads `Arc<TypedArrayData>` per-element-\
38 kind arm per ADR-006 §2.7.6/Q8 and writes through the matching \
39 `TypedArray<T>::set` instantiation, with the element kind sourced \
40 from the JIT-stamped call signature per §2.7.5. See \
41 docs/cluster-audits/wave-10-jit-playbook.md §5."
42 )
43}