56 breaking releases

Uses new Rust 2021

new 0.58.0 Sep 28, 2022
0.56.0 Sep 15, 2022
0.50.0 Jul 28, 2022
0.32.0 Mar 31, 2022
0.14.0 Nov 24, 2021

#302 in Web programming

Download history 551/week @ 2022-06-11 549/week @ 2022-06-18 741/week @ 2022-06-25 763/week @ 2022-07-02 664/week @ 2022-07-09 622/week @ 2022-07-16 566/week @ 2022-07-23 630/week @ 2022-07-30 860/week @ 2022-08-06 591/week @ 2022-08-13 660/week @ 2022-08-20 685/week @ 2022-08-27 650/week @ 2022-09-03 1028/week @ 2022-09-10 870/week @ 2022-09-17 734/week @ 2022-09-24

3,401 downloads per month
Used in 10 crates (2 directly)

MIT license

5MB
16K SLoC

Rust 14K SLoC // 0.1% comments JavaScript 1.5K SLoC // 0.1% comments TypeScript 1K SLoC // 0.1% comments

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 ./test_ffi/tests/bench.js

Dependencies

~77MB
~1.5M SLoC