133 breaking releases

new 0.135.0 Apr 25, 2024
0.133.0 Apr 12, 2024
0.130.0 Mar 28, 2024
0.116.0 Dec 21, 2023
0.14.0 Nov 24, 2021

#1657 in Web programming

Download history 523/week @ 2024-01-03 682/week @ 2024-01-10 751/week @ 2024-01-17 769/week @ 2024-01-24 953/week @ 2024-01-31 664/week @ 2024-02-07 775/week @ 2024-02-14 1328/week @ 2024-02-21 1283/week @ 2024-02-28 934/week @ 2024-03-06 883/week @ 2024-03-13 751/week @ 2024-03-20 1183/week @ 2024-03-27 797/week @ 2024-04-03 1146/week @ 2024-04-10 646/week @ 2024-04-17

3,907 downloads per month
Used in 25 crates (5 directly)

MIT license

180KB
4.5K SLoC

Rust 4K SLoC // 0.1% comments JavaScript 560 SLoC // 0.0% 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-ffi ./tests/ffi/tests/bench.js

Dependencies

~96MB
~2M SLoC