Implement mqjsc compiler for standalone C binaries#5
Implement mqjsc compiler for standalone C binaries#5yumin-chen wants to merge 3 commits intomainfrom
Conversation
- Refactor common runtime functions (js_print, timers, file loading) into mqjs_runtime.c/h. - Create mqjsc.c: a compiler that translates JS to bytecode and embeds it in a C wrapper. - Update Makefile to build a static library libmquickjs.a for shared engine and runtime code. - Update mqjs.c and example.c to use the shared mqjs_runtime. - Add test case for mqjsc in the Makefile to verify standalone binary generation. - Ensure generated binaries handle scriptArgs and clean up memory properly. 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. |
- Refactor mqjs_runtime for shared engine/runtime code. - Implement mqjsc compiler with main_c_template for binary generation. - Update build system to produce libmquickjs.a static library. - Add standalone binary verification to the test suite. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
|
Instead of separating mqjs_runtime.c from mqjs.c source, use macros on a single shared mqjs.c source. |
I have updated the implementation to merge the runtime logic back into mqjs.c. I'm now using the MQJS_RUNTIME_ONLY macro to isolate the shared runtime functions from the REPL and tool-specific code, as requested. The Makefile has been updated to build mqjs_runtime.o from mqjs.c with this macro. |
- Consolodate shared runtime functions (print, timers, file loading) into mqjs.c. - Use MQJS_RUNTIME_ONLY macro to isolate the runtime for standalone binaries. - Implement mqjsc compiler using C source templates (main_c_template). - Update Makefile to build libmquickjs.a and mqjs_runtime.o from mqjs.c. - Refactor example.c to use the shared runtime. - Add automated verification for mqjsc to the test suite. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
|
Design capacity-based link time optimisation: Instead of always bundling the entire mqjs_runtime, the mqjsc can bundle only the capacity needed by the compiled bytecode and bundle a partial runtime along with the compiled bytecode |
Implemented a standalone JavaScript compiler
mqjscfor the MicroQuickJS engine. The compiler works by parsing JavaScript into bytecode, generating a C source file that embeds this bytecode, and invoking the system's C compiler to produce a standalone executable linked against the MicroQuickJS runtime and library.Key changes:
mqjs_runtime.candmqjs_runtime.hto house shared built-in functions (e.g.,print,setTimeout) and utility functions used by both the REPL and compiled binaries.libmquickjs.ain theMakefileto simplify linking the engine and runtime components.mqjsc.cto handle the compilation process, including support for 32-bit bytecode generation on 64-bit hosts.mqjs,example) to leverage the refactored runtime and static library.Makefileto ensuremqjscproduces functional standalone executables.PR created automatically by Jules for task 8631206984580320788 started by @yumin-chen