deno/ext/ffi
Nathan Whitaker 5421a29944
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 / 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 / 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 / test release macos-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 / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
refactor: remove permission traits + generics from extension crates (#31284)
I also moved the `RuntimePermissionDescriptorParser` struct from
deno_runtime into deno_permissions, so that extension crates can use it
in tests and stuff like that
2025-11-17 10:30:36 -08:00
..
00_ffi.js fix(ffi): check that fast calls are taken (#30658) 2025-09-11 12:02:57 +02:00
call.rs refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
callback.rs refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
Cargo.toml 2.5.6 (#31136) 2025-10-29 23:50:18 +00:00
dlfcn.rs refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
ir.rs perf: stack allocated v8 scopes (#30827) 2025-09-23 17:54:14 -07:00
lib.rs refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
README.md chore: move test_ffi and test_nap to tests/ [WIP] (#22394) 2024-02-12 13:46:50 -07:00
repr.rs refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
static.rs perf: stack allocated v8 scopes (#30827) 2025-09-23 17:54:14 -07:00
symbol.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
turbocall.rs perf: stack allocated v8 scopes (#30827) 2025-09-23 17:54:14 -07: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