shape_jit/ffi/array.rs
1//! Array FFI Functions for JIT.
2//!
3//! ## Route A close (ADR-006 §2.7.14 / W11-jit-new-array)
4//!
5//! Q15 resolved Route A: kinded per-element-kind `Arc<TypedArrayData>`
6//! monomorphization. Allocation goes through `v2_array_new_<kind>`
7//! (defined in `ffi/v2/mod.rs`); push goes through `v2_array_push`
8//! dispatched by element byte size; indexed get/set/len/SIMD ops are
9//! inlined directly against the `TypedArray<T>` layout from
10//! `mir_compiler/v2_array.rs`. The legacy kind-blind `jit_new_array`
11//! / `jit_array_get` / `jit_array_push` / `jit_array_pop` / etc.
12//! entries (the ValueWord-shape ABI) are not re-introduced.
13//!
14//! The `ArrayInfo` carrier struct below is kept in its `#[repr(C)]`
15//! shape because downstream symbol-table consumers (the deleted
16//! `jit_array_info` entry's signature in any future probe) and non-
17//! array consumers reference it through the public type. The
18//! `is_inline_bool` helper is similarly preserved as a §2.7.5 carrier
19//! that's not a tag-bit decode (it tests against the JIT's stable
20//! inline-bool constants from a known-Bool slot).
21//!
22//! ## Forbidden under any future expansion
23//!
24//! - `JitArray` revival under any renamed shape (CLAUDE.md "Renames
25//! to refuse on sight" — broader-family regex).
26//! - Bool-default fallback for unknown element kind.
27//! - `tag_bits`-based element decoder.
28
29use super::value_ffi::{TAG_BOOL_FALSE, TAG_BOOL_TRUE};
30
31// ============================================================================
32// Public ABI carrier preserved for downstream symbol-table compatibility.
33// ============================================================================
34
35/// JIT-FFI carrier struct for legacy array-info consumers.
36///
37/// Preserved in its `#[repr(C)]` shape so the Cranelift signature
38/// declaration in `ffi_symbols/array_symbols.rs` (if any future
39/// kinded-info entry registers) has a stable target type. The body
40/// that previously populated this is gone; under Route A consumers
41/// inline-load the `data` / `len` fields from the `TypedArray<T>`
42/// layout directly.
43#[repr(C)]
44pub struct ArrayInfo {
45 pub data_ptr: u64,
46 pub length: u64,
47}
48
49// ============================================================================
50// Helper used by other (still-living) FFI sites to materialize a fresh
51// element-kind label without tag-bit decode. Kept as a §2.7.5 carrier.
52// ============================================================================
53
54/// Returns `true` iff `value_bits` carries an inline-true / inline-false
55/// constant per `value_ffi::TAG_BOOL_*`. Distinct from the deleted
56/// `tag_bits::is_tagged`/`get_tag` shape: the input is a JIT-stamped
57/// boolean payload from a known-Bool slot, not a runtime classifier.
58#[inline]
59pub fn is_inline_bool(value_bits: u64) -> bool {
60 value_bits == TAG_BOOL_TRUE || value_bits == TAG_BOOL_FALSE
61}