Package MicroQuickJS as a WASI 0.2 Component#7
Conversation
This commit introduces the necessary infrastructure to package MicroQuickJS as a self-contained WASI 0.2 component. Key changes: - Created 'microquickjs.wit' defining the 'engine' interface. - Implemented 'glue.c' to bridge the WIT interface with MicroQuickJS, including singleton context management and GC rooting for exported values. - Added 'Makefile.wasi' for the component build pipeline (supporting Path A). - Patched 'mquickjs_build.c' to increase 'ATOM_ALIGN' to 256. - Implemented WASI compatibility stubs in 'glue.c' returning 'JS_UNDEFINED'. - Ensured ABI safety in 'glue.c' by avoiding NULL returns for WIT strings. The implementation preserves existing native build targets and uses a static 4 MiB arena for predictable memory footprint. 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. |
This commit introduces the necessary infrastructure to package MicroQuickJS as a self-contained WASI 0.2 component. Key changes: - Created 'microquickjs.wit' defining the 'engine' interface. - Implemented 'glue.c' to bridge the WIT interface with MicroQuickJS, including singleton context management and GC rooting for exported values. - Added 'Makefile.wasi' for the component build pipeline (supporting Path A). - Patched 'mquickjs_build.c' to increase 'ATOM_ALIGN' to 256. - Implemented WASI compatibility stubs in 'glue.c' returning 'JS_UNDEFINED'. - Ensured ABI safety in 'glue.c' by avoiding NULL returns for WIT strings. The implementation preserves existing native build targets and uses a static 4 MiB arena for predictable memory footprint. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
This commit introduces the necessary infrastructure to package MicroQuickJS as a self-contained WASI 0.2 component. Key changes: - Created 'microquickjs.wit' defining the 'engine' interface. - Implemented 'glue.c' to bridge the WIT interface with MicroQuickJS, including singleton context management and GC rooting for exported values. - Added 'Makefile.wasi' for the component build pipeline. - Patched 'mquickjs_build.c' to increase 'ATOM_ALIGN' to 256. - Implemented WASI compatibility stubs in 'glue.c' returning 'JS_UNDEFINED'. - Ensured ABI safety in 'glue.c' by avoiding NULL returns for WIT strings. The implementation preserves existing native build targets and uses a static 4 MiB arena for predictable memory footprint. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
I have verified that the changes are backwards compatible. The original Makefile remains unchanged and successfully builds the native 'mqjs' and 'example' targets, and all native tests pass. The WASI component build is isolated in the new Makefile.wasi. |
…ckwards compatibility - WIT interface defined in 'microquickjs.wit'. - C glue layer in 'glue.c' with singleton context and GC rooting. - Dedicated 'Makefile.wasi' for component build. - Ensured backwards compatibility: native targets build and pass tests. - Addressed PR feedback: - WASI stubs return 'JS_UNDEFINED'. - String conversion avoids NULL returns for WIT strings. - Increased ATOM_ALIGN for larger stdlib support. - Cleaned up build artifacts. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
This commit addresses the final set of requirements and review comments: - Integrated 'make test' and 'make microbench' into 'Makefile.wasi' using a wasm32-wasip2 CLI build. - Provided 'readline_tty_wasi.c' to enable non-interactive WASI CLI execution. - Updated 'mquickjs_build.c' to produce non-static, ABI-compatible headers for WASM. - Documented WASI build and test instructions in 'README.md'. - Ensured full backwards compatibility with the existing native build system. - All code changes are production-ready and cleaned of build artifacts. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
Implemented the MicroQuickJS WASI 0.2 component.
Includes:
microquickjs.wit: WIT interface definition for the JS engine.glue.c: C implementation of the WIT interface, providing a persistent singleton JS context over a 4 MiB static arena and managing GC roots for JS values exposed to the host.Makefile.wasi: A dedicated build system for cross-compiling to wasm32-wasi and composing the final component usingwit-bindgenandwasm-tools.ATOM_ALIGNinmquickjs_build.cto prevent property overflows during stdlib generation.The component supports
eval, JS value construction (int32, float64, bool, string, object, array), property manipulation, and function calls across the component boundary. It usessetjmp/longjmplowered via WebAssembly Exception Handling (SJLJ) for error recovery.PR created automatically by Jules for task 272671185353916062 started by @yumin-chen