mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
24c3c96958
This commit adds granular `--unstable-*` flags: - "--unstable-broadcast-channel" - "--unstable-ffi" - "--unstable-fs" - "--unstable-http" - "--unstable-kv" - "--unstable-net" - "--unstable-worker-options" - "--unstable-cron" These flags are meant to replace a "catch-all" flag - "--unstable", that gives a binary control whether unstable features are enabled or not. The downside of this flag that allowing eg. Deno KV API also enables the FFI API (though the latter is still gated with a permission). These flags can also be specified in `deno.json` file under `unstable` key. Currently, "--unstable" flag works the same way - I will open a follow up PR that will print a warning when using "--unstable" and suggest to use concrete "--unstable-*" flag instead. We plan to phase out "--unstable" completely in Deno 2.
25 lines
944 B
Markdown
25 lines
944 B
Markdown
# 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:
|
|
|
|
```bash
|
|
target/release/deno bench --allow-ffi --allow-read --unstable-ffi ./test_ffi/tests/bench.js
|
|
```
|