KRYONOS
JS Runtime & Core

Engine Specs & ES5 Compliance

Technical specifications for the embedded Duktape JavaScript engine, memory limits, garbage collection, and syntax compliance rules in KryonOS.

Engine Specifications & ECMAScript Compliance

KryonOS utilizes the Duktape 2.7 embedded JavaScript engine, compiled directly into the C++ kernel firmware. It executes bytecode through a virtual stack machine optimized for microcontrollers with constrained RAM.

Official firmware source code and build instructions are hosted on the KryonOS GitHub Repository.


1. ECMAScript Compliance

The runtime is fully compliant with the ECMAScript 5.1 (ES5) specification, with selective ES6 features.

Supported Features

  • Complete ES5 standard library (Array, Object, Function, Math, JSON, Date, RegExp).
  • TypedArrays (Uint8Array, Int8Array, Uint16Array, Int32Array, Float32Array, ArrayBuffer).
  • Promise object for asynchronous control flow.
  • Proxy and Reflect metaprogramming primitives.
  • Strict mode ("use strict").

Unsupported Modern Syntax

Due to strict ROM and RAM footprint constraints on microcontroller targets, ES6+ syntax sugar is not supported:

  • No let or const: Always declare variables using var.
  • No Arrow Functions: Use standard function(args) { ... } syntax.
  • No ES6 Classes: Use prototype-based constructor patterns.
  • No Template Literals: Use string concatenation ("Value: " + val).
  • No Destructuring Assignment: Access object properties directly (var x = obj.x;).
  • No Default Parameters: Initialize defaults inside the function body (val = val || defaultValue;).
  • No Spread / Rest Operators: Use standard loops or arguments.

2. Syntax Comparison Reference


3. Memory Architecture & Garbage Collection

Memory Allocation Budget

  • Usable Heap: Approximately ~90 KB of continuous RAM is allocated per JavaScript execution context when Wi-Fi is inactive.
  • Stack Depth: Virtual call stack depth is limited to 64 frames to prevent hardware stack overflows.
  • Heap Fragmentation: Allocating many temporary short-lived objects inside fast animation loops causes heap fragmentation.

Garbage Collection (GC) Mechanics

KryonOS employs a Mark-and-Sweep Garbage Collector. The OS automatically executes sweep passes when the engine yields to the kernel.

Critical Yielding Rule: If your application runs an infinite or long-running loop (such as a game loop or continuous sensor polling), you must call System.delay(10) inside each iteration. This yields execution to FreeRTOS and triggers garbage collection. Omitting this call will cause heap exhaustion and trigger a kernel panic.

// Standard Game/Service Loop Pattern
var running = true;

while (running) {
  // 1. Process inputs
  var touch = System.getTouch();
  
  // 2. Update logic
  // ...
  
  // 3. Render frame
  // ...
  
  // 4. Yield CPU and trigger garbage collection
  System.delay(10);
}

On this page