Expand description
The gasm ABI v0 host: instantiates a guest and implements the “gasm”,
“gasm:gfx”, “gasm:net” and “gasm:storage” imports, plus the WASI subset in
crate::wasi.
Structs§
- Clipboard
- The “copied only if it fits” convention: copy
srctodstifsrc.len() <= cap; returns the full length either way. gasm:clipboard’s state. The runner owns the system clipboard: it setspastedfor the frame that carries the player’s paste key press (cleared after it) and takescopiedafter each frame. Headless runs never paste. - Fnv
- FNV-1a 32-bit; mirrored in runners/web/gasm-host.js for cross-runner checks.
- Game
- A running guest.
gasm_frameguests are called once per frame;gasm_runguests run in one suspended call (stack switching) that eachGame::frameresumes until its nextyield_frame. - Gamepad
- Host
- Load
Options - How to load a guest.
- Memory
Limit - The guest’s memory cap (
--memory-limit): growing past it traps, with a message that says so (the JS runner checks after each guest call, with the same message). - Pointer
- Profile
--profile <out.json>: wasmtime’sGuestProfilersampling the main thread’s guest stacks every millisecond (an extra epoch ticker; call timeouts are off meanwhile), written in the Firefox Profiler’s format when the game ends. Only guest frames are recorded, and wasmtime checks the epoch only in guest code: the milliseconds a call into the runner (gasm:gl, ANGLE, …) took are samples of the guest stack it returns to, so they count for the function that called it. The time inside those calls is measured too (the call hook) and printed with the file.- RawInput
- Raw input for one frame, set by the runner before each
gasm_frame.Nonefields mean the runner has no such device (the import returns -1). - Virtual
Clock - Headless virtual time: derived from the frame number, monotonic when the
guest changes its frame rate. Same arithmetic in gasm-host.js
(
VirtualClock) and thegasm::nativestub.
Enums§
- Stop
- Why a guest call ended.
Constants§
- ABI_
VERSION - CLIPBOARD_
MAX - The largest text gasm:clipboard passes either way
- DEFAULT_
MEMORY_ LIMIT - The default memory cap: far above what the games here use (Godot’s 3D example: 39 MiB).
- GAMEPAD_
AXES - GAMEPAD_
BUTTONS - GAMEPAD_
BYTES - KEY_
STATE_ BYTES - POINTER_
BYTES - TITLE_
MAX_ BYTES - Longest title
set_titlekeeps, in UTF-8 bytes.
Functions§
- clean_
title - A guest’s
set_titletext as runners show it: control characters (Unicode Cc) and bidi controls (U+202A–U+202E, U+2066–U+2069) removed, then cut to 256 bytes at a character boundary. None: empty, the runner’s default. Same rules in runners/web/lib/host.jscleanTitle. - custom_
section - The payload of custom section
namein a wasm binary (None for a .cwasm or a malformed module: the loader reports those). - engine
- The process-wide engine: the same configuration for compiling, precompiling
and loading (
.cwasmfiles must match it). Epoch interruption lets a guest call that never returns be stopped (LoadOptions::call_timeout). Calls can be sync (gasm_frameguests) or async (gasm_runguests: stack switching). - frame_
position - Map a drawable position into the last video_present frame (letterboxed as the
runners display it,
present::letterbox). Same arithmetic in runners/web/lib/input.js. - imports_
module - Whether a module imports anything from
module(e.g. “gasm:gl”), read before loading it. A .cwasm is checked only withallow_precompiled(it is native code). - memory_
limit_ message - The trap message when a guest needs more memory than allowed (also the JS runner’s).
- precompile
- Ahead-of-time compile a guest to native code for this host (no JIT needed at load).
- provided
- What this runner provides (
gasm.has), without a game (gasm-run --info). - static_
title - The guest’s built-in title (custom section
gasm.title, UTF-8), cleaned like set_title: the default title before (or without) set_title.