Skip to content
Snippets Groups Projects
Commit 0d193086 authored by Chris Fallin's avatar Chris Fallin
Browse files

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
parent dadb4c5b
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment