Skip to content
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

Add option to use weval, an experimental JS AOT option using partial evaluation. #541

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ jobs:
with:
name: engine-${{ matrix.profile }}
path: |
js-compute-runtime.wasm
js-compute-runtime-component-normal.wasm
js-compute-runtime-component-weval.wasm
js-compute-runtime-component.wasm
js-compute-runtime-normal.wasm
js-compute-runtime-weval.wasm

ensure_cargo_installs:
name: Ensure that all required "cargo install" commands are run, or we have a cache hit
Expand Down Expand Up @@ -152,7 +155,14 @@ jobs:
matrix:
include:
- profile: debug
weval: false
- profile: debug
weval: true
- profile: release
weval: false
- profile: release
- profile: release
weval: true
needs: [build, ensure_cargo_installs]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -193,7 +203,7 @@ jobs:

- name: Build WPT runtime
run: |
bash ./tests/wpt-harness/build-wpt-runtime.sh
WEVAL=${{matrix.weval}} bash ./tests/wpt-harness/build-wpt-runtime.sh

- name: Prepare WPT hosts
run: |
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ node_modules/
# *.d
/rusturl/
# compiler_flags
/js-compute-runtime.wasm
/js-compute-runtime-component.wasm
/js-compute-runtime-*.wasm
/js-compute-runtime-component-*.wasm
/runtime/js-compute-runtime/obj
tests/wpt-harness/wpt-test-runner.js
/fastly.wit
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ to pull down or update submodules.

To build from source, you need to ensure that the headers and object files for the [SpiderMonkey JavaScript engine](https://spidermonkey.dev/) are available. It's recommended to download pre-built object files:
```sh
(cd runtime/spidermonkey && bash download-engine.sh)
(cd runtime/spidermonkey && bash download-engine.sh release normal)
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "compute-sdk-test-backend"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/btoa/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ name = "btoa"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/byob/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "byob"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "byte-repeater"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "cache-override"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
[local_server.backends]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "config-store"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
[local_server.dictionaries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "console"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "crypto"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "dynamic-backend"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "edge-dictionary"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
[local_server.dictionaries]
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/env/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "env"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/error/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ name = "error"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "extend-from-builtins"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"


[local_server]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "extend-from-request"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "fanout"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/geoip/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "geoip"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
[local_server.geolocation]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "hello-world"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "includeBytes"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "kv-store"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
# TODO: update this to the kv api when it is ready
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/log/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "log"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "missing-backend"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "multiple-set-cookie"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
[local_server.backends]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "random"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "react-byob"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/regex/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "includeBytes"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "request-cache-key"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "request-clone"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "request-downstream"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "request-headers"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
[local_server.backends]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "request-limits"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "request-upstream"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "response-headers"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "response-json"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "response-redirect"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "response"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "secret-store"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]
[local_server.secret_stores]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "status"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "streaming-close"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "streaming-error"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/tee/fastly.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "tee"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"

[local_server]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "timers"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ name = "urlsearchparams"
service_id = ""

[scripts]
build = "node ../../../../js-compute-runtime-cli.js"
build = "node ../../../../js-compute-runtime-cli.js --enable-weval"
3 changes: 2 additions & 1 deletion js-compute-runtime-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { addSdkMetadataField } from "./src/addSdkMetadataField.js";

const {
enableExperimentalHighResolutionTimeMethods,
enableWeval,
wasmEngine,
input,
component,
Expand All @@ -27,7 +28,7 @@ if (version) {
// it could be that the user is using an older version of js-compute-runtime
// and a newer version does not support the platform they are using.
const {compileApplicationToWasm} = await import('./src/compileApplicationToWasm.js')
await compileApplicationToWasm(input, output, wasmEngine, enableExperimentalHighResolutionTimeMethods);
await compileApplicationToWasm(input, output, wasmEngine, enableExperimentalHighResolutionTimeMethods, enableWeval);
if (component) {
const {compileComponent} = await import('./src/component.js');
await compileComponent(output);
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"test": "npm run test:types && npm run test:cli",
"test:cli": "brittle --bail integration-tests/cli/**.test.js",
"test:types": "tsd",
"build": "make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/*.wasm runtime/js-compute-runtime/fastly.wit .",
"build:debug": "DEBUG=true make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/*.wasm runtime/js-compute-runtime/fastly.wit .",
"build": "make -j8 -C runtime/js-compute-runtime && make -j8 -C runtime/js-compute-runtime VARIANT=-weval && cp runtime/js-compute-runtime/*.wasm runtime/js-compute-runtime/fastly.wit .",
"build:debug": "DEBUG=true make -j8 -C runtime/js-compute-runtime && make -j8 -C runtime/js-compute-runtime VARIANT=-weval && cp runtime/js-compute-runtime/*.wasm runtime/js-compute-runtime/fastly.wit .",
"check-changelog": "cae-release-notes-format-checker CHANGELOG.md"
},
"devDependencies": {
Expand All @@ -47,6 +47,7 @@
"dependencies": {
"@bytecodealliance/jco": "^0.7.0",
"@bytecodealliance/wizer": "^3.0.1",
"@cfallin/weval": "^0.1.3",
"acorn": "^8.8.2",
"acorn-walk": "^8.2.0",
"esbuild": "^0.17.18",
Expand Down
Loading
Loading