Expand description
Tier-2 reactor ABI for wasm32-unknown-unknown (Cloudflare Workers / V8
isolates). No WASI, no stdio/argv — the module exports functions a JS
host calls over linear memory (docs/design/done/WASM_TIER2_PLAN.md A3):
plg_init (emitted by the generated module) → builds
the Machine, hands it to plg_rt_set_machine
plg_rt_alloc(len) → ptr host writes the query bytes here
plg_rt_run_query(ptr,len,…) → u64 packed (len<<32 | ptr) of a JSON buffer
plg_rt_free(ptr,len) host frees the result (or the query buffer)
JSON formatting and the query path are NOT duplicated here — both go
through crate::core, the single I/O-free core the WASI shell shares.
§Concurrency contract (D3 / WASM.md finding #2)
One in-flight query per isolate. The program Machine is a single
static; a V8 isolate is single-threaded, but one Worker can interleave
async tasks, so the host must not call plg_rt_run_query again before the
prior call returns. This matches typical Worker use (a request maps to a
query) and avoids threading per-request state through the ABI.
Functions§
- plg_
rt_ alloc - Allocate a host-writable buffer in linear memory (query in / result out).
- plg_
rt_ ⚠free - Safety
- plg_
rt_ ⚠run_ query - Run one query (UTF-8 at
qptr..qptr+qlen) and return packed(len << 32) | ptrof a JSON byte buffer the host reads then frees viaplg_rt_free. The packed return assumes wasm32 (the pointer fits in the low 32 bits); wasm64 would need a wider/two-value result (WASM.md finding #7). - plg_
rt_ ⚠set_ machine - Safety