[Tarantool-patches] [PATCH luajit 0/5] Various FFI ABI calling conventions fixes

Sergey Kaplun skaplun at tarantool.org
Sat May 30 19:04:04 MSK 2026


This patch set provides the various improvements to the FFI interface.
The first two patches add support for OSX calling conventions for
varargs functions and fix the JIT-compiled code for varargs functions on
macOS arm64. The next patch adds handling for HFA structures with an
array in them. The fourth patch adds many fixups for x64/arm64 calling
conventions. The last one patch is a follow-up to it to fix the macOS
regression introduced in the fourth patch.

Branch: https://github.com/tarantool/luajit/tree/skaplun/ffi-c-call-conventions

Related issues:
* https://github.com/tarantool/tarantool/issues/12480
* https://github.com/tarantool/tarantool/issues/6097
* https://github.com/LuaJIT/LuaJIT/issues/205
* https://github.com/LuaJIT/LuaJIT/issues/1357
* https://github.com/LuaJIT/LuaJIT/issues/1455

Mike Pall (5):
  FFI: Unify stack setup for C calls in interpreter.
  FFI/ARM64/OSX: Handle non-standard OSX C calling conventions.
  ARM64: Fix pass-by-value struct calling conventions.
  FFI: Various ABI and calling convention fixes.
  FFI/MacOS: Fix calling convention for enums.

 src/lj_asm_arm64.h                            |  75 +-
 src/lj_ccall.c                                | 133 ++--
 src/lj_ccall.h                                |  13 +-
 src/lj_cparse.c                               |   9 +-
 src/lj_crecord.c                              |  27 +
 src/lj_ctype.h                                |   2 +-
 src/vm_arm.dasc                               |   8 +-
 src/vm_arm64.dasc                             |   8 +-
 src/vm_mips.dasc                              |   1 -
 src/vm_mips64.dasc                            |   1 -
 src/vm_ppc.dasc                               |   3 +-
 src/vm_x64.dasc                               |   8 +-
 src/vm_x86.dasc                               |  22 +-
 .../ffi-call-empty-struct.test.lua            |  47 ++
 test/tarantool-tests/ffi-ccall/CMakeLists.txt |  13 +-
 test/tarantool-tests/ffi-ccall/libfficcall.c  | 650 ++++++++++++++++++
 .../ffi-vector-arguments.test.lua             |  62 ++
 .../gh-6097-arm64-osx-ffi-vararg.test.lua     |  43 ++
 ...57-arm64-struct-array-pass-by-val.test.lua |  23 +
 .../lj-1455-arm64-ffi-ccall-hfa.test.lua      |  82 +++
 .../lj-1455-bitfield0-a16.test.lua            |  27 +
 .../lj-1455-ffi-conventions.test.lua          | 441 ++++++++++++
 .../lj-205-arm64-osx-ffi-enum-arg.test.lua    |  63 ++
 .../lj-205-arm64-osx-ffi-small-arg.test.lua   |  29 +
 24 files changed, 1703 insertions(+), 87 deletions(-)
 create mode 100644 test/tarantool-tests/ffi-call-empty-struct.test.lua
 create mode 100644 test/tarantool-tests/ffi-vector-arguments.test.lua
 create mode 100644 test/tarantool-tests/gh-6097-arm64-osx-ffi-vararg.test.lua
 create mode 100644 test/tarantool-tests/lj-1357-arm64-struct-array-pass-by-val.test.lua
 create mode 100644 test/tarantool-tests/lj-1455-arm64-ffi-ccall-hfa.test.lua
 create mode 100644 test/tarantool-tests/lj-1455-bitfield0-a16.test.lua
 create mode 100644 test/tarantool-tests/lj-1455-ffi-conventions.test.lua
 create mode 100644 test/tarantool-tests/lj-205-arm64-osx-ffi-enum-arg.test.lua
 create mode 100644 test/tarantool-tests/lj-205-arm64-osx-ffi-small-arg.test.lua

-- 
2.54.0



More information about the Tarantool-patches mailing list