11# FFI C-Call JIT Trampoline
22
33The first traced ordinary FFI C-call slice now records exact void, signed
4- 32-bit integer, pointer-returning, zero-argument signed 64-bit integer, and
5- FP-returning function cdata on x64. The narrow GPR subset accepts 0, 1, or 2
6- signed 32-bit integer/pointer arguments, plus exact zero-argument signed 64-bit
7- integer returns. The FPR subset accepts 0, 1, or 2 same-kind exact float or
8- double arguments. The recorder emits ` lj_ccall_jit_void_gpr() ` ,
9- ` lj_ccall_jit_i32_gpr() ` , ` lj_ccall_jit_i64_gpr() ` , or
10- ` lj_ccall_jit_ptr_gpr() ` plus a tiny signature code for the GPR argument shape,
11- or ` lj_ccall_jit_num_fpr() ` / ` lj_ccall_jit_flt_fpr() ` for the FP-only FPR
12- shapes.
4+ 32-bit integer, pointer-returning, zero-argument unsigned 32-bit/signed 64-bit
5+ integer, and FP-returning function cdata on x64. The narrow GPR subset accepts
6+ 0, 1, or 2 signed 32-bit integer/pointer arguments, plus exact zero-argument
7+ unsigned 32-bit and signed 64-bit integer returns. The FPR subset accepts 0, 1,
8+ or 2 same-kind exact float or double arguments. The recorder emits
9+ ` lj_ccall_jit_void_gpr() ` , ` lj_ccall_jit_i32_gpr() ` ,
10+ ` lj_ccall_jit_i64_gpr() ` , or ` lj_ccall_jit_ptr_gpr() ` plus a tiny signature
11+ code for the GPR argument shape, ` lj_ccall_jit_u32_0() ` for high-bit-safe
12+ unsigned 32-bit results, or ` lj_ccall_jit_num_fpr() ` /
13+ ` lj_ccall_jit_flt_fpr() ` for the FP-only FPR shapes.
1314
1415This does not enable the old direct ` IR_CALLXS ` path. Each helper is emitted as
1516a side-effecting ` IRCALL ` with an implicit ` lua_State * ` ; the recorder converts
@@ -23,6 +24,7 @@ The scope is deliberately narrow:
2324- exactly 0, 1, or 2 Lua arguments;
2425- exact signed 32-bit integer or pointer argument types;
2526- void, exact signed 32-bit integer, or pointer return types;
27+ - zero-argument exact unsigned 32-bit integer returns as Lua numbers;
2628- zero-argument exact signed 64-bit integer returns;
2729- same-kind exact float/double arguments and exact float/double returns;
2830- x64 only;
@@ -32,11 +34,12 @@ The scope is deliberately narrow:
3234
3335This gives hot ` ffi.C.getpid() ` , ` ffi.C.abs(i) ` , small
3436` int add(int,int) ` -style loops, simple pointer-return/pointer-argument loops,
35- side-effecting ` void f(...) ` loops, zero-argument signed int64 cdata-result
36- loops, and FP-only numeric call loops a traced, nonblocking native-state path
37- without risking the direct backend ` IR_CALLXS ` register/result ordering. The
38- full direct bridge still needs x64 lowering that brackets the foreign ABI call
39- without clobbering argument or result registers.
37+ side-effecting ` void f(...) ` loops, zero-argument high-bit uint32 result loops,
38+ zero-argument signed int64 cdata-result loops, and FP-only numeric call loops a
39+ traced, nonblocking native-state path without risking the direct backend
40+ ` IR_CALLXS ` register/result ordering. The full direct bridge still needs x64
41+ lowering that brackets the foreign ABI call without clobbering argument or
42+ result registers.
4043
4144` tests/t-ffi-ccall-stopreq.c ` also heats the shared ` sleep_i32 ` trampoline until
4245a trace exists, starts the STOPREQ publisher only after that warmup, and catches
0 commit comments