From 503fd640f5056c3c1f4b076f309cbfa15e6ae27d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 02:27:44 +0000 Subject: [PATCH] Implement bytecode-only runtime optimization for QuickJS This commit introduces a mechanism to significantly reduce the QuickJS runtime binary size by safely stripping the parser and compiler when they are not needed. Key changes: - Modified `qjsc.c` to detect "bytecode-only" mode when eval, regexp, JSON parsing, and the module loader are all disabled via feature flags. - Gated the parser and compiler entry points in `quickjs.c` and `quickjs-libc.c` with `#ifndef JS_RUNTIME_BYTECODE_ONLY`. - Implemented minimal initialization functions and stubbed features (like the `Function` constructor) to throw a `TypeError` if invoked in a bytecode-only runtime. - Added declarations for minimal initializers in `quickjs.h` and `quickjs-libc.h`. This optimization results in a ~42% reduction in stripped binary size (from ~1022KB to ~588KB for a simple "hello world" example) while maintaining full functionality for pre-compiled bytecode. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>