Skip to content

Commit 7ee0002

Browse files
committed
Revert weval removal commit
1 parent 6e6216d commit 7ee0002

File tree

16 files changed

+1452
-71
lines changed

16 files changed

+1452
-71
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ jobs:
102102
build-type:
103103
- 'release'
104104
- 'debug'
105+
- 'weval'
105106
steps:
106107
- uses: actions/checkout@v4
107108
with:
@@ -173,6 +174,7 @@ jobs:
173174
build-type:
174175
- 'release'
175176
- 'debug'
177+
- 'weval'
176178
steps:
177179
- uses: actions/checkout@v4
178180

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ examples/hello-world/guest/package-lock.json
1010
examples/hello-world/guest/hello.component.wasm
1111
/build-debug
1212
/build-release
13+
/build-release-weval
1314
.vscode
1415
/package-lock.json
1516
.idea

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ set(EMBEDDING_DEP "starling-raw.wasm")
2626
# Define output filenames based on build configuration
2727
set(OUTPUT_NAME_RELEASE "starlingmonkey_embedding.wasm")
2828
set(OUTPUT_NAME_DEBUG "starlingmonkey_embedding.debug.wasm")
29+
set(OUTPUT_NAME_WEVAL "starlingmonkey_embedding_weval.wasm")
2930

3031
# Set the appropriate name based on current configuration
3132
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
3233
set(OUTPUT_FILENAME ${OUTPUT_NAME_DEBUG})
34+
elseif(WEVAL)
35+
set(OUTPUT_FILENAME ${OUTPUT_NAME_WEVAL})
36+
set(EMBEDDING_DEP "starling-ics.wevalcache")
3337
else()
3438
set(OUTPUT_FILENAME ${OUTPUT_NAME_RELEASE})
3539
endif()

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ STARLINGMONKEY_DEPS = $(STARLINGMONKEY_SRC)/cmake/* embedding/* $(STARLINGMONKEY
1515
all: release
1616
debug: lib/starlingmonkey_embedding.debug.wasm lib/spidermonkey-embedding-splicer.js
1717
release: lib/starlingmonkey_embedding.wasm lib/spidermonkey-embedding-splicer.js
18+
release-weval: lib/starlingmonkey_ics.wevalcache lib/spidermonkey-embedding-splicer.js
1819

1920
lib/spidermonkey-embedding-splicer.js: target/wasm32-wasip1/release/splicer_component.wasm crates/spidermonkey-embedding-splicer/wit/spidermonkey-embedding-splicer.wit | obj lib
2021
@$(JCO) new target/wasm32-wasip1/release/splicer_component.wasm -o obj/spidermonkey-embedding-splicer.wasm --wasi-reactor
@@ -27,6 +28,13 @@ lib/starlingmonkey_embedding.wasm: $(STARLINGMONKEY_DEPS) | lib
2728
cmake -B build-release -DCMAKE_BUILD_TYPE=Release
2829
make -j16 -C build-release starlingmonkey_embedding
2930

31+
lib/starlingmonkey_embedding_weval.wasm: $(STARLINGMONKEY_DEPS) | lib
32+
cmake -B build-release-weval -DCMAKE_BUILD_TYPE=Release -DUSE_WASM_OPT=OFF -DWEVAL=ON
33+
make -j16 -C build-release-weval starlingmonkey_embedding
34+
35+
lib/starlingmonkey_ics.wevalcache: lib/starlingmonkey_embedding_weval.wasm
36+
@cp build-release-weval/starling-raw.wasm/starling-ics.wevalcache $@
37+
3038

3139
lib/starlingmonkey_embedding.debug.wasm: $(STARLINGMONKEY_DEPS) | lib
3240
cmake -B build-debug -DCMAKE_BUILD_TYPE=RelWithDebInfo

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ Establishing this initial prototype as a singular flexible engine foundation tha
5151

5252
### Weval AOT Compilation
5353

54-
Note: unfortunately Weval AOT Compilation is disabled for the time being, due to incompatibilities with newer versions of the LLVM toolchain used to compile StarlingMonkey. See [this](https://bytecodealliance.zulipchat.com/#narrow/channel/459697-StarlingMonkey/topic/Updating.20Gecko.20version/near/527089464) and the following messages for details.
54+
[Weval][weval] ahead-of-time (AOT) compilation can be enabled to improve runtime performance by pre-compiling JavaScript inline caches.
55+
56+
To enable AOT compilation, set the `enableAot: true` option or use the `--aot` CLI flag.
57+
58+
AOT compilation can also be configured with the following options:
59+
60+
| Option | Type | Example | Description |
61+
|------------------------|-------------------------------------|-----------------|--------------------------------------------------------------------------|
62+
| `aotMinStackSizeBytes` | `number | Number | bigint | BigInt` | `2_007_846_092` | The minimum stack size (via `RUST_MIN_STACK`) to set when running `weval` |
63+
64+
[weval]: https://github.com/bytecodealliance/weval
65+
66+
#### Custom `weval` binary for AOT
67+
68+
To use a custom (pre-downloaded) [`weval`][weval] binary, set the `wevalBin` option to the path to your desired weval binary.
5569

5670
## Platform APIs
5771

@@ -215,6 +229,18 @@ export function componentize(opts: {
215229
* Path to custom ComponentizeJS engine build to use
216230
*/
217231
engine?: string;
232+
/**
233+
* Path to custom weval cache to use
234+
*/
235+
aotCache?: string;
236+
/**
237+
* Enable AoT using weval
238+
*/
239+
enableAot?: boolean;
240+
/**
241+
* Use a pre-existing path to the `weval` binary, if present
242+
*/
243+
wevalBin?: string;
218244
/**
219245
* Use a pre-existing path to the `wizer` binary, if present
220246
*/
@@ -240,7 +266,7 @@ export function componentize(opts: {
240266
*/
241267
enableFeatures?: [];
242268
/**
243-
* Pass environment variables to the spawned Wizer Process
269+
* Pass environment variables to the spawned Wizer or Weval Process
244270
* If set to true, all host environment variables are passed
245271
* To pass only a subset, provide an object with the desired variables
246272
*/
@@ -319,6 +345,14 @@ npm install
319345
npm run build
320346
```
321347

348+
Before being able to use `componentize-js` with AOT support (ex. via `npm link`, from `jco`), you'll need to run:
349+
350+
```console
351+
npm run build:weval
352+
```
353+
354+
This will produce `lib/starlingmonkey_embedding_weval.wasm` and `lib/starlingmonkey_ics.wevalcache`.
355+
322356
To clean up a local installation (i.e. remove the installation of StarlingMonkey):
323357

324358
```console
@@ -333,6 +367,12 @@ To run all tests:
333367
npm run test
334368
```
335369

370+
To run tests with AOT (weval) enabled:
371+
372+
```console
373+
npm run test:weval
374+
```
375+
336376
### Running a specific test
337377

338378
To run a specific test suite, you can pass an argument to [`vitest`][vitest]:

examples/hello-world/guest/componentize.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { resolve } from 'node:path';
33

44
import { componentize } from '@bytecodealliance/componentize-js';
55

6+
// AoT compilation makes use of weval (https://github.com/bytecodealliance/weval)
7+
const enableAot = process.env.ENABLE_AOT == '1';
8+
69
const jsSource = await readFile('hello.js', 'utf8');
710

811
const { component } = await componentize(jsSource, {
912
witPath: resolve('hello.wit'),
13+
enableAot,
1014
});
1115

1216
await writeFile('hello.component.wasm', component);

0 commit comments

Comments
 (0)