Skip to main content

shape_jit/ffi/object/
mod.rs

1//! Object FFI Functions for JIT
2//!
3//! This module provides FFI functions for creating and manipulating objects,
4//! arrays, closures, and performing property access operations in the JIT.
5//!
6//! ## Modules
7//!
8//! - `object_ops` - Object creation, manipulation, and metadata operations
9//! - `property_access` - Property access for objects, arrays, strings, series, and other types
10//! - `conversion` - Conversion between NaN-boxed bits and runtime Values
11//! - `format` - String formatting with template substitution
12//! - `closure` - Closure creation with captured values
13//! - `pattern` - Pattern matching helpers for Result/Option types
14
15pub mod closure;
16pub mod conversion;
17pub mod format;
18pub mod object_ops;
19pub mod pattern;
20pub mod property_access;
21
22// Re-export all public functions for backward compatibility
23pub use object_ops::{jit_new_object, jit_object_rest, jit_set_prop};
24
25pub use property_access::{jit_get_prop, jit_hashmap_shape_id, jit_hashmap_value_at, jit_length};
26
27pub use conversion::{
28    jit_bits_to_nanboxed, jit_bits_to_nanboxed_with_ctx, jit_bits_to_typed_scalar,
29    nanboxed_to_jit_bits, typed_scalar_to_jit_bits,
30};
31
32pub use format::jit_format;
33
34#[allow(deprecated)]
35pub use closure::jit_make_closure;
36
37pub use closure::jit_finalize_heap_closure;
38
39// Track A.1D: OwnedMutable capture cell allocator (Box<ValueWord>). Called
40// from `MirToIR::emit_heap_closure` to materialise the cell pointer that
41// gets installed into the closure's `Ptr` capture slot.
42pub use closure::jit_alloc_owned_mut_cell;
43
44// Track A.1E: Shared capture FFI helpers.
45//   - `jit_arc_shared_retain`        — Arc strong-count retain for
46//                                       `emit_heap_closure`'s Shared branch.
47//   - `jit_shared_lock_contended`    — slow-path lock spin-wait.
48//   - `jit_shared_unlock_contended`  — slow-path unlock release store.
49pub use closure::{
50    jit_arc_shared_retain, jit_shared_lock_contended, jit_shared_unlock_contended,
51};
52
53// Session 1 Commit 3: Outer-scope Shared-cell lifecycle helpers.
54//   - `jit_alloc_shared_cell`        — allocates a fresh `Arc<SharedCell>`
55//                                       with the given `ValueWord` initial
56//                                       bits; returns the raw pointer bits
57//                                       of the sole strong share.
58//   - `jit_arc_shared_release`       — consumes exactly one strong share
59//                                       (outer-scope reclaim); null-safe.
60pub use closure::{jit_alloc_shared_cell, jit_arc_shared_release};
61
62// Wave C.1: Per-FieldKind closure-cell FFI helpers (D1 native ABI). 33
63// OwnedMutable wrappers (alloc/read/write × 11 FieldKinds) + 22 Shared
64// wrappers (read/write × 11 FieldKinds) = 55 distinct symbols. Cell
65// pointers cross the FFI boundary as `i64`; payloads use native types
66// (F64/I64) where 8-byte, `I32` for 4-byte ints, and `I32` widened from
67// sub-32 (i16/u16/i8/u8/bool). See
68// `crates/shape-jit/src/ffi/object/closure.rs` for ABI details.
69pub use closure::{
70    jit_alloc_owned_mut_cell_bool, jit_alloc_owned_mut_cell_f64, jit_alloc_owned_mut_cell_i8,
71    jit_alloc_owned_mut_cell_i16, jit_alloc_owned_mut_cell_i32, jit_alloc_owned_mut_cell_i64,
72    jit_alloc_owned_mut_cell_ptr, jit_alloc_owned_mut_cell_u8, jit_alloc_owned_mut_cell_u16,
73    jit_alloc_owned_mut_cell_u32, jit_alloc_owned_mut_cell_u64, jit_read_owned_mut_cell_bool,
74    jit_read_owned_mut_cell_f64, jit_read_owned_mut_cell_i8, jit_read_owned_mut_cell_i16,
75    jit_read_owned_mut_cell_i32, jit_read_owned_mut_cell_i64, jit_read_owned_mut_cell_ptr,
76    jit_read_owned_mut_cell_u8, jit_read_owned_mut_cell_u16, jit_read_owned_mut_cell_u32,
77    jit_read_owned_mut_cell_u64, jit_read_shared_cell_bool, jit_read_shared_cell_f64,
78    jit_read_shared_cell_i8, jit_read_shared_cell_i16, jit_read_shared_cell_i32,
79    jit_read_shared_cell_i64, jit_read_shared_cell_ptr, jit_read_shared_cell_u8,
80    jit_read_shared_cell_u16, jit_read_shared_cell_u32, jit_read_shared_cell_u64,
81    jit_write_owned_mut_cell_bool, jit_write_owned_mut_cell_f64, jit_write_owned_mut_cell_i8,
82    jit_write_owned_mut_cell_i16, jit_write_owned_mut_cell_i32, jit_write_owned_mut_cell_i64,
83    jit_write_owned_mut_cell_ptr, jit_write_owned_mut_cell_u8, jit_write_owned_mut_cell_u16,
84    jit_write_owned_mut_cell_u32, jit_write_owned_mut_cell_u64, jit_write_shared_cell_bool,
85    jit_write_shared_cell_f64, jit_write_shared_cell_i8, jit_write_shared_cell_i16,
86    jit_write_shared_cell_i32, jit_write_shared_cell_i64, jit_write_shared_cell_ptr,
87    jit_write_shared_cell_u8, jit_write_shared_cell_u16, jit_write_shared_cell_u32,
88    jit_write_shared_cell_u64,
89};
90
91pub use pattern::{jit_pattern_check_constructor, jit_pattern_extract_constructor};