Skip to content

Tiny v0.2.4 - Optimization and Robustness

Choose a tag to compare

@confh confh released this 13 Jun 19:43

Tiny v0.2.4 - Optimization and Robustness

This release introduces a suite of advanced compiler optimizations and a significant overhaul of the JIT engine to support mid-function deoptimization and native memory management.

Compiler Optimizations

  • Object Virtualization: Implemented a sophisticated escape analysis pass that identifies non-escaping object literals. These objects are now virtualized into stack slots, completely eliminating heap allocation overhead for temporary data structures.
  • Interpreter Superinstructions: The bytecode optimizer now emits broad superinstructions (e.g., OP_LOCAL_CONST_OP_STORE, OP_ADD_LOCAL_PROPERTIES_STORE) that consolidate common instruction patterns, significantly reducing dispatch overhead in the interpreter.
  • Standard Library Intrinsics: Core methods from math, io, and json are now lowered directly to specialized opcodes, bypassing the standard method dispatch and native call overhead.

JIT Engine Overhaul

  • Mid-Function Deoptimization: Added support for robust deoptimization checkpoints. JIT-compiled functions can now safely bail out to the interpreter at any point (e.g., on type mismatches or side-effect boundaries) while maintaining full local and stack state.
  • Inlined WASM Allocators: JIT-compiled functions now utilize a high-performance bump-pointer allocator directly within WASM linear memory. Allocation is tracked via a bitset to ensure zero-copy interop with the interpreter.
  • Optimized String Joins: Implemented a fully-native WASM fast path for string concatenation and interpolation, reducing context switches to the host for common string operations.
  • Advanced Type Flow Analysis: The JIT compiler now performs a multi-pass type inference on parameters and return values to generate more specialized and efficient WASM code.

Runtime and Performance

  • Fast JSON Provider: Introduced a hand-rolled, reflection-free JSON parser and stringifier. This provider operates directly on TinyValue types, delivering substantial performance gains over standard library implementations.
  • VM Task Pooling: Optimized async task and server performance by implementing a configurable worker pool (VMPool). This provides better resource isolation and prevents excessive memory pressure under high concurrency.
  • Enhanced String Equality: Added a direct WASM-native string comparison loop for JIT-compiled code, further reducing host-call overhead.

Breaking Changes

  • Internal Bytecode Version: Bumped to 23 to accommodate new superinstruction opcodes and JIT deoptimization metadata.
  • Standard Module Dispatch: Standard module calls in JIT code now dispatch through a centralized call_stdlib_wasm import for improved side-effect tracking.