Adds a parallel build of all three Lumbda implementations to WASM, a
single-page playground at www/playground/, and a verified test suite.
Tiers
- Python: Pyodide (CPython-in-WASM) hosting lumbda.py
- C: Emscripten build of c/ (tree-walker + bytecode VM; jit.c
stubbed, gc.c uses its existing no-Boehm fallback)
- Asm: hand-written asm/lumbda.wat — parallel impl to asm/lumbda.s.
Reader, eval (lambda/define/if/cond/let/and/or/quote/set!),
recursion across mutated top-level env, bump allocator with
memory.grow, 24 primitives. ~1200 lines of raw WAT.
SPA (wasm/app/, deployed to www/playground/)
- CodeMirror 6 editor (Scheme highlighting) on left, output on right
- Radios: 4 demos (Mandelbrot, Fib+Ack, Sieve, self-interp meta-eval)
x 4 tiers (Python | C | Asm | All three)
- All-three mode renders the three tier outputs side by side with
per-tier elapsed timing
Tests (38 verified assertions)
- 20 unit (Node): per-tier module loads, eval smoke
- 8 integration (Node): each demo on c+asm WASM byte-matches the
canonical native Python run
- 10 functional (Playwright headless Chromium): page mounts, every
demo runs on every tier, all-three renders
Makefile
- Root targets: wasm-build, wasm-test, wasm-test-fn, wasm-serve,
wasm-deploy, wasm-clean
- wasm/Makefile orchestrates the three tier builds; deploy copies
dist/ into www/playground/
Asm tier notes
- WAT linear symbol intern + linear env lookup is MOAD-0001 at scale;
documented in the asm/lumbda.wat header and in the SPA footer. The
demos hit ~30 globals so the linear walks are cheap enough.
- Bump allocator never frees (matches asm/lumbda.s heap discipline);
memory.grow expands by 1 MB chunks. Browser tab tears down at unload.
Toolchain (developer prerequisites)
- Emscripten 6.0.0 via emsdk at ~/git/emsdk
- wabt 1.0.36 at ~/git/wabt
- Playwright for functional tests (symlinked from ~/git/agnt)
35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
// wasm/app/runner.js
|
|
// Tier runner — wraps the three loaders, runs a Lisp source on selected
|
|
// tiers, returns {tier, output, error, elapsed} for each.
|
|
|
|
import { createPythonTier } from "./python/lumbda-py.js";
|
|
import { createCTier } from "./c/lumbda-c.loader.js";
|
|
import { createAsmTier } from "./asm/lumbda-asm.loader.js";
|
|
|
|
const cache = {};
|
|
|
|
async function getTier(name, progress) {
|
|
if (cache[name]) return cache[name];
|
|
progress(`loading ${name} tier…`);
|
|
if (name === "python") cache[name] = await createPythonTier("./python/");
|
|
else if (name === "c") cache[name] = await createCTier({ baseURL: "./c/" });
|
|
else if (name === "asm") cache[name] = await createAsmTier({ baseURL: "./asm/" });
|
|
else throw new Error(`unknown tier: ${name}`);
|
|
return cache[name];
|
|
}
|
|
|
|
export async function runOnTiers(tiers, src, progress) {
|
|
const results = [];
|
|
for (const t of tiers) {
|
|
const start = performance.now();
|
|
try {
|
|
const tier = await getTier(t, progress);
|
|
progress(`running on ${t}…`);
|
|
const output = await tier.evalLisp(src);
|
|
results.push({ tier: t, output, error: null, elapsed: performance.now() - start });
|
|
} catch (e) {
|
|
results.push({ tier: t, output: "", error: e.message || String(e), elapsed: performance.now() - start });
|
|
}
|
|
}
|
|
return results;
|
|
}
|