1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00
denoland-deno/ext/ffi
David Sherret 386d5c8310
refactor: remove PermissionsContainer in deno_runtime (#24119)
Also removes permissions being passed in for node resolution. It was
completely useless because we only checked it for reading package.json
files, but Deno reading package.json files for resolution is perfectly
fine.

My guess is this is also a perf improvement because Deno is doing less
work.
2024-06-06 23:37:53 -04:00
..
00_ffi.js BREAKING(ffi/unstable): use BigInt representation in turbocall (#23983) 2024-05-30 08:00:11 +05:30
call.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
callback.rs BREAKING(ffi/unstable): always return u64 as bigint (#23981) 2024-05-28 09:31:09 +05:30
Cargo.toml refactor: remove PermissionsContainer in deno_runtime (#24119) 2024-06-06 23:37:53 -04:00
dlfcn.rs BREAKING(ffi/unstable): use BigInt representation in turbocall (#23983) 2024-05-30 08:00:11 +05:30
ir.rs BREAKING(ffi/unstable): always return u64 as bigint (#23981) 2024-05-28 09:31:09 +05:30
lib.rs refactor: remove PermissionsContainer in deno_runtime (#24119) 2024-06-06 23:37:53 -04:00
README.md chore: move test_ffi and test_nap to tests/ [WIP] (#22394) 2024-02-12 13:46:50 -07:00
repr.rs BREAKING(ffi/unstable): use BigInt representation in turbocall (#23983) 2024-05-30 08:00:11 +05:30
static.rs BREAKING(ffi/unstable): always return u64 as bigint (#23981) 2024-05-28 09:31:09 +05:30
symbol.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
turbocall.rs BREAKING(ffi/unstable): use BigInt representation in turbocall (#23983) 2024-05-30 08:00:11 +05:30

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