1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
//! FFI function references for Cranelift codegen.
//!
//! This struct bundles the native-typed FFI entry points that the JIT
//! compiler actually references during codegen. Historically it carried ~240
//! `FuncRef` fields covering every legacy NaN-boxed helper; the V6 cleanup
//! (part of the v2 spec alignment) pruned the dead weight so only the
//! v2-native entry points remain.
//!
//! R7.1 deleted 11 `generic_*` dispatch-fallback fields (48 → 37).
//! R7.2 consolidated 4 typed-array push helpers into 1 (37 → 34).
//! R7.3 audited every remaining field: all 34 have ≥1 live caller in the
//! MIR lowering path (see `mir_compiler/{statements,terminators,v2_array,
//! v2_typed_map}.rs`). No further trimming is justified without
//! consolidating caller-side dispatch, which is out of scope for R7.
//!
//! Steady-state FuncRef count: 34. Further reduction would require FFI
//! consolidation work beyond the R7 audit's mandate.
//!
//! New FFI helpers should be registered here AND in
//! `crates/shape-jit/src/ffi_symbols/` (declare + register), and then the
//! `FFIFuncRefs` builder in `crates/shape-jit/src/compiler/ffi_builder.rs`
//! should populate the field.
use cranelift::codegen::ir::FuncRef;
/// Bundle of Cranelift `FuncRef` handles for native-typed FFI calls used by
/// the v2 JIT codegen pipeline.
pub struct FFIFuncRefs {
// Object / property access
pub(crate) get_prop: FuncRef,
pub(crate) set_prop: FuncRef,
// Call dispatch (value/method path — the other foreign-call variants were
// retired with the legacy NaN-boxed dispatch helpers).
pub(crate) call_value: FuncRef,
pub(crate) call_method: FuncRef,
// Array allocator + hot per-element push.
//
// Route A (ADR-006 §2.7.14 / W11-jit-new-array close): the kind-blind
// `jit_new_array` / `jit_array_push_elem` FuncRefs are deleted. The
// kinded `Arc<TypedArrayData>` allocator surface is the existing
// `v2_array_new_<kind>` family (below), and the kinded push surface is
// `v2_array_push` dispatched by element byte size. Call sites that
// lack a proven element kind surface-and-stop per §2.7.5.
//
// `print: FuncRef` (kind-blind builtin print fallback) DELETED in
// W12-jit-print-heap-arm-classification reopen (2026-05-13). Routed
// through the deleted-W-series `format_value_word` shape and was
// preserved "for one edge case" (Smoke 1.5's Err arm) — exactly the
// W-series walk-back CLAUDE.md "Forbidden rationalizations" refuses.
// The §2.7.5 producer-site classification conduit extension
// (`infer_enum_payload_kind` now uses `native_kind_from_concrete_type`)
// closes the kind-source gap; remaining `_`-arm operands at the
// print Call-terminator are NotImplemented(SURFACE).
//
// W11-jit-new-array (ADR-006 §2.7.5): per-kind print entry points
// dispatched by the MIR-side print emitter when the operand's
// `NativeKind` is statically known.
pub(crate) print_i64: FuncRef,
// r5c-2-β-CKPT-C u64-carrier-disambiguation: UNSIGNED render path for
// `NativeKind::UInt64` / `UIntSize` operand slots. `print_i64`
// reinterprets the bits as `i64` (so `u64::MAX` displayed `-1`); the
// unsigned kinds route here instead for VM == JIT identical output.
pub(crate) print_u64: FuncRef,
pub(crate) print_f64: FuncRef,
pub(crate) print_bool: FuncRef,
// W12-jit-print-heap-arm-classification (Phase 3 cluster-0 Round 8A,
// 2026-05-13): per-HeapKind kinded print entries (ADR-006 §2.7.5
// stamp-at-compile-time). Dispatched by the MIR-side Call-terminator
// print emitter when the operand's `NativeKind` is a heap arm —
// `NativeKind::String` → `print_str`,
// `Ptr(HeapKind::TypedObject)` → `print_typed_object`,
// `Ptr(HeapKind::Option)` → `print_option`,
// `Ptr(HeapKind::Result)` → `print_result`. The kind is the FFI entry
// by construction; no kind-code parameter; surface-and-stop on
// unknown heap kinds at the dispatch site (§2.7.7 #4 / #7 forbid
// tag-decode + Bool-default).
pub(crate) print_str: FuncRef,
pub(crate) print_typed_object: FuncRef,
pub(crate) print_option: FuncRef,
pub(crate) print_result: FuncRef,
// Phase 3 cluster-2 Round 3 cw-D-fam12 (2026-05-16): scalar Char +
// concurrency Mutex/Atomic/Lazy/Channel kinded print entries
// (ADR-006 §2.7.5 stamp-at-compile-time + §2.7.25 concurrency-
// primitive printing convention). Dispatched by the MIR-side
// Call-terminator print emitter when the operand's `NativeKind` is
// `NativeKind::Char` (scalar — `print_char`),
// `Ptr(HeapKind::Mutex)` → `print_mutex`,
// `Ptr(HeapKind::Atomic)` → `print_atomic`,
// `Ptr(HeapKind::Lazy)` → `print_lazy`,
// `Ptr(HeapKind::Channel)` → `print_channel`. Heap arms take
// `(ctx_ptr, bits)`; the scalar `print_char` takes a `u32`
// codepoint directly (mirror of `print_i64` / `print_f64` /
// `print_bool`).
pub(crate) print_char: FuncRef,
pub(crate) print_mutex: FuncRef,
pub(crate) print_atomic: FuncRef,
pub(crate) print_lazy: FuncRef,
pub(crate) print_channel: FuncRef,
// Phase 3 cluster-2 Round 4 cw-D-fam3 (2026-05-16): Collection
// family kinded print entries (ADR-006 §2.7.5 stamp-at-compile-time
// + §2.7.5.B per-HeapKind-family kinded jit_print dispatch arms
// amendment Family 3 extension). Dispatched by the MIR-side
// Call-terminator print emitter when the operand's `NativeKind` is
// `Ptr(HeapKind::HashMap)` → `print_hashmap`,
// `Ptr(HeapKind::HashSet)` → `print_hashset`,
// `Ptr(HeapKind::Deque)` → `print_deque`,
// `Ptr(HeapKind::PriorityQueue)` → `print_priority_queue`,
// `Ptr(HeapKind::Range)` → `print_range`,
// `Ptr(HeapKind::Iterator)` → `print_iterator`. All heap arms take
// `(ctx_ptr, bits)`; each delegates to `print_kinded_inner` so VM
// == JIT identical output is preserved. ADR-006 §2.7.5.B 2026-05-16
pub(crate) print_hashmap: FuncRef,
pub(crate) print_hashset: FuncRef,
pub(crate) print_deque: FuncRef,
pub(crate) print_priority_queue: FuncRef,
pub(crate) print_range: FuncRef,
pub(crate) print_iterator: FuncRef,
// W11-fup-C (Phase 3d, 2026-05-18): v2-raw TypedArray<T> kinded
// print entry (ADR-006 §2.7.5 stamp-at-compile-time). Dispatched by
// the MIR-side Call-terminator print emitter when the operand
// `NativeKind` is `Ptr(HeapKind::TypedArray)` — the MIR-time TYPE
// label for `ConcreteType::Array(_)` (per
// `mir_compiler/types.rs:175`). The runtime carrier is the v2-raw
// `*mut TypedArray<T>` pointer (NOT `Arc<TypedArrayData>` — that
// enum + outer arm were deleted across V3-S5 ckpt-1..ckpt-4).
// Takes `(ctx_ptr, bits)`; delegates to the canonical VM-side
// `ValueFormatter::format_kinded` via the `NativeKind::UInt64`
// carrier-recognition label at `printing.rs:126` so VM == JIT
// identical output is preserved (per-element walker at
// `printing.rs:610-640` reads element kind from the v2-raw
// HeapHeader `_pad` byte).
pub(crate) print_typed_array: FuncRef,
// Closure construction (Phase H2: typed closure block → Arc<Closure>).
pub(crate) make_closure: FuncRef,
pub(crate) finalize_heap_closure: FuncRef,
// Track A.1D: OwnedMutable capture cell allocator. Called from
// `emit_heap_closure` once per `CaptureKind::OwnedMutable` capture to
// obtain the `*mut ValueWord` pointer installed into the Ptr slot.
pub(crate) alloc_owned_mut_cell: FuncRef,
// Track A.1E: Shared capture FFI helpers.
// `arc_shared_retain` — per-capture Arc strong-count retain
// in `emit_heap_closure`'s Shared branch.
// `shared_lock_contended` — spin-wait fallback for the inline
// CAS lock acquire.
// `shared_unlock_contended` — release store fallback for the
// inline CAS unlock.
pub(crate) arc_shared_retain: FuncRef,
pub(crate) shared_lock_contended: FuncRef,
pub(crate) shared_unlock_contended: FuncRef,
// Session 1 Commit 3: outer-scope Shared-cell lifecycle helpers.
// `alloc_shared_cell` — `Arc<SharedCell>` allocator called
// from `MirToIR::initialize_shared_local_slots`
// to materialise the cell behind a
// SharedCow local slot at function
// entry. Mirrors the interpreter's
// `op_alloc_shared_local`.
// `arc_shared_release` — matching release, called from
// `emit_drop` on SharedCow local
// slots. Mirrors `op_drop_shared_local`.
pub(crate) alloc_shared_cell: FuncRef,
pub(crate) arc_shared_release: FuncRef,
// Wave C.1: per-FieldKind closure-cell FFI helpers (D1 native ABI).
// 33 OwnedMutable handles (alloc/read/write × 11 FieldKinds) + 22
// Shared handles (read/write × 11 FieldKinds) = 55 FuncRefs. Cell
// pointers cross the FFI boundary as `i64`; payloads use native
// Cranelift types where direct (F64/I64), I32 for 4-byte ints, and
// I32 widened from sub-32 (i16/u16/i8/u8/bool). See
// `crates/shape-jit/src/ffi/object/closure.rs` for ABI details.
//
// OwnedMutable allocators
pub(crate) alloc_owned_mut_cell_i64: FuncRef,
pub(crate) alloc_owned_mut_cell_u64: FuncRef,
pub(crate) alloc_owned_mut_cell_f64: FuncRef,
pub(crate) alloc_owned_mut_cell_i32: FuncRef,
pub(crate) alloc_owned_mut_cell_u32: FuncRef,
pub(crate) alloc_owned_mut_cell_i16: FuncRef,
pub(crate) alloc_owned_mut_cell_u16: FuncRef,
pub(crate) alloc_owned_mut_cell_i8: FuncRef,
pub(crate) alloc_owned_mut_cell_u8: FuncRef,
pub(crate) alloc_owned_mut_cell_bool: FuncRef,
pub(crate) alloc_owned_mut_cell_ptr: FuncRef,
// OwnedMutable readers
pub(crate) read_owned_mut_cell_i64: FuncRef,
pub(crate) read_owned_mut_cell_u64: FuncRef,
pub(crate) read_owned_mut_cell_f64: FuncRef,
pub(crate) read_owned_mut_cell_i32: FuncRef,
pub(crate) read_owned_mut_cell_u32: FuncRef,
pub(crate) read_owned_mut_cell_i16: FuncRef,
pub(crate) read_owned_mut_cell_u16: FuncRef,
pub(crate) read_owned_mut_cell_i8: FuncRef,
pub(crate) read_owned_mut_cell_u8: FuncRef,
pub(crate) read_owned_mut_cell_bool: FuncRef,
pub(crate) read_owned_mut_cell_ptr: FuncRef,
// OwnedMutable writers
pub(crate) write_owned_mut_cell_i64: FuncRef,
pub(crate) write_owned_mut_cell_u64: FuncRef,
pub(crate) write_owned_mut_cell_f64: FuncRef,
pub(crate) write_owned_mut_cell_i32: FuncRef,
pub(crate) write_owned_mut_cell_u32: FuncRef,
pub(crate) write_owned_mut_cell_i16: FuncRef,
pub(crate) write_owned_mut_cell_u16: FuncRef,
pub(crate) write_owned_mut_cell_i8: FuncRef,
pub(crate) write_owned_mut_cell_u8: FuncRef,
pub(crate) write_owned_mut_cell_bool: FuncRef,
pub(crate) write_owned_mut_cell_ptr: FuncRef,
// Shared readers (alloc/release reuse `alloc_shared_cell` /
// `arc_shared_release` above).
pub(crate) read_shared_cell_i64: FuncRef,
pub(crate) read_shared_cell_u64: FuncRef,
pub(crate) read_shared_cell_f64: FuncRef,
pub(crate) read_shared_cell_i32: FuncRef,
pub(crate) read_shared_cell_u32: FuncRef,
pub(crate) read_shared_cell_i16: FuncRef,
pub(crate) read_shared_cell_u16: FuncRef,
pub(crate) read_shared_cell_i8: FuncRef,
pub(crate) read_shared_cell_u8: FuncRef,
pub(crate) read_shared_cell_bool: FuncRef,
pub(crate) read_shared_cell_ptr: FuncRef,
// Shared writers
pub(crate) write_shared_cell_i64: FuncRef,
pub(crate) write_shared_cell_u64: FuncRef,
pub(crate) write_shared_cell_f64: FuncRef,
pub(crate) write_shared_cell_i32: FuncRef,
pub(crate) write_shared_cell_u32: FuncRef,
pub(crate) write_shared_cell_i16: FuncRef,
pub(crate) write_shared_cell_u16: FuncRef,
pub(crate) write_shared_cell_i8: FuncRef,
pub(crate) write_shared_cell_u8: FuncRef,
pub(crate) write_shared_cell_bool: FuncRef,
pub(crate) write_shared_cell_ptr: FuncRef,
// TypedObject allocation + field store (used by struct lowering).
pub(crate) typed_object_alloc: FuncRef,
pub(crate) typed_object_set_field: FuncRef,
// Arc refcount primitives (used by ownership-aware JIT paths).
pub(crate) arc_retain: FuncRef,
pub(crate) arc_release: FuncRef,
// r5c-2-β-δ-(α): v2-raw `TypedArray<T>` retain / release. The carrier
// is `*mut TypedArray<T>` (HeapHeader at offset 0, separate element
// buffer); the legacy `arc_retain` / `arc_release` would corrupt it.
pub(crate) v2_typed_array_retain: FuncRef,
pub(crate) v2_typed_array_release: FuncRef,
// v2 typed-array allocators (used by v2 lowerings).
pub(crate) v2_array_new_f64: FuncRef,
pub(crate) v2_array_new_i64: FuncRef,
pub(crate) v2_array_new_i32: FuncRef,
pub(crate) v2_array_new_bool: FuncRef,
// ADR-006 §2.7.5 + §2.7.24 Q25.A SUPERSEDED + audit deliverable (b)
// §4.1.B — v2-raw `TypedArray<*const StringObj>` / `TypedArray<*const
// DecimalObj>` heap-element allocators. Phase 3 cluster-0+1 Wave 3
// Stabilize Round 2 V3-S5 ckpt-6-prime Group X JIT FFI String/Decimal
// BUILD (2026-05-15). Routed by `v2_array_new_func` for `NativeKind::
// StringV2` / `NativeKind::DecimalV2` element kinds — mirrors the
// existing scalar-kind dispatch arms for Float64/Int64/Int32/Bool. The
// per-element pointer payload is `*const StringObj` / `*const DecimalObj`
// matching the VM-side `NewStringV2` / `NewDecimalV2` producer at
// `crates/shape-vm/src/executor/v2_handlers/array.rs:803-858`.
pub(crate) v2_array_new_string: FuncRef,
pub(crate) v2_array_new_decimal: FuncRef,
// Phase 4b Round 4 W16.2-A op_new_array-typed-object-element (2026-05-18).
// v2-raw `TypedArray<*const TypedObjectStorage>` heap-element allocator
// per ADR-006 §2.7.5 + §2.7.24 Q25.A SUPERSEDED + audit
// `v0.3-w16-v3s5-ckpt56-strict-close-audit.md` §2.1 + §3.A row 1. Routed
// by `v2_array_new_func` for `NativeKind::Ptr(HeapKind::TypedObject)`.
pub(crate) v2_array_new_typed_object: FuncRef,
// v2 typed-array element push — single generic helper that dispatches
// on the `elem_size` byte immediate. Callers zero/sign-extend the native
// value to I64 before the call; the FFI body routes to the matching
// TypedArray::push instantiation. (Get/set/len remain inlined in
// Cranelift directly against the native buffer layout.)
pub(crate) v2_array_push: FuncRef,
// v2 struct allocator.
pub(crate) v2_alloc_struct: FuncRef,
// v2 SIMD reductions (f64/i64 sum/min/max/mean/sum-of-squares).
pub(crate) v2_array_sum_f64: FuncRef,
pub(crate) v2_array_sum_i64: FuncRef,
pub(crate) v2_array_min_f64: FuncRef,
pub(crate) v2_array_max_f64: FuncRef,
pub(crate) v2_array_mean_f64: FuncRef,
pub(crate) v2_array_sum_squares_f64: FuncRef,
// v2 SIMD element-wise scalar ops (allocating, f64).
pub(crate) v2_array_scale_f64: FuncRef,
pub(crate) v2_array_add_scalar_f64: FuncRef,
// v2 SIMD element-wise binary ops (allocating, f64).
pub(crate) v2_array_add_f64: FuncRef,
pub(crate) v2_array_mul_f64: FuncRef,
// F5.a/F5.b + W15.2-LANG-7 close: string `+` lowering.
// `string_concat` — `(a_bits: u64, a_kind_code: u8, b_bits: u64,
// b_kind_code: u8) -> u64`. Kind codes carry the ADR-006 §2.7.5/§2.7.7
// producer-side stamp per `crates/shape-jit/src/ffi/stack_kind_code.rs`.
// Returns a fresh `Arc<String>` carrier (`Arc::into_raw(Arc::new(out))
// as u64`) — the §2.7.5 `NativeKind::String` carrier shape every
// downstream consumer reads. Called from `mir_compiler::rvalues::
// compile_rvalue` when either operand slot carries `NativeKind::
// String` under `BinOp::Add`. Covers the desugared chain emitted by
// `f"..."` formatted strings as well.
pub(crate) string_concat: FuncRef,
// W11-fup-A (Phase 3d, 2026-05-18): typed-pow entry points for the
// MIR `BinOp::Pow` JIT codegen. `pow_f64` takes/returns native f64;
// `pow_i64` takes/returns native i64. Bodies live at
// `crates/shape-jit/src/ffi/v2_math.rs::jit_pow_f64 / jit_pow_i64`.
// Called from `mir_compiler::rvalues::compile_binop_f64` /
// `compile_binop_int64` `BinOp::Pow` arms when both operands have
// the proven matching native kind.
pub(crate) pow_f64: FuncRef,
pub(crate) pow_i64: FuncRef,
// W15.2-LANG-6 jit-math-nan-poisoning (Phase 4b Round 2, 2026-05-18):
// typed-f64 single-arg math FFI entry points dispatched by the JIT
// Call-terminator interception in `mir_compiler/terminators.rs` when
// the callee is a bare-math-builtin `MirConstant::Function(name)` and
// the arg has proven `NativeKind::Float64` (or `NativeKind::Int64`
// widened via Cranelift's `fcvt_from_sint`). Native f64 ABI; bodies
// live at `crates/shape-jit/src/ffi/v2_math.rs::jit_{sqrt,abs,...}_f64`.
//
// Per ADR-006 §2.7.5 stamp-at-compile-time: the arg kind is the
// producing-site discriminator; no NaN-box decode at the FFI boundary,
// no Bool-default fallback. Fixes the symmetric defect of
// W12-enum-constructor-mir-lowering / W12-collection-constructor-mir-
// lowering — bare-name builtin leaks as `MirConstant::Function(name)`
// into MIR which the JIT cannot resolve through `function_indices`,
// so the pre-fix indirect-call path returned `TAG_NULL` (NaN-tagged
// null bits) which the F64 caller-side decode interpreted as `NaN`.
pub(crate) sqrt_f64: FuncRef,
pub(crate) abs_f64: FuncRef,
pub(crate) floor_f64: FuncRef,
pub(crate) ceil_f64: FuncRef,
pub(crate) round_f64: FuncRef,
pub(crate) sin_f64: FuncRef,
pub(crate) cos_f64: FuncRef,
pub(crate) tan_f64: FuncRef,
pub(crate) asin_f64: FuncRef,
pub(crate) acos_f64: FuncRef,
pub(crate) atan_f64: FuncRef,
pub(crate) exp_f64: FuncRef,
pub(crate) ln_f64: FuncRef,
// ADR-006 §2.7.5 — kinded EnumStore producers
// (W12-jit-aggregate-non-array, 2026-05-12). Three entry points
// matching the VM-side `BuiltinFunction::OkCtor` / `ErrCtor` /
// `SomeCtor` shapes (`crates/shape-vm/src/executor/vm_impl/
// builtins.rs:551-586`). The JIT-side bodies use the existing
// `box_ok` / `box_err` / `box_some` heap-pointer encoding (legacy
// NaN-box shape with HK_OK / HK_ERR / HK_SOME prefix); conversion
// to the post-strict-typing `Arc<ResultData>` / `Arc<OptionData>`
// carrier happens at the JIT↔VM boundary via the existing
// `jit_bits_to_nanboxed` conversion infrastructure
// (`crates/shape-jit/src/ffi/conversion.rs:246-258` — same path as
// `jit_unwrap_ok` / `jit_is_ok` etc.).
//
// The JIT EnumStore consumer dispatches on the MIR statement's
// `variant_name` field to pick the right entry. Slot kind stamped
// from the conduit (`concrete_types[container_slot]` →
// `Ptr(HeapKind::Result)` / `Ptr(HeapKind::Option)`); no
// Bool-default per §2.7.7 #9.
pub(crate) make_ok: FuncRef,
pub(crate) make_err: FuncRef,
pub(crate) make_some: FuncRef,
// ADR-006 §2.7.17 / Q18 — Arc-shape Result/Option producers
// (W12-jit-result-option-trinity, Phase 3 cluster-0 Round 7A,
// 2026-05-12). These produce `Arc::into_raw(Arc<ResultData>) as u64`
// / `Arc::into_raw(Arc<OptionData>) as u64` directly per the strict-
// typed §2.7.17 carrier — matching the VM-side `BuiltinFunction::
// OkCtor` / `ErrCtor` / `SomeCtor` / `NoneCtor` output. The producer
// signature is `(payload_bits: u64, payload_kind_code: u8) -> u64`
// where the kind code is the §2.7.7 / Q9 parallel-track byte
// (`stack_kind_code::encode(payload_kind)`) stamped at JIT-compile
// time from the EnumStore operand's MIR-inferred kind. Replaces the
// legacy `make_ok` / `make_err` / `make_some` NaN-box family at the
// strict-typed EnumStore consumer (those FFI fields above remain
// referenced by ffi/conversion.rs for the JIT↔VM trampoline boundary).
pub(crate) v2_make_result_ok: FuncRef,
pub(crate) v2_make_result_err: FuncRef,
pub(crate) v2_make_option_some: FuncRef,
pub(crate) v2_make_option_none: FuncRef,
// ADR-006 §2.7.17 — Arc-shape Result/Option predicates + payload
// extractors. Read `is_ok` / `is_some` from the `*const ResultData` /
// `*const OptionData` borrow directly — NO NaN-box tag decode, NO
// `is_heap_kind` probe (§2.7.7 #4 / #7 forbidden per CLAUDE.md
// "Forbidden code" — runtime tag_bits dispatch deleted with the
// W-series). Used by the JIT `Rvalue::EnumTest` / `Rvalue::EnumPayload`
// consumer in `mir_compiler/rvalues.rs`.
pub(crate) arc_result_is_ok: FuncRef,
pub(crate) arc_result_is_err: FuncRef,
pub(crate) arc_result_payload: FuncRef,
pub(crate) arc_option_is_some: FuncRef,
pub(crate) arc_option_is_none: FuncRef,
pub(crate) arc_option_payload: FuncRef,
// Arc-shape kinded retain/release for `Arc<ResultData>` /
// `Arc<OptionData>` carriers (W12-jit-result-option-trinity,
// 2026-05-12). The legacy `arc_retain` / `arc_release` operate on
// the `UnifiedValue<T>` refcount layout (offset 4) and corrupt the
// typed-Arc allocations (whose refcount lives at offset -16 per
// Rust Arc contract). Refcount sites for Result/Option-kinded
// slots dispatch HERE instead of the legacy entries.
pub(crate) arc_result_retain: FuncRef,
pub(crate) arc_result_release: FuncRef,
pub(crate) arc_option_retain: FuncRef,
pub(crate) arc_option_release: FuncRef,
// ADR-006 §2.7.5 / §2.7.25 — Typed-Arc collection allocators
// (W12-jit-collection-arc-ffi-ctors-and-refcount, Phase 3 cluster-0
// Round 9 / 8B.1, 2026-05-13). Each entry produces
// `Arc::into_raw(Arc<XData>) as u64` with the standard Rust Arc
// layout (refcount at offset -16). Distinct from W11's
// `Box::into_raw(Box::new(UnifiedValue<T>))` carrier (HeapHeader
// refcount at offset 4) — see `ffi/v2/collection_arc.rs` header
// for the carrier-shape rule audit §5 codified.
//
// Zero-arg ctors (5 entries): no payload, take no parameters.
pub(crate) v2_make_hashset: FuncRef,
pub(crate) v2_make_hashmap: FuncRef,
pub(crate) v2_make_deque: FuncRef,
pub(crate) v2_make_priorityqueue: FuncRef,
pub(crate) v2_make_channel: FuncRef,
// Single-kind ctors (2 entries): compile-time-validated inner kind
// per §2.7.25 (Atomic→Int64, Lazy→Ptr(HeapKind::Closure)). The
// EnumStore consumer surfaces-and-stops on inner-kind mismatch at
// MIR-emit time before reaching these bodies.
pub(crate) v2_make_atomic: FuncRef,
pub(crate) v2_make_lazy: FuncRef,
// Carrier-pair ctor (1 entry): Mutex accepts any inner kind via
// the `(bits, kind_code: u8)` carrier-pair per §2.7.5. Unknown
// kind ords surface via §2.7.7 #9 — no Bool-default.
pub(crate) v2_make_mutex: FuncRef,
// ADR-006 §2.7.5 / §2.7.17 — Per-HeapKind kinded retain/release
// entries for the 8 typed-Arc collection carriers. Required because
// the legacy `arc_retain` / `arc_release` operate on the
// `UnifiedValue<T>` HeapHeader refcount at offset 4, which would
// scribble on the inner payload of an `Arc::into_raw(Arc<XData>)`
// carrier (whose refcount lives at offset -16). Same defection-
// shape Round 7A's `arc_result_retain` / `arc_option_retain` pair
// resolved at the Result/Option Arc-carrier site.
//
// 16 entries: retain + release per HashSet, HashMap, Deque,
// PriorityQueue, Channel, Mutex, Atomic, Lazy.
pub(crate) arc_hashset_retain: FuncRef,
pub(crate) arc_hashset_release: FuncRef,
pub(crate) arc_hashmap_retain: FuncRef,
pub(crate) arc_hashmap_release: FuncRef,
pub(crate) arc_deque_retain: FuncRef,
pub(crate) arc_deque_release: FuncRef,
pub(crate) arc_priorityqueue_retain: FuncRef,
pub(crate) arc_priorityqueue_release: FuncRef,
pub(crate) arc_channel_retain: FuncRef,
pub(crate) arc_channel_release: FuncRef,
pub(crate) arc_mutex_retain: FuncRef,
pub(crate) arc_mutex_release: FuncRef,
pub(crate) arc_atomic_retain: FuncRef,
pub(crate) arc_atomic_release: FuncRef,
pub(crate) arc_lazy_retain: FuncRef,
pub(crate) arc_lazy_release: FuncRef,
// ADR-006 §2.7.5 — `Arc<String>` strict-typed carrier retain/release
// (W12-jit-string-carrier-unification, Phase 3 cluster-0 Round 12 T2/T3,
// 2026-05-13). The §2.7.5 `NativeKind::String` slot carries
// `Arc::into_raw(Arc<String>) as u64`; refcount at offset -16 per the
// standard Rust Arc layout. The legacy `arc_retain` / `arc_release`
// operate on the W11 `UnifiedValue<T>` HeapHeader at offset 4 and
// would scribble on the `String` payload's `ptr/cap/len` words.
//
// Bodies in `ffi/string.rs::jit_arc_string_retain` / `_release`.
// Mirror of Round 7A's `arc_result_retain` / `_release` and Round 9's
// typed-Arc collection retain/release pairs.
pub(crate) arc_string_retain: FuncRef,
pub(crate) arc_string_release: FuncRef,
// ADR-006 §2.7.5 / §2.7.11 / Q12 — `Arc<HeapValue::ClosureRaw>`
// strict-typed closure carrier retain/release (W15.2-LANG-4
// jit-filter-predicate close, 2026-05-18). The §2.7.11/Q12
// `NativeKind::Ptr(HeapKind::Closure)` slot carries
// `Arc::into_raw(Arc<HeapValue>) as u64` per `jit_finalize_heap_closure`;
// refcount at offset -16 per the standard Rust Arc layout. The
// legacy `arc_retain` / `arc_release` (UnifiedValue<T> HeapHeader
// at offset 4) would scribble on the inner `HeapValue` payload's
// discriminant + variant data.
//
// Bodies in `ffi/object/closure.rs::jit_arc_closure_retain` /
// `_release`. Mirror of Round 12 T2/T3's `arc_string_retain` /
// `_release` and Round 7A's `arc_result_retain` / `_release` pairs.
pub(crate) arc_closure_retain: FuncRef,
pub(crate) arc_closure_release: FuncRef,
// v2 typed HashMap<string, ...> access.
//
// SURFACE (ADR-006 §2.7.14 Q15 / W11-jit-carrier-conversion sub-cluster):
// the kind-blind `jit_v2_map_*` symbols (deleted ValueWord-shape map FFI)
// are gated on the kinded `Arc<HashMapData>` + `KindedSlot` rebuild. The
// FuncRef slots are deleted from this struct in lockstep with the v2_map
// call-site surface-and-stop in `mir_compiler/v2_typed_map.rs`. The
// declarations in `ffi_symbols/v2_symbols.rs::declare_v2_functions` are
// already a no-op for the same set.
}