deno/ext/ffi
snek 4c0ae84d94
Some checks are pending
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
fix(ffi): check that fast calls are taken (#30658)
2025-09-11 12:02:57 +02:00
..
00_ffi.js fix(ffi): check that fast calls are taken (#30658) 2025-09-11 12:02:57 +02:00
call.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
callback.rs chore: Rust 1.89.0 (#30364) 2025-08-09 11:11:48 +00:00
Cargo.toml 2.5.0 (#30673) 2025-09-10 09:17:46 +05:30
dlfcn.rs fix(ffi): check that fast calls are taken (#30658) 2025-09-11 12:02:57 +02:00
ir.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
lib.rs fix(ffi): check that fast calls are taken (#30658) 2025-09-11 12:02:57 +02:00
README.md chore: move test_ffi and test_nap to tests/ [WIP] (#22394) 2024-02-12 13:46:50 -07:00
repr.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
static.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
symbol.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
turbocall.rs fix(ffi): check that fast calls are taken (#30658) 2025-09-11 12:02:57 +02:00

deno_ffi

This crate implements dynamic library ffi.

Performance

Deno FFI calls have extremely low overhead (~1ns on M1 16GB RAM) and perform on par with native code. Deno leverages V8 fast api calls and JIT compiled bindings to achieve these high speeds.

Deno.dlopen generates an optimized and a fallback path. Optimized paths are triggered when V8 decides to optimize the function, hence call through the Fast API. Fallback paths handle types like function callbacks and implement proper error handling for unexpected types, that is not supported in Fast calls.

Optimized calls enter a JIT compiled function "trampoline" that translates Fast API values directly for symbol calls. JIT compilation itself is super fast, thanks to tinycc. Currently, the optimized path is only supported on Linux and MacOS.

To run benchmarks:

target/release/deno bench --allow-ffi --allow-read --unstable-ffi ./tests/ffi/tests/bench.js