Implement mqjsc compiler for standalone MicroQuickJS executables#1
Implement mqjsc compiler for standalone MicroQuickJS executables#1yumin-chen wants to merge 4 commits intomainfrom
Conversation
- Refactor mqjs.c to extract common runtime builtins into mqjs_runtime.c/h. - Develop mqjsc.c tool to compile JS source to standalone C binaries. - Use fork()/execvp() for safer C compiler invocation. - Update Makefile with mqjsc build rules and verification tests. - Ensure consistent scriptArgs behavior between mqjs and mqjsc. 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.c to extract common runtime builtins into mqjs_runtime.c/h. - Develop mqjsc.c tool to compile JS source to standalone C binaries using fork()/execvp(). - Update Makefile with mqjsc build rules and verification tests. - Ensure consistent scriptArgs behavior and correct error reporting in REPL. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
|
Use static const char main_c_template instead of |
I've replaced the line-by-line |
- Replace line-by-line fprintf with a static const char template for generated C code. - Add necessary headers to the generated code. - verified functionality with existing tests. 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 instead |
I've merged |
- Merge mqjs_runtime.c back into mqjs.c using CONFIG_REPL macro. - Add examples/ directory with hello.js, fib.js, timers.js, and args.js. - Add comprehensive test suite in tests/test_mqjsc.sh. - Update README.md with compiler documentation and usage examples. - Update Makefile to integrate new tests and support shared mqjs.c source. 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 |
The
mqjsccompiler allows users to package MicroQuickJS scripts into standalone executable binaries. It works by compiling the JavaScript source into bytecode and then generating a C wrapper that embeds this bytecode and links against the MicroQuickJS runtime.Key changes:
mqjs_runtime.candmqjs_runtime.hto hold core JS builtins likeprint,gc, andsetTimeout.mqjsc.c, which handles bytecode generation, C code generation, and binary compilation viagcc.system()withfork()/execvp()to prevent command injection.Makefileto support the new compiler and refactored runtime.make testthat verifiesmqjscby compiling and running a test script.PR created automatically by Jules for task 18036427833704579629 started by @yumin-chen