Skip to content

Conversation

cfallin
Copy link
Contributor

@cfallin cfallin commented May 26, 2023

This PR pulls in some still-experimental work to partially evaluate the SpiderMonkey JS interpreter together with JS scripts, ahead-of-time, to produce compiled code.

It should not yet be considered production-worthy, pending more testing and proving out its stability and performance; but, it is at a point where we believe it should be under a non-default option so that users of the SDK may try it. No guarantees! It may explode your bytecode!

The support works by bundling two builds of the engine Wasm -- with and without the weval intrinsics -- and invoking either Wizer with the "normal" build or weval with the "weval" build, as appropriate. The --enable-weval option selects the latter.

I have measured weval showing speedups of ~30% on a Markdown renderer on my machine, and up to ~3.5x on the crypto benchmark in the Octane suite (1.83x speedup geomean).

This refers to a hash for the runtime/spidermonkey submodule that is in fastly/spidermonkey-wasi-embedding#17; that will need to be merged first (and probably bytecodealliance/gecko-dev#5 before that).

I'm not entirely sure about some of the build/packaging integration; that's the bulk of the changes here and will need special review.

The package deps include @cfallin/weval; if it's preferable, I should probably move the repo to BA and get the appropriate permissions to publish it as @bytecodealliance/weval.

guybedford

This comment was marked as resolved.

import { isFile } from "./isFile.js";
import { isFileOrDoesNotExist } from "./isFileOrDoesNotExist.js";
import wizer from "@bytecodealliance/wizer";
import weval from "@cfallin/weval";
Copy link
Contributor

Choose a reason for hiding this comment

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

A standard technique for lazy initialization in JavaScript would be to turn this into a dynamic import() nested into the async code path where Weval is used only.