Repository navigation
ariglx-web: WebAssembly guests in the page (G2, third part) - #1245
Merged
Merged
Conversation
A document's wasm: block now runs in ariglx-web as it does in the native ariglx, on the browser's own WebAssembly. - src/arigl/CMakeLists.txt: the browser's ariglx compiles the engine in, cvc_ariadne_wasm_host(ariglx ASYNC_LOAD). A new target, ariglx_wasm_guests (built by name, not by the package), transforms the hosts' test guest and copies src/arigl/web/test/wasm's documents beside it, for the browser smoke. - doc_fetch.cpp: the page's fetcher follows a wasm: block's module (the module alone, or the map's module:; not a cvcpkg: package), so the guest comes with the document. - browser_runtime.cpp: a guest the page won't compile on its own thread is compiled asynchronously. Chrome refuses new WebAssembly.Module for a module over 8 MB there with a RangeError, and new WebAssembly.Instance for one as large even when it was compiled asynchronously (headless Chrome 157: 7.9 MiB passes both, 8.1 MiB fails both). On that refusal the backend awaits WebAssembly.compile, then WebAssembly.instantiate, through EM_ASYNC_JS, and the document's load waits. A small guest never pauses the page. Only a host linked with Asyncify can wait (cvc_ariadne_wasm_host's new ASYNC_LOAD); without it the load fails, saying why. - arigl_web_smoke.mjs --wasmdocs: guest.ari (the guest fetched with the document, its ari_init, calls, a yield over two frames, spin's 24 million gas in 376 slices, a trap caught as a WasmError) and big.ari (the guest with a 9 MiB custom section, compiled and instantiated asynchronously). Each reports through a python: block's print to stderr: the page keeps stderr, and the DSL's print writes to stdout. - ci.yml's ariglx-web job builds ariglx_wasm_guests in the recipe's tree and passes --wasmdocs, on wasm and wasm-mt; src/ariadne_wasm joins both legs' paths. - Docs: ARIADNE.md (the wasm: block in the browser) and the roadmap (section 8.5's as-built, the G2 row). JSPI against Asyncify is what is left of G2.
transfix
enabled auto-merge (squash)
November 15, 2026 05:43
This was referenced Nov 15, 2026
transfix
added a commit
that referenced
this pull request
Nov 15, 2026
transfix
added a commit
that referenced
this pull request
Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
G2's third part (ARIADNE_SCRIPTING_HOSTS.md §8.5, §10): a document's
wasm:block now runs inariglx-webas it does in the nativeariglx, on the browser's own WebAssembly. #1197 built the browser backend and #1206 the gas pass; this compiles them into the page and checks them in headless Chrome. What G2 has left is JSPI measured against Asyncify.What it adds
ariglx.cvc_ariadne_wasm_host(ariglx ASYNC_LOAD)in the Emscripten branch ofsrc/arigl/CMakeLists.txt.ariglxalready makes the engine and registers it after Python (lend_python), so nothing inmain.cppchanges.doc_fetch.cpp,document_references) follows awasm:block's module, as it followsimport:andload:: the module alone or the map'smodule:, top level only, and not acvcpkg:package. It's data, so it isn't parsed for more names.AriadneDocFetch.ListsTheFilesADocumentNamescovers it.new WebAssembly.Modulefor a module over 8 MB with aRangeError. It refusesnew WebAssembly.Instancefor one as large too, even when the module was compiled asynchronously. I probed headless Chrome 157: 7.9 MiB passes both, 8.1 MiB fails both.browser_runtime.cppstill compiles synchronously first. On thatRangeErrorit awaitsWebAssembly.compile, thenWebAssembly.instantiatefor each instance, throughEM_ASYNC_JS, and the document's load waits while the host's own Asyncify unwinds its stack.ASYNC_LOAD(CVC_ARIADNE_WASM_ASYNC_LOAD). Without it, such a guest fails to load and the error says why.ariadne_wasm_browser_teststays as it was.ariglx_wasm_guests(built by name, not by the package) transforms the hosts' test guest (guest.wat: metered, then Asyncify) into<bin>/ariglx-wasm-guests, besidesrc/arigl/web/test/wasm's documents.arigl_web_smoke.mjs --wasmdocs DIR), two documents:guest.ari: the guest fetched with the document, itsari_initat load, a call frominit:, then on the first tickecho,nap(two yields, so the guest unwinds and later frames rewind it), a trap caught as aWasmError, andspin(24 million gas, 376 slices over several frames).big.ari:big.wasm, which the smoke serves as the guest with a 9 MiB custom section after it, compiled and instantiated asynchronously.window.ariadneWeb.log, and the DSL'sprintwrites to stdout, so each document reports through a smallpython:block. Both engines then run in one document, asariglxregisters them.ariglx-webjob buildsariglx_wasm_guestsin the recipe's tree after the recipe's build and passes--wasmdocs, on wasm and wasm-mt.src/ariadne_wasmjoins both legs' paths.wasm:block in the browser) and the roadmap (§8.5's as-built, the §1 table, the G2 row).How it was tested (Windows, sandipaws)
arigl_web_smoke.mjs --pydocs src/arigl/web/test/python --wasmdocs <bin>/ariglx-wasm-guestsin headless Chrome 157: all 14 cases passed. That includes the two new ones:ariglx-web: wasm booted yes, init early, echo 1 a, nap 7, boom trapped, spin done, running 4.5 s after navigation;ariglx-web: wasm big guest booted yes, echo 2 b, get-x big, at 6.4 s.ariadne_doc_fetch_test: 9/9, including the newwasm:cases.arixwith wasmtime and print the same two lines.Not covered here
host.load) pauses the page under Python, which §5.3 otherwise avoids. The default link instruments those frames, so it's sound there.ASYNCIFY_REMOVE(fallback 1) would break it. The roadmap says so.