From 4aeff38d552962297ea6a9f74305077110a8c0a5 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Wed, 22 May 2019 09:25:26 -0500 Subject: [PATCH] loader: add initial wasi wasm support --- doc/api/cli.md | 8 + doc/api/esm.md | 6 + .../modules/esm/create_dynamic_module.js | 3 +- lib/internal/modules/esm/translators.js | 34 +- lib/internal/wasi.js | 1294 +++++++++++++++++ node.gyp | 2 + src/node_binding.cc | 1 + src/node_binding.h | 12 + src/node_constants.cc | 12 + src/node_options.cc | 7 +- src/node_options.h | 1 + src/node_wasi.cc | 133 ++ test/fixtures/wasi/outside.txt | 1 + test/fixtures/wasi/sandbox/input.txt | 1 + test/fixtures/wasi/sandbox/notadir | 0 test/fixtures/wasi/sandbox/subdir/outside.txt | 1 + test/fixtures/wasi/sandbox/subdir1/input.txt | 1 + test/fixtures/wasi/sandbox/subdir1/loop1 | 1 + .../wasi/sandbox/subdir2/input_link.txt | 1 + test/fixtures/wasi/sandbox/subdir2/loop2 | 1 + test/wasi/README.md | 5 + test/wasi/build.sh | 10 + test/wasi/c/cant_dotdot.c | 11 + test/wasi/c/clock_getres.c | 12 + test/wasi/c/exitcode.c | 5 + test/wasi/c/fd_prestat_get_refresh.c | 8 + test/wasi/c/follow_symlink.c | 15 + test/wasi/c/getentropy.c | 17 + test/wasi/c/getrusage.c | 24 + test/wasi/c/gettimeofday.c | 25 + test/wasi/c/notdir.c | 11 + test/wasi/c/poll.c | 31 + test/wasi/c/preopen_populates.c | 3 + test/wasi/c/read_file.c | 15 + test/wasi/c/read_file_twice.c | 17 + test/wasi/c/stat.c | 53 + test/wasi/c/stdin.c | 16 + test/wasi/c/symlink_escape.c | 9 + test/wasi/c/symlink_loop.c | 9 + test/wasi/c/write_file.c | 15 + test/wasi/patch_preopen.js | 17 + test/wasi/test-wasi.js | 85 ++ test/wasi/testcfg.py | 6 + test/wasi/wasi.status | 7 + test/wasi/wasm/cant_dotdot.wasm | Bin 0 -> 33983 bytes test/wasi/wasm/clock_getres.wasm | Bin 0 -> 31064 bytes test/wasi/wasm/exitcode.wasm | Bin 0 -> 13119 bytes test/wasi/wasm/fd_prestat_get_refresh.wasm | Bin 0 -> 13290 bytes test/wasi/wasm/follow_symlink.wasm | Bin 0 -> 35971 bytes test/wasi/wasm/getentropy.wasm | Bin 0 -> 30772 bytes test/wasi/wasm/getrusage.wasm | Bin 0 -> 31144 bytes test/wasi/wasm/gettimeofday.wasm | Bin 0 -> 30972 bytes test/wasi/wasm/notdir.wasm | Bin 0 -> 32136 bytes test/wasi/wasm/poll.wasm | Bin 0 -> 41241 bytes test/wasi/wasm/preopen_populates.wasm | Bin 0 -> 13114 bytes test/wasi/wasm/read_file.wasm | Bin 0 -> 35955 bytes test/wasi/wasm/read_file_twice.wasm | Bin 0 -> 36057 bytes test/wasi/wasm/stat.wasm | Bin 0 -> 35563 bytes test/wasi/wasm/stdin.wasm | Bin 0 -> 19105 bytes test/wasi/wasm/symlink_escape.wasm | Bin 0 -> 34002 bytes test/wasi/wasm/symlink_loop.wasm | Bin 0 -> 33985 bytes test/wasi/wasm/write_file.wasm | Bin 0 -> 34334 bytes 62 files changed, 1940 insertions(+), 6 deletions(-) create mode 100644 lib/internal/wasi.js create mode 100644 src/node_wasi.cc create mode 100644 test/fixtures/wasi/outside.txt create mode 100644 test/fixtures/wasi/sandbox/input.txt create mode 100644 test/fixtures/wasi/sandbox/notadir create mode 120000 test/fixtures/wasi/sandbox/subdir/outside.txt create mode 100644 test/fixtures/wasi/sandbox/subdir1/input.txt create mode 120000 test/fixtures/wasi/sandbox/subdir1/loop1 create mode 100644 test/fixtures/wasi/sandbox/subdir2/input_link.txt create mode 120000 test/fixtures/wasi/sandbox/subdir2/loop2 create mode 100644 test/wasi/README.md create mode 100755 test/wasi/build.sh create mode 100644 test/wasi/c/cant_dotdot.c create mode 100644 test/wasi/c/clock_getres.c create mode 100644 test/wasi/c/exitcode.c create mode 100644 test/wasi/c/fd_prestat_get_refresh.c create mode 100644 test/wasi/c/follow_symlink.c create mode 100644 test/wasi/c/getentropy.c create mode 100644 test/wasi/c/getrusage.c create mode 100644 test/wasi/c/gettimeofday.c create mode 100644 test/wasi/c/notdir.c create mode 100644 test/wasi/c/poll.c create mode 100644 test/wasi/c/preopen_populates.c create mode 100644 test/wasi/c/read_file.c create mode 100644 test/wasi/c/read_file_twice.c create mode 100644 test/wasi/c/stat.c create mode 100644 test/wasi/c/stdin.c create mode 100644 test/wasi/c/symlink_escape.c create mode 100644 test/wasi/c/symlink_loop.c create mode 100644 test/wasi/c/write_file.c create mode 100644 test/wasi/patch_preopen.js create mode 100644 test/wasi/test-wasi.js create mode 100644 test/wasi/testcfg.py create mode 100644 test/wasi/wasi.status create mode 100755 test/wasi/wasm/cant_dotdot.wasm create mode 100755 test/wasi/wasm/clock_getres.wasm create mode 100755 test/wasi/wasm/exitcode.wasm create mode 100755 test/wasi/wasm/fd_prestat_get_refresh.wasm create mode 100755 test/wasi/wasm/follow_symlink.wasm create mode 100755 test/wasi/wasm/getentropy.wasm create mode 100755 test/wasi/wasm/getrusage.wasm create mode 100755 test/wasi/wasm/gettimeofday.wasm create mode 100755 test/wasi/wasm/notdir.wasm create mode 100755 test/wasi/wasm/poll.wasm create mode 100755 test/wasi/wasm/preopen_populates.wasm create mode 100755 test/wasi/wasm/read_file.wasm create mode 100755 test/wasi/wasm/read_file_twice.wasm create mode 100755 test/wasi/wasm/stat.wasm create mode 100755 test/wasi/wasm/stdin.wasm create mode 100755 test/wasi/wasm/symlink_escape.wasm create mode 100755 test/wasi/wasm/symlink_loop.wasm create mode 100755 test/wasi/wasm/write_file.wasm diff --git a/doc/api/cli.md b/doc/api/cli.md index 4bf6a9473a0350..5f4faff2313647 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -190,6 +190,13 @@ added: v12.3.0 Enable experimental WebAssembly module support. +### `--experimental-wasi-modules` + + +Enable experimental [WASI][] module support. + ### `--force-fips`