-
- Downloads
Bug 1831030 - JS shell on WASI: add basic Wizer integration. r=jandem
This patch allows the use of a JS shell binary, compiled to `wasm32-wasi` (WASI ABI on WebAssembly), to make use of the Wizer snapshotting tool to embed JavaScript source with SpiderMonkey to run in a standalone Wasm module. If enabled with `--enable-js-shell-wizer`, the shell no longer provides an interactive REPL; instead, when invoked during the "initialization" phase of Wizer, it reads JS source on standard input, then saves JS state (the global, the context, etc) for later. When the execution is snapshotted and the snapshot is later executed as an ordinary WASI command, the resume entry-point invokes a JS function named `main` in the global scope, if any. An example of how to use this follows: ``` $ echo "function main() { print('hello world'); }" | \ wizer --allow-wasi -r _start=wizer.resume obj-release/dist/bin/js \ -o snapshotted.wasm $ wasmtime snapshotted.wasm hello world $ ``` Differential Revision: https://phabricator.services.mozilla.com/D176979
Showing
- js/moz.configure 16 additions, 0 deletionsjs/moz.configure
- js/src/shell/js.cpp 57 additions, 20 deletionsjs/src/shell/js.cpp
- js/src/shell/jsshell.h 17 additions, 0 deletionsjs/src/shell/jsshell.h
- js/src/shell/moz.build 2 additions, 0 deletionsjs/src/shell/moz.build
- js/src/shell/wizer.cpp 57 additions, 0 deletionsjs/src/shell/wizer.cpp
- third_party/wizer/wizer.h 128 additions, 0 deletionsthird_party/wizer/wizer.h
Loading
Please register or sign in to comment