Expand description
Native C ABI linking and invocation for extern C foreign functions.
ADR-006 §2.7.4 / §2.7.5 SURFACE: this module is a forbidden-pattern
carrier — every input / output path consumed the deleted ValueWord
/ tag_bits / as_heap_ref / vmarray_from_vec / as_native_* /
value_to_* surfaces. The C ABI extension contract (libffi-driven
call) stays raw bits per §2.7.5 cross-crate ABI policy, but the
marshalling between the VM stack (kinded) and the FFI argument
buffer (raw) is the consumer-side migration target. Per the
B11-control-flow-heap dispatch the body is stubbed pending phase-2c
rebuild.
The pre-rebuild surface (now deleted):
-
link_native_function(spec, layouts, cache)— parsed the textual C signature, validated layout references, opened the dynamic library, resolved the symbol, built a libffiCif. The signature parsing + layout resolution path is independent ofValueWordand could be preserved verbatim — butNativeLinkedFunctionitself is the public type used byexecutor/mod.rs:222for theForeignFunctionHandle::Native(Arc<NativeLinkedFunction>)variant; its fields stay unchanged. -
invoke_linked_function(linked, args: &[ValueWord], raw_invoker, vm_stack: &mut [ValueWord])— encoded VM args into FFI buffers perCTypearm, called libffi, then decoded the return value back intoValueWordviafrom_native_*/from_string/from_array(vmarray_from_vec(...)). The mutable-slice writeback path also wrote back viavmarray_from_vec. All of the above are deleted ValueWord-shape constructors; rebuild needs&[KindedSlot]in /KindedSlotout, with&mut [u64]+ parallel&mut [NativeKind]for the writeback path on the §2.7.7 stack ABI.
Rebuild plan: keep the CType parser, CSignature,
NativeTypeLayout resolution, libffi Cif construction, and all
the type-classification helpers (none of those touch ValueWord).
Migrate invoke_linked_function to the kinded API; the
RawCallableInvoker extension contract on the §2.7.5 FFI side
stays (*mut c_void, &u64, &[u64]) -> Result<u64, String> per
module_exports.rs:21.
Structs§
- Native
Linked Function - Phase-2c rebuild placeholder. The pre-rebuild type carried libffi
Cif+CodePtr+ parsedCSignature+ a layout map + anArc<Library>keep-alive — that internal layout is reconstructed in phase-2c on top of the kinded marshalling path. The placeholder keeps the public type name +Arc-wrap visible toexecutor/mod.rs:222’sForeignFunctionHandle::Native(Arc<...>)variant.
Functions§
- invoke_
linked_ function - Phase-2c surface stub. Pre-rebuild body marshalled
&[ValueWord]args into libffi argument buffers perCTypearm, called libffi viaCif::call::<T>, and decoded the return value into aValueWordvia the deletedfrom_native_*/from_string/from_array(vmarray_from_vec(...))constructors. Rebuild target signature:&[KindedSlot] -> Result<KindedSlot, String>with per-NativeKindarg dispatch at the body site (§2.7.6) and a kinded result whoseNativeKindis sourced from the FFI returnCType(post-proof per §2.7.5.1). Thevm_stackwriteback path forcmut_slice<T>argument writebacks rebuilds against the §2.7.7 parallel(stack: &mut [u64], kinds: &mut [NativeKind])pair. - link_
native_ function - Phase-2c surface stub. The pre-rebuild body parsed the textual C
signature (
fn(<params>) -> <ret>), validatedcview<...>/cmut<...>/cslice<...>layout references against the program-suppliedNativeStructLayoutEntrytable, opened the dynamic library vialibloading, resolved the symbol, and built a libffiCif. The signature parser and layout resolver themselves do not touchValueWord— they’re preserved as a starting point for the phase-2c rebuild. The library opening / symbol resolution path is also kind-independent.