Mobile Development 34 min read

hyengine: A Unified Mobile Script Engine with JIT, Optimizations, and GC

hyengine is a lightweight, high‑performance mobile execution engine that unifies WebAssembly, JavaScript, Python and Lua via a compiler and VM, offering JIT compilation, register allocation, inline‑cache optimizations, a custom allocator (hymalloc) and a concurrent three‑color garbage collector (hygc), achieving substantial speed‑ups on macOS and Android.

DaTaobao Tech
DaTaobao Tech
DaTaobao Tech
hyengine: A Unified Mobile Script Engine with JIT, Optimizations, and GC

hyengine is a lightweight, high‑performance execution engine designed for mobile platforms that unifies the execution of multiple script languages such as WebAssembly, JavaScript, Python and Lua. It consists of a compiler (frontend, middle‑end, backend) and a virtual machine (VM) and provides JIT compilation, register allocation, inline‑cache optimizations, a custom memory allocator (hymalloc) and a multi‑threaded three‑color garbage collector (hygc).

The compiler translates wasm bytecode into ARM64 machine code through a simple direct‑translation pass followed by several optimizer passes (code‑block splitting, register allocation based on access frequency, instruction‑fusion and pattern‑matching). These passes reduce code size from 63 to 32 instructions for a Fibonacci benchmark and cut execution time from 1716 ms to 493 ms, approaching LLVM‑generated code.

For JavaScript, hyengine reuses QuickJS but replaces its reference‑counting GC with hygc, a concurrent three‑color mark‑sweep collector that runs in a background thread and limits pause time to <30 ms. The allocator hymalloc organizes memory into regions, pools and items, achieving up to 4× faster allocation than the system malloc on an M1 Mac.

Additional optimizations include a global‑object inline cache to avoid repeated property look‑ups and fast‑path implementations for frequently used built‑ins such as Array.indexOf. Performance measurements on both macOS (x86/arm64) and Android devices show significant speed‑ups for wasm, JavaScript and mixed workloads.

Future work will focus on extending the compiler with a custom bytecode, adding more optimizer passes, implementing hot‑method JIT in the VM and exploring support for additional languages.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaScriptMemory ManagementWebAssemblyGarbage CollectionJIT
DaTaobao Tech
Written by

DaTaobao Tech

Official account of DaTaobao Technology

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.