-
Notifications
You must be signed in to change notification settings - Fork 38
Add option to use weval
, an experimental JS AOT option using partial evaluation.
#541
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
88638f7
Add option to use `weval`, an experimental JS AOT option using partia…
cfallin c4a77a4
Pull in updated spidermonkey-wasi-embedding submodule.
cfallin 603a1bd
update wpt and test results
84c7208
edits for ci and wpt runner
56ffef4
update development docs and scripts
4021694
update wpt results
6f94438
update wpt results
a57959e
run all compute app tests using weval
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add option to use
weval
, an experimental JS AOT option using partia…
…l evaluation. 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.
- Loading branch information
commit 88638f719d700d530a4a6a410ed3f36295ebb3f0
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule spidermonkey
updated
8 files
+12 −5 | .github/workflows/main.yml | |
+30 −19 | build-engine.sh | |
+3 −6 | download-engine.sh | |
+1 −1 | gecko-repository | |
+1 −1 | gecko-revision | |
+13 −0 | mozconfig.defaults | |
+3 −0 | mozconfig.weval | |
+22 −19 | rebuild.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ import { mkdir, readFile } from "node:fs/promises"; | |
import { isFile } from "./isFile.js"; | ||
import { isFileOrDoesNotExist } from "./isFileOrDoesNotExist.js"; | ||
import wizer from "@bytecodealliance/wizer"; | ||
import weval from "@cfallin/weval"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { precompile } from "./precompile.js"; | ||
import { bundle } from "./bundle.js"; | ||
import { containsSyntaxErrors } from "./containsSyntaxErrors.js"; | ||
|
||
export async function compileApplicationToWasm(input, output, wasmEngine, enableExperimentalHighResolutionTimeMethods = false) { | ||
export async function compileApplicationToWasm(input, output, wasmEngine, enableExperimentalHighResolutionTimeMethods = false, enableWeval = false) { | ||
try { | ||
if (!(await isFile(input))) { | ||
console.error( | ||
|
@@ -82,17 +83,8 @@ export async function compileApplicationToWasm(input, output, wasmEngine, enable | |
let application = precompile(contents.outputFiles[0].text); | ||
|
||
try { | ||
let wizerProcess = spawnSync( | ||
wizer, | ||
[ | ||
"--inherit-env=true", | ||
"--allow-wasi", | ||
`--dir=.`, | ||
`--wasm-bulk-memory=true`, | ||
"-r _start=wizer.resume", | ||
`-o=${output}`, | ||
wasmEngine, | ||
], | ||
let wizerProcess; | ||
let spawnEnv = | ||
{ | ||
stdio: [null, process.stdout, process.stderr], | ||
input: application, | ||
|
@@ -101,8 +93,35 @@ export async function compileApplicationToWasm(input, output, wasmEngine, enable | |
env: { | ||
ENABLE_EXPERIMENTAL_HIGH_RESOLUTION_TIME_METHODS: enableExperimentalHighResolutionTimeMethods ? '1' : '0' | ||
} | ||
} | ||
); | ||
}; | ||
if (enableWeval) { | ||
let wevalBinary = await weval(); // Lazily fetch the toolchain. | ||
wizerProcess = spawnSync( | ||
wevalBinary, | ||
[ | ||
"-w", | ||
"-o", | ||
output, | ||
"-i", | ||
wasmEngine, | ||
], | ||
spawnEnv | ||
); | ||
} else { | ||
wizerProcess = spawnSync( | ||
wizer, | ||
[ | ||
"--inherit-env=true", | ||
"--allow-wasi", | ||
`--dir=.`, | ||
`--wasm-bulk-memory=true`, | ||
"-r _start=wizer.resume", | ||
`-o=${output}`, | ||
wasmEngine, | ||
], | ||
spawnEnv | ||
); | ||
} | ||
if (wizerProcess.status !== 0) { | ||
throw new Error(`Wizer initialization failure`); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We likely do have to tackle this one head-on here I think -
wasm-opt
is in PATH in all our current workflows, so would need to be renamed. Binaryen bins are added to PATH in https://github.com/fastly/js-compute-runtime/blob/main/.github/workflows/main.yml#L93.