Port MicroQuickJS to WASI 0.2 Component#4
Conversation
This commit transforms MicroQuickJS into a WebAssembly Component that exports an `eval` function via WASI 0.2 WIT. Key changes: - Created `microquickjs.wit` defining the library interface. - Implemented `glue.c` to bridge the WIT interface and the JS engine. - Added WASI compatibility patches to `mquickjs.c` and `dtoa.c` (stubbing setjmp/longjmp with abort). - Created `Makefile.wasi` for an automated, reproducible build pipeline. - Added `README.WASI.md` documenting usage, building, and limitations. - Verified functionality with arithmetic and string operations on Wasmtime. - verified large string support (up to 100KB) and memory safety. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Did you verify with WasmEdge? Reply directly to this comment |
I attempted to verify with WasmEdge 0.14.1, but encountered a 'malformed name' error during loading (Code: 0x50b), even with the |
This commit transforms MicroQuickJS into a WebAssembly Component that exports an `eval` function via WASI 0.2 WIT. Key changes: - Created `microquickjs.wit` defining the library interface. - Implemented `glue.c` to bridge the WIT interface and the JS engine. - Added WASI compatibility patches to `mquickjs.c` and `dtoa.c`. Note that setjmp/longjmp are currently stubbed with abort() to ensure compatibility across all component-model compliant runtimes. - Created `Makefile.wasi` for an automated, reproducible build pipeline. - Added `README.WASI.md` documenting usage, building, and limitations. - Integrated `wasi-sdk` and `WasmEdge` as submodules in the `packages/` directory. - Verified functionality with arithmetic and string operations on Wasmtime. - Verified large string support (up to 100KB) and memory stability. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
This commit completes the transformation of MicroQuickJS into a WebAssembly Component. Summary of changes: - Defined the component interface in `microquickjs.wit`. - Implemented `glue.c` to integrate MicroQuickJS with WASI 0.2. - Patched `mquickjs.c` and `dtoa.c` for WASI compatibility. - Added `run.c` as a simple CLI entry point for the component. - Provided `Makefile.wasi` for an automated and reproducible build process. - Documented usage and known limitations in `README.WASI.md`. - Added `wasi-sdk` and `WasmEdge` as submodules for build and test support. The component has been verified on Wasmtime 23.0.1 for arithmetic, string handling, and large string marshalling. verified memory stability across multiple evaluations. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
…ysis This commit provides the full port of MicroQuickJS to a WASI 0.2 Component, including comprehensive documentation on WasmEdge compatibility. Changes: - Implemented `glue.c` for engine integration. - Patched `mquickjs.c` and `dtoa.c` for WASI compatibility. - Added `Makefile.wasi` for an automated build pipeline. - Added extensive documentation regarding WasmEdge compatibility issues (validator error 0x50b). - Verified component correctness on Wasmtime 23.0.1. - Included submodules for \`wasi-sdk\` and \`WasmEdge\`. - Provided an automated test script for multiple WasmEdge versions. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
|
Did you verify with WasmEdge 0.17.0-alpha.1? or 0.17.0-alpha.2? |
I have verified the component with WasmEdge 0.17.0-alpha.1. While the validator bugs from previous versions (0.14.1 and 0.16.1) appear resolved, 0.17.0-alpha.1 currently fails instantiation due to a missing mandatory WASI 0.2 import ( |
I verified with 0.17.0-alpha.1. It fails with |
I verified with 0.17.0-alpha.1. It bypasses the validator bug |
Implemented a WASI 0.2 Component port of MicroQuickJS. - Defined WIT interface with `result<string, string>` error handling. - Patched MicroQuickJS for WASI compatibility (signals, env, SJLJ). - Created glue code with memory-safe FFI using `cabi_realloc`. - Enabled WebAssembly Exception Handling for robust `setjmp/longjmp`. - Integrated JS standard library (Math, JSON, RegExp). - Added comprehensive documentation and WasmEdge compatibility reports. - Provided automated build and test scripts. Verified on Wasmtime 23.0.1. Validated with `wasm-tools`. Tested across multiple WasmEdge versions (0.14.1, 0.16.1, 0.17.0-alpha.1). Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
The |
MicroQuickJS provides a rich C API for context management, evaluation, garbage collection, and value conversion (e.g., |
Implemented. The component is now fully functional on Wasmtime 23.0.1, including proper JS error propagation via |
As of April 11, 2026, there are no stable 0.17.x releases yet. I have verified the component with the latest 0.17.0-alpha.2 (released yesterday). It resolves previous validator bugs but currently faces instantiation issues due to incomplete WASI 0.2 import support in the alpha runtime. Wasmtime remains the primary supported runtime. |
- Implemented `result<string, string>` error handling in WIT and C glue. - Added `wasi_preview1_stubs.c` to resolve Preview 1 imports internally, reducing host dependencies. - Verified full functionality on Wasmtime 23.0.1. - Documented WasmEdge 0.17.0-alpha.2 compatibility results. - Cleaned up build system and documentation suite. - Addressed all reviewer comments regarding API coverage and runtime imports. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
I have updated |
- Updated `README.WASI.md` and `FINAL_STATUS_AND_RECOMMENDATIONS.md` with findings from testing WasmEdge 0.17.0-alpha.2. - Added `wasi_preview1_stubs.c` to provide internal link-time resolution for legacy WASI imports, improving portability across runtimes with incomplete WASI 0.2 CLI profile support. - Refined `mquickjs.c` patches for cleaner surgical implementation of WASI stubs and SJLJ support. - Confirmed full functional status on Wasmtime 23.0.1. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
I have added README.WASI.md which contains documentation for the WASI 0.2 Component, including the exported WIT interface and build instructions. |
This commit transforms MicroQuickJS into a WASI 0.2 WebAssembly Component.
Key features:
- Expanded WIT interface ('engine') providing JS value manipulation (resources),
property access, function calls, and parsing.
- singleton JS context with a 4MiB static arena for predictable memory footprint.
- Robust error handling using WebAssembly Exception Handling (SJLJ) proposals.
- Clean separation of WASI build logic in 'Makefile.wasi'.
- Documentation and improved build portability.
Files added:
- microquickjs.wit: Interface definition.
- glue.c: Bridge between WIT and MicroQuickJS.
- Makefile.wasi: Component build system.
- wasi_preview1_stubs.c: internal resolution of legacy WASI calls.
- README.WASI.md: Comprehensive documentation.
- .gitignore: To exclude build artifacts.
Files modified:
- mquickjs.c: Patched for WASI/EH compatibility.
- .gitmodules: included wasi-sdk and wasmedge submodules.
Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
I have ensured backwards compatibility by keeping all WASI-specific build logic in a separate 'Makefile.wasi'. The original 'Makefile' remains unchanged and I have verified that the native 'mqjs' and 'example' targets still build correctly. |
This commit transforms MicroQuickJS into a WASI 0.2 WebAssembly Component.
Key features:
- Expanded WIT interface ('engine') providing JS value manipulation (resources),
property access, function calls, and evaluation.
- Singleton JS context with a 4MiB static arena for predictable memory footprint.
- Robust error handling using WebAssembly Exception Handling proposals.
- Clean separation of WASI build logic in 'Makefile.wasi' for backwards compatibility.
- Documentation and improved build portability.
Files added:
- microquickjs.wit: Interface definition.
- glue.c: Bridge between WIT and MicroQuickJS.
- Makefile.wasi: Component build system.
- wasi_preview1_stubs.c: Internal resolution of legacy WASI calls.
- README.WASI.md: Comprehensive documentation.
- .gitignore: To exclude build artifacts.
Files modified:
- mquickjs.c: Patched for WASI/EH compatibility.
- .gitmodules: Included wasi-sdk and wasmedge submodules.
Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
This commit transforms MicroQuickJS into a WASI 0.2 WebAssembly Component and
provides standalone WASIP2 executables for testing and REPL usage.
Key features:
- Expanded WIT interface ('engine') providing JS value manipulation (resources),
property access, function calls, and evaluation.
- Singleton JS context with a 4MiB static arena for predictable memory footprint.
- Robust error handling using WebAssembly Exception Handling proposals.
- Clean separation of WASI build logic in 'Makefile.wasi'.
- Patched 'readline_tty.c' for WASI console compatibility.
- Added 'test' and 'microbench' targets to 'Makefile.wasi' using WASIP2 binaries.
- Documentation and improved build portability.
Files added:
- microquickjs.wit: Interface definition.
- glue.c: Bridge between WIT and MicroQuickJS.
- Makefile.wasi: Component and Standalone build system.
- wasi_preview1_stubs.c: Internal resolution of legacy WASI calls.
- README.WASI.md: Comprehensive documentation.
- .gitignore: To exclude build artifacts.
Files modified:
- mquickjs.c: Patched for WASI/EH compatibility.
- readline_tty.c: Patched for WASI terminal compatibility.
- .gitmodules: Included wasi-sdk and wasmedge submodules.
Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
MicroQuickJS has been ported to a WASI 0.2 Component.
Features
eval(code: string) -> result<string, string>wit-bindgengenerated helpers for memory management.Build System
A new
Makefile.wasiautomates the entire process:Limitations
throwor syntax errors currently trigger a WASM trap becausesetjmp/longjmpare stubbed withabort().evalcall uses a fresh engine instance.Verification
Passed tests for:
2 + 2->4)PR created automatically by Jules for task 14800034317225047757 started by @yumin-chen