Skip to content

Commit bfab024

Browse files
committed
doc: document per-architecture fast FFI argument limits
The prior text covered only two of the seven supported architectures and conflated x86-64 SysV with the stricter Win64 emitter. Signed-off-by: leah-1ee <selee3196@gmail.com>
1 parent cb9bb66 commit bfab024

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

doc/api/ffi.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,26 @@ raw pointer `bigint` values. For pointer-like parameters, `null`, `undefined`,
126126
strings, `Buffer`, typed array, `DataView`, and `ArrayBuffer` values are
127127
converted on the JavaScript side before calling the optimized native wrapper.
128128

129-
Optimized Fast FFI calls support at most 8 function arguments, but the exact
130-
limit depends on the architecture and on the argument types, because each
131-
argument must fit in the registers used by the platform trampoline. Integer
132-
and pointer arguments are limited to 7 on AArch64 and to 6 on x86-64, while
133-
floating-point arguments can use up to 8 on both. Functions that exceed these
134-
limits, including any function with more than 8 arguments, use the generic FFI
135-
call path instead.
129+
Optimized Fast FFI calls fall back to the generic FFI call path when a
130+
function's arguments or return type do not fit the platform-specific fast
131+
trampoline. Fast FFI calls support at most 8 total arguments, and the
132+
register and argument limits differ per architecture:
133+
134+
| Architecture | Max integer/pointer args | Max floating-point args | Buffer-shaped args | Buffer-shaped + FP together | Narrow (8/16-bit) return |
135+
| -------------------------- | ----------------------------------------- | ----------------------- | ------------------ | --------------------------- | ------------------------ |
136+
| AArch64 | 7 (6 when a buffer-shaped arg is present) | 8 | Supported | Not supported | Supported |
137+
| x86-64, Linux/macOS (SysV) | 6 (4 when a buffer-shaped arg is present) | 8 | Supported | Not supported | Supported |
138+
| x86-64, Windows (Win64) | 3 (total arguments also capped at 3) | 3 | Not supported | N/A | Supported |
139+
| s390x | 4 | 4 | Not supported | N/A | Not supported |
140+
| PPC64LE | 7 | 8 | Not supported | N/A | Not supported |
141+
| LoongArch64 | 7 | 8 | Not supported | N/A | Not supported |
142+
| RISC-V (64-bit) | 7 | 8 | Not supported | N/A | Not supported |
143+
144+
PPC64BE has no fast-call trampoline and always uses the generic call path.
145+
"Buffer-shaped args" means `Buffer`, typed array, `DataView`, or `ArrayBuffer`
146+
values passed as pointer-like arguments. Functions whose argument or return
147+
types exceed the limits for the current platform use the generic FFI call
148+
path instead.
136149

137150
## Signature objects
138151

0 commit comments

Comments
 (0)