Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ffi to replace plugins #11152

Merged
merged 66 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
00228d7
feat: begin work on ffi
eliassjogreen Jun 22, 2021
dff8206
Merge branch 'denoland:main' into main
eliassjogreen Jun 27, 2021
e594fdd
permission and fix build
eliassjogreen Jun 27, 2021
3433945
chore: remove old plugin api
eliassjogreen Jun 27, 2021
9e57e82
feat: permissions
eliassjogreen Jun 27, 2021
60bee1f
feat: permissions
eliassjogreen Jun 27, 2021
7d1d520
fix: lsp integration test
eliassjogreen Jun 27, 2021
2db65db
chore: fmt
eliassjogreen Jun 27, 2021
5500ea1
Merge branch 'main' of https://github.com/denoland/deno into denoland…
eliassjogreen Jul 5, 2021
40dfcd8
merge changes
eliassjogreen Jul 5, 2021
e5e1471
Merge branch 'denoland-main'
eliassjogreen Jul 5, 2021
ed3ae89
Merge branch 'denoland:main' into main
eliassjogreen Jul 5, 2021
9e37073
fix ci?
eliassjogreen Jul 6, 2021
1481018
update lockfile
eliassjogreen Jul 6, 2021
ad30536
Merge branch 'main' into main
eliassjogreen Jul 6, 2021
a4cf764
update lock
eliassjogreen Jul 6, 2021
4fc52a3
refactor
eliassjogreen Jul 6, 2021
cccbb87
better permissions
eliassjogreen Jul 8, 2021
8ac6dbb
fmt and lint
eliassjogreen Jul 8, 2021
2f68bce
Merge branch 'main' into main
eliassjogreen Jul 8, 2021
8c31e20
update lockfile
eliassjogreen Jul 8, 2021
1e1fcc4
attempt to fix autoconf issue
eliassjogreen Jul 8, 2021
d4156c0
Merge branch 'main' into main
eliassjogreen Jul 8, 2021
af8a9a3
apt-get install dependencies? argh...
eliassjogreen Jul 8, 2021
05c4fb5
apt-get install dependencies? argh...
eliassjogreen Jul 8, 2021
33cd326
nope
eliassjogreen Jul 8, 2021
d05fe4f
don't depend on autotools, fix m1 build, use ry's fork of libffi-rs
ry Jul 9, 2021
5eaa8f5
Merge branch 'main' into eliassjogreen/main
ry Jul 9, 2021
9014e1f
apt-get install file
ry Jul 9, 2021
4e0f873
undo github actions changes
ry Jul 9, 2021
861c16d
fix sysroot build
piscisaureus Jul 10, 2021
5ca83b4
fix some tests
piscisaureus Jul 10, 2021
0f14c1a
fix another test
piscisaureus Jul 10, 2021
ad5e5ef
fix yet another test
piscisaureus Jul 10, 2021
7866903
fix ffi test
piscisaureus Jul 10, 2021
7beb2ab
Merge remote-tracking branch 'origin/main' into ffi
piscisaureus Jul 10, 2021
c18c24f
undo unrelated Cargo.toml changes
piscisaureus Jul 10, 2021
9e576f5
undo unrelated changes to Cargo.lock
piscisaureus Jul 10, 2021
2c9b71b
don't need template string here
piscisaureus Jul 10, 2021
f2912f0
Merge remote-tracking branch 'origin/main' into ffi
piscisaureus Jul 12, 2021
5ac8b49
fix merge
piscisaureus Jul 12, 2021
50ca0d9
update types
eliassjogreen Jul 14, 2021
2b8d716
Merge remote-tracking branch 'origin/main' into ffi
piscisaureus Jul 16, 2021
044bc5e
Remove unstable native plugins (#10908)
bartlomieju Jul 2, 2021
452a500
Fix use-after-free
piscisaureus Jul 16, 2021
dec90cb
ci: fail-fast off
piscisaureus Jul 16, 2021
1a9fb25
Merge remote-tracking branch 'origin/main' into ffi
piscisaureus Jul 16, 2021
fe65d10
umm nooo
piscisaureus Jul 16, 2021
ff5d594
rename stuff
piscisaureus Jul 17, 2021
8995e85
upgrade deno-libbfi
piscisaureus Jul 17, 2021
672aaa7
Revert "ci: fail-fast off"
piscisaureus Jul 17, 2021
5d639e1
update deno-libffi-sys
piscisaureus Jul 17, 2021
9c820d5
Upgrade to deno-libffi 0.0.3
piscisaureus Jul 18, 2021
79992b1
Merge remote-tracking branch 'origin/main' into ffi
piscisaureus Jul 18, 2021
9b22cad
Merge branch 'main' into eliassjogreen_main
bartlomieju Jul 26, 2021
582127d
update extensions/ffi
bartlomieju Jul 26, 2021
be0c886
reset CI
bartlomieju Jul 26, 2021
393c95a
Merge branch 'main' into eliassjogreen_main
bartlomieju Jul 29, 2021
da4a270
Merge branch 'main' into eliassjogreen_main
bartlomieju Jul 29, 2021
8f7b719
Merge branch 'main' into eliassjogreen_main
bartlomieju Aug 2, 2021
0738564
clippy
bartlomieju Aug 2, 2021
7088a9d
Merge branch 'main' into eliassjogreen_main
bartlomieju Aug 4, 2021
f69ffb0
fmt
bartlomieju Aug 4, 2021
d0fbb91
Merge branch 'main' into eliassjogreen_main
bartlomieju Aug 6, 2021
e36d4f0
Merge branch 'main' into eliassjogreen_main
bartlomieju Aug 6, 2021
c6b66a2
reset CI
bartlomieju Aug 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ jobs:
sudo apt-get update
sudo apt-get install debootstrap

# Note: git, nc, strace, and time, are needed to run the benchmarks.
sudo debootstrap \
--include=ca-certificates,curl,git,netcat-openbsd,strace,time \
--no-merged-usr --variant=minbase bionic /sysroot \
http://azure.archive.ubuntu.com/ubuntu
# `file` and `make` are needed to build libffi-sys.
# `curl` is needed to build rusty_v8.
# `git`, `nc`, `strace`, and `time`, are needed to run the benchmarks.
sudo debootstrap \
--include=ca-certificates,curl,file,git,make,netcat-openbsd,strace,time \
--no-merged-usr --variant=minbase bionic /sysroot \
http://azure.archive.ubuntu.com/ubuntu
sudo mount --rbind /dev /sysroot/dev
sudo mount --rbind /sys /sysroot/sys
sudo mount --rbind /home /sysroot/home
Expand Down
52 changes: 47 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ members = [
"cli",
"core",
"runtime",
"test_plugin",
"test_ffi",
"test_util",
"extensions/broadcast_channel",
"extensions/console",
"extensions/crypto",
"extensions/fetch",
"extensions/ffi",
"extensions/http",
"extensions/net",
"extensions/timers",
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ deno_console = { version = "0.13.0", path = "../extensions/console" }
deno_core = { version = "0.95.0", path = "../core" }
deno_crypto = { version = "0.27.0", path = "../extensions/crypto" }
deno_fetch = { version = "0.36.0", path = "../extensions/fetch" }
deno_ffi = { version = "0.1.0", path = "../extensions/ffi" }
deno_http = { version = "0.4.0", path = "../extensions/http" }
deno_net = { version = "0.4.0", path = "../extensions/net" }
deno_timers = { version = "0.11.0", path = "../extensions/timers" }
Expand Down
2 changes: 1 addition & 1 deletion cli/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"listen",
"listenDatagram",
"loadavg",
"openPlugin",
"dlopen",
"osRelease",
"ppid",
"resolveDns",
Expand Down
8 changes: 4 additions & 4 deletions cli/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ declare namespace Deno {
| "write"
| "net"
| "env"
| "plugin"
| "ffi"
| "hrtime";

/** The current status of the permission. */
Expand Down Expand Up @@ -2167,8 +2167,8 @@ declare namespace Deno {
variable?: string;
}

export interface PluginPermissionDescriptor {
name: "plugin";
export interface FFIPermissionDescriptor {
name: "ffi";
}

export interface HrtimePermissionDescriptor {
Expand All @@ -2183,7 +2183,7 @@ declare namespace Deno {
| WritePermissionDescriptor
| NetPermissionDescriptor
| EnvPermissionDescriptor
| PluginPermissionDescriptor
| FFIPermissionDescriptor
| HrtimePermissionDescriptor;

export interface PermissionStatusEventMap {
Expand Down
76 changes: 42 additions & 34 deletions cli/dts/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,36 +107,44 @@ declare namespace Deno {
swapFree: number;
}

/** **UNSTABLE**: new API, yet to be vetted.
*
* Open and initialize a plugin.
*
* ```ts
* import { assert } from "https://deno.land/std/testing/asserts.ts";
* const rid = Deno.openPlugin("./path/to/some/plugin.so");
*
* // The Deno.core namespace is needed to interact with plugins, but this is
* // internal so we use ts-ignore to skip type checking these calls.
* // @ts-ignore
* const { op_test_sync, op_test_async } = Deno.core.ops();
*
* assert(op_test_sync);
* assert(op_test_async);
*
* // @ts-ignore
* const result = Deno.core.opSync("op_test_sync");
*
* // @ts-ignore
* const result = await Deno.core.opAsync("op_test_sync");
* ```
*
* Requires `allow-plugin` permission.
/** All possible types for interfacing with foreign functions */
export type NativeType =
| "void"
| "u8"
| "i8"
| "u16"
| "i16"
| "u32"
| "i32"
| "u64"
| "i64"
| "usize"
| "isize"
| "f32"
| "f64";

/** A foreign function as defined by its parameter and result types */
export interface ForeignFunction {
parameters: NativeType[];
result: NativeType;
}

/** A dynamic library resource */
export interface DynamicLibrary<S extends Record<string, ForeignFunction>> {
/** All of the registered symbols along with functions for calling them */
symbols: { [K in keyof S]: (...args: unknown[]) => unknown };

close(): void;
}

/** **UNSTABLE**: new API
*
* The plugin system is not stable and will change in the future, hence the
* lack of docs. For now take a look at the example
* https://github.com/denoland/deno/tree/main/test_plugin
* Opens a dynamic library and registers symbols
*/
export function openPlugin(filename: string): number;
export function dlopen<S extends Record<string, ForeignFunction>>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have allow-ffi, it would be helpful for googling/doc searches if this function somehow included the string "ffi". Maybe rename "dlopen" to "openffi" ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ffiopen has a nice ring

filename: string,
symbols: S,
): DynamicLibrary<S>;

/** The log category for a diagnostic message. */
export enum DiagnosticCategory {
Expand Down Expand Up @@ -1043,14 +1051,14 @@ declare namespace Deno {
*/
net?: "inherit" | boolean | string[];

/** Specifies if the `plugin` permission should be requested or revoked.
* If set to `"inherit"`, the current `plugin` permission will be inherited.
* If set to `true`, the global `plugin` permission will be requested.
* If set to `false`, the global `plugin` permission will be revoked.
/** Specifies if the `ffi` permission should be requested or revoked.
* If set to `"inherit"`, the current `ffi` permission will be inherited.
* If set to `true`, the global `ffi` permission will be requested.
* If set to `false`, the global `ffi` permission will be revoked.
*
* Defaults to "inherit".
*/
plugin?: "inherit" | boolean;
ffi?: "inherit" | boolean;

/** Specifies if the `read` permission should be requested or revoked.
* If set to `"inherit"`, the current `read` permission will be inherited.
Expand Down Expand Up @@ -1137,7 +1145,7 @@ declare interface WorkerOptions {
* For example: `["https://deno.land", "localhost:8080"]`.
*/
net?: "inherit" | boolean | string[];
plugin?: "inherit" | boolean;
ffi?: "inherit" | boolean;
read?: "inherit" | boolean | Array<string | URL>;
run?: "inherit" | boolean | Array<string | URL>;
write?: "inherit" | boolean | Array<string | URL>;
Expand Down
Loading