QEMU, FFmpeg Founder Unveils Micro QuickJS Engine

French mathematician Fabrice Bellard, known for founding projects like QEMU, FFmpeg, BPG, QuickJS, TinyGL, and TinyCC, recently unveiled a new JavaScript engine specifically designed for embedded systems. Named Micro QuickJS, this engine is capable of compiling and executing JavaScript programs using a mere 10 KB of RAM. When combined with the C library, Micro QuickJS takes up around 100 KB of permanent memory. Additionally, it enables the compilation of JavaScript into bytecode for separate execution. The entire project code is written in C and distributed under the MIT license.

Micro QuickJS supports a subset of the JavaScript language based on the ECMAScript 5 (ES2019) specification. However, it enforces stricter code requirements and prohibits the use of certain ineffective or error-inducing JavaScript constructs. For instance, global variables must be declared using the “var” keyword, the use of “with” is forbidden, arrays cannot contain empty spaces, initialization cannot be performed when declaring with “new Number(1)”, and access to local variables from eval is restricted.

The performance of Micro QuickJS is on par with the QuickJS engine developed by Fabrice Bellard in 2019. Although Micro QuickJS utilizes some code from QuickJS, its architecture is fundamentally different and optimized for minimal memory consumption. One notable difference is the use of a tracing garbage collector in Micro QuickJS, whereas QuickJS utilizes reference counting. The overhead of the garbage collector in Micro QuickJS is minimal, requiring only a few bits per allocated memory block. It also features its own memory allocator, distinct from the malloc() library function.

Micro QuickJS also deviates from QuickJS in several aspects, including the absence of a stack in the virtual machine, a different internal object representation, storage of strings in UTF-8 encoding, generation of a standard library during compile time stored in permanent memory with minimal objects in RAM, a parser similar to QuickJS but without recursion, and the integration of bytecode generation and optimization in a single pass (as opposed to QuickJS’s multiple optimization passes).

/Reports, release notes, official announcements.