Skip to content

Port MicroQuickJS to WASI 0.2 Component#6

Open
yumin-chen wants to merge 2 commits into
mainfrom
port-microquickjs-to-wasi-0.2-11092647189104356399
Open

Port MicroQuickJS to WASI 0.2 Component#6
yumin-chen wants to merge 2 commits into
mainfrom
port-microquickjs-to-wasi-0.2-11092647189104356399

Conversation

@yumin-chen

Copy link
Copy Markdown

MicroQuickJS was successfully ported to a WASI 0.2 Component.

The implementation includes:

  1. Toolchain Setup: Automated via Makefile.wasi, using wasi-sdk, wit-bindgen, and wasm-tools.
  2. WIT Interface: Defined in microquickjs.wit, exporting eval: func(code: string) -> string.
  3. Glue Logic: glue.c manages a singleton JSContext and handles string marshaling between the Component Model and QuickJS. glue_stdlib.c provides necessary stubs for the JS standard library in a library context.
  4. WASI Compatibility: Core engine was patched to avoid POSIX-specific behaviors like setjmp/longjmp which are currently problematic in the Component Model pipeline.
  5. Build Improvements: Increased alignment in the header generator to accommodate the standard library size.

Building the component:
make -f Makefile.wasi

Verification:
wasm-tools component wit microquickjs.component.wasm


PR created automatically by Jules for task 11092647189104356399 started by @yumin-chen

This commit transforms MicroQuickJS into a WebAssembly Component Model
component exporting an `eval` function via a WIT interface.

Key changes:
- Added `microquickjs.wit` defining the library interface.
- Implemented `glue.c` and `glue_stdlib.c` to bridge the engine with
  the Component Model using a singleton runtime pattern.
- Patched `mquickjs.c` and `dtoa.c` to stub `setjmp`/`longjmp` for WASI
  compatibility, preventing unresolved 'env' imports.
- Modified `mquickjs_build.c` to increase `ATOM_ALIGN` to 256,
  supporting larger property counts in the generated stdlib.
- Added `Makefile.wasi` for automated WASI component builds.
- Added `README.WASI.md` with build and verification instructions.

The resulting component has been verified using `wasm-tools` to
correctly export the `eval` function and follow the WASI 0.2
specifications.

Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

This commit transforms MicroQuickJS into a WebAssembly Component Model
component exporting an evaluation and value-manipulation interface.

Key features:
- Complete engine interface defined in WIT, including rooted JS value resources.
- Robust error handling using WASI SDK's Exception Handling lowering for setjmp/longjmp.
- Automated, portable build process via Makefile.wasi.
- Singleton runtime pattern over a static 4MiB arena for predictable memory footprint.
- Comprehensive documentation in README.WASI.md.

Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant