Skip to content

WASM runtime ​

The wasm package implements the Wasmi runtime and guest helper APIs. The native and browser examples mount its executable at /binaries/wasm. Sources: executables/wasm/Cargo.toml and executables/wasm/src/host/main.rs.

Command syntax ​

text
/binaries/wasm [--install] [--stack-size <bytes>] [--instruction-limit <fuel>] <path>

The command runs in Xila's terminal. <path> must identify a regular guest file in the VFS; the loader reads the supplied path directly and does not perform Current_directory resolution. The guest receives its module path as its argument and the task environment as its environment.

Argument/optionDefaultBehavior
<path>RequiredGuest module file path. Use an absolute VFS path.
--installOffSelects __install: () -> () instead of _start: () -> (). A missing or incorrectly typed export fails.
--stack-size4096Parsed as a stack size, but currently not applied by the runtime.
--instruction-limit100,000Nonzero fuel quantum used by resumable execution. Fuel is replenished after yielding; this is not a total instruction limit.

Cargo features ​

FeaturePurpose
hostWasmi interpreter and Xila executable integration; includes browser-hosted Xila.
guestGuest helpers without the interpreter when default features are disabled.
graphicsGenerated graphics wrappers and supported host imports.
c_bindingsGuest C wrappers/header generation; enables guest/graphics dependencies.
memory_3232-bit guest-word translation configuration; default.
memory_64Alternate 64-bit guest-word translation configuration. Calculator remains a wasm32 guest.
default_guestguest,graphics,c_bindings,memory_32; emits xila_graphics.h in the build output directory.

Default features are host,memory_32. Guest-only consumers must disable defaults. Core's xila package has neither a host nor a wasm feature; these runtime features belong to the wasm package.

Results and errors ​

  • WASI proc_exit(0) succeeds; a nonzero exit code becomes a runtime error.
  • Argument, file-kind, compilation, instantiation, missing-export, and execution failures are reported on stderr and return a nonzero executable result.
  • Standard streams are descriptors 0/1/2 in the per-execution WASI context. The root directory is preopened if available.
  • Graphics status and capability errors are defined in the graphics reference.

Execution limits ​

CapabilityCurrent constraint
SchedulingFuel exhaustion and sched_yield yield cooperatively to the executor.
poll_oneoffUp to 64 realtime/startup-clock subscriptions with relative or absolute deadlines. File-descriptor polling and unsupported clocks return errors.
Startup clockUses Xila's time manager and driver, not a separate hardware monotonic source.
WebAssembly start sectionsSuspension is unsupported. WASI command guests should use exported _start.
WASI/graphics compatibilityPartial WASI coverage and a supported graphics subset, not full compatibility.
Graphics ABIGuest and host must match the LVGL revision/configuration.

Browser capabilities ​

AreaBrowser example behavior
Host targetXila builds for wasm32-unknown-unknown; application guests build for wasm32-wasip1.
Storage APIsRequires OPFS, FileSystemFileHandle.createWritable, and Web Locks on localhost/HTTPS.
Diskxila_drive.img, 16 MiB MBR/LittleFS image, local to the origin.
Disk ownershipOne Xila tab can hold the disk's lifetime Web Lock.
SavesAt boot, every second when dirty, and on normal shutdown; synchronous flushes update the memory cache.
Memory16 MiB disk cache plus one temporary 16 MiB snapshot and browser buffering during saves. Guest/interpreter and embedded application bytes add further costs.
Fresh accountadministrator with an empty password; created only for a fresh disk. Existing accounts are restored.
Bundled guestCalculator copied to /binaries/calculator and installed at startup; requires its release artifact before browser compilation.
Guest uploadNo general upload mechanism. Other guests must already be present in the VFS.
NetworkingNo Xila network manager; HTTP uses Fetch under CORS/browser restrictions and does not expose raw sockets.

Browser-managed storage can be evicted or lost; abrupt termination can lose changes since the last completed save. See Browser storage for the durability model.