The founder of QEMU and FFmpeg has published the Micro QuickJS JavaScript engine.

French mathematician Fabrice Bellard, who founded the QEMU, FFmpeg, BPG, QuickJS, TinyGL, and TinyCC projects, has published a new JavaScript engine for embedded systems—Micro QuickJS. It can compile and execute JavaScript programs while consuming only 10 KB of RAM. Together with the C library, the engine occupies approximately 100 KB of memory. It can compile JavaScript to bytecode and run the bytecode separately. The project's code is written in C and distributed under the MIT license.

The engine supports a subset of the JavaScript language that is close to the ECMAScript 5 (ES2019) specification, but imposes stricter code requirements and prohibits the use of certain inefficient or error-prone JavaScript constructs. For example, global variables must be declared using the "var" keyword, the use of "with" is prohibited, arrays cannot be empty, initialization is not possible with declarations of the form "new Number(1)", and local variables cannot be accessed from eval.

Micro QuickJS's performance is close to that of the QuickJS engine, developed by Fabrice since 2019. Micro QuickJS uses some of the same code as the QuickJS engine, but its architecture is significantly different and designed for minimal memory consumption. For example, Micro QuickJS uses a tracing garbage collector, while QuickJS uses reference counting. The garbage collector's overhead is only a few bits per allocated memory block. Memory allocation uses its own allocator, independent of the malloc() library function.

Other differences from QuickJS: does not use a stack virtual machine; a different internal representation of objects; storing strings in UTF-8 encoding; generating the standard library during compilation and storing it in persistent memory with the creation of only a few objects in RAM; a parser similar to QuickJS, but not using recursion; combining bytecode generation and optimization in a single pass (QuickJS has several passes for optimization).

Source: opennet.ru

Add a comment