deno/ext/ffi
denobot 3fbb1daddb
Some checks failed
ci / pre-build (push) Has been cancelled
ci / bench release linux-x86_64 (push) Has been cancelled
ci / test debug linux-x86_64 (push) Has been cancelled
ci / test release linux-x86_64 (push) Has been cancelled
ci / test debug macos-x86_64 (push) Has been cancelled
ci / test release macos-x86_64 (push) Has been cancelled
ci / test debug windows-x86_64 (push) Has been cancelled
ci / test release windows-x86_64 (push) Has been cancelled
ci / test debug linux-aarch64 (push) Has been cancelled
ci / test release linux-aarch64 (push) Has been cancelled
ci / test debug macos-aarch64 (push) Has been cancelled
ci / test release macos-aarch64 (push) Has been cancelled
ci / lint debug linux-x86_64 (push) Has been cancelled
ci / lint debug macos-x86_64 (push) Has been cancelled
ci / lint debug windows-x86_64 (push) Has been cancelled
ci / build libs (push) Has been cancelled
ci / publish canary (push) Has been cancelled
2.6.3 (#31690)
Bumped versions for 2.6.3

---------

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-12-20 11:07:07 +00: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.6.3 (#31690) 2025-12-20 11:07:07 +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