Skip to content

Commit cd374ec

Browse files
feat: wasm32 browser target — wasm example tour, wasm-serve, benchmark refresh (#154)
## Summary Browser-targeted WebAssembly support, plus the developer ergonomics and example coverage to go with it. - **wasm example as a language tour** — `examples/wasm/hello.osp` expanded from a hello-world into a full wasm-safe walkthrough of the language (pattern matching, functions, string interpolation, etc.), with `.expectedoutput` and the prebuilt `hello.wasm` regenerated to match. - **Make targets** — VSIX targets scoped to `osprey` only, and a new `wasm-serve` dev server target for running the wasm example in the browser. - **Benchmarks** — restored the full 22-case run (including the GC backend) and refreshed the published results/tables. ## Test plan - [ ] `make ci` (lint + test + build) - [ ] Differential example harness passes (`examples/wasm/hello.osp` matches `.expectedoutput` byte-for-byte) - [ ] `make wasm-serve` runs the example in a browser
1 parent b9b9939 commit cd374ec

12 files changed

Lines changed: 1787 additions & 57 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
This file provides guidance for agents when working with code in this repository.
55

6+
⚠️ NEVER ASk THE USER QUESTIONS! USER YOUR JUDGEMENT. ACT AUTONOMOUSLY ⚠️
67
⚠️ **NEVER DUPLICATE CODE** - Edit in place, never create new versions. Use deslop - find-similar before adding code, and deslop-top-offenders after modifying code ⚠️
78
⚠️ DO NOT USE GIT - ESPECIALLY NOT PUTTING YOUR SIGNATURE ON COMMITS ⚠️
89
⚠️ PRACTICE TOKEN ECONOMICS ⚠️

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# --run`) and TypeScript sub-projects (vscode-extension, webcompiler, website).
88
# =============================================================================
99

10-
.PHONY: build test lint fmt clean ci setup run install bench wasm vsix-rebuild-reinstall
10+
.PHONY: build test lint fmt clean ci setup run install bench wasm wasm-serve vsix-rebuild-reinstall
1111

1212
# ---------------------------------------------------------------------------
1313
# OS Detection
@@ -89,6 +89,9 @@ WASM_CFLAGS ?= --target=$(WASM_TARGET) --sysroot=$(WASI_SYSROOT) -O2 -std=c11 -
8989
# containers + JSON + effects. Excludes fiber (pthreads), http/websocket
9090
# (sockets/OpenSSL), system (fork/wait), term (termios) and ffi (dlopen).
9191
WASM_RT_SRC ?= memory_runtime string_runtime string_runtime_list list_runtime map_runtime map_runtime_hamt json_runtime effects_runtime
92+
# `make wasm-serve` static-host dir + port for the in-browser example.
93+
WASM_SERVE_DIR ?= examples/wasm
94+
WASM_SERVE_PORT ?= 8080
9295

9396
# =============================================================================
9497
# Standard Targets
@@ -155,6 +158,19 @@ wasm: build _runtime_wasm
155158
echo "$$out" | grep -Eq '(^| )NOEXP=0 ' || { echo 'FAIL: example missing .expectedoutput'; exit 1; }
156159
@echo "==> wasm ready: built + validated + WASI/browser smoke + golden suite green"
157160

161+
## wasm-serve: Build the wasm target (full `make wasm`), then static-host
162+
## $(WASM_SERVE_DIR) at http://localhost:$(WASM_SERVE_PORT)/ and open it in
163+
## your browser. Long-running dev server — Ctrl-C to stop. Override the port
164+
## with WASM_SERVE_PORT=<n>. (`make wasm` itself stays headless for CI.)
165+
wasm-serve: wasm
166+
@URL="http://localhost:$(WASM_SERVE_PORT)/"; \
167+
command -v python3 >/dev/null 2>&1 || { echo "FAIL: python3 not found (needed for the dev server)"; exit 1; }; \
168+
echo "==> serving $(WASM_SERVE_DIR)/ at $$URL — opening browser (Ctrl-C to stop)"; \
169+
OPENER=$$(command -v open || command -v xdg-open || true); \
170+
if [ -n "$$OPENER" ]; then ( sleep 1; "$$OPENER" "$$URL" >/dev/null 2>&1 || true ) & \
171+
else echo " (no 'open'/'xdg-open' found — browse to $$URL manually)"; fi; \
172+
cd $(WASM_SERVE_DIR) && exec python3 -m http.server $(WASM_SERVE_PORT)
173+
158174
## setup: Post-create dev environment setup (used by devcontainer)
159175
setup:
160176
@echo "==> Setting up development environment..."

benchmarks/results/raw.jsonl

Lines changed: 172 additions & 2 deletions
Large diffs are not rendered by default.

benchmarks/results/results.html

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)