Repository navigation
wasmoon 2.0 - #131
Open
ceifa wants to merge 91 commits into
Open
wasmoon 2.0#131ceifa wants to merge 91 commits into
ceifa wants to merge 91 commits into
Conversation
… api of lua creation
|
is there any reason this hasn't recieved any attention |
|
should def be merged. |
Quality cleanups from review, no behavior change: - collapse awaitInterruptible into settleOrInterrupt - share one settled-value marshaller (Thread.pushReturnValues; marshalResolved/marshalRejected) - centralize the abort/timeout classification in async.limitError - remove the syncDepth field, derivable from stackCanSuspend via one withSuspensionDisabled helper - extract the shared per-yield handling (throwIfLimitReached, handleHostYield) from the two run loops - drop the dead await-hook L parameter and inline the single-use heap-slice wrappers Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012hBeqdFnHzBUQ7zLRVYQxx
Snapshot of the working tree at /home/ceifa/Projects/wasmoon, on top of 55c7d96, pushed as-is for review. Not built or tested as part of this commit.
JSPI is now the only way an :await() suspends; the coroutine yielding engine and the `async` load option are gone. On a platform without JSPI everything else still runs and an :await() raises an error naming the versions that have it. - fix the C stack pointer leak: a run started inside another run's JS callback that outlived it left the idle stack pointer lower for good, and after ~100 of those the instance trapped with "memory access out of bounds" - a Lua function called from JS is always synchronous; state.callAsync(fn, args, options) runs it as a run of its own, and promise next/catch/finally call their Lua reactions through it - a top level coroutine.yield() without an onYield handler gives the event loop a turn every time again - engines: node >= 26; CI runs Node 26 without the JSPI flag or the engine matrix
With `inject`, `async(fn)` returns a function that runs `fn` as a run of its own and hands back a promise of its first result: what `async function` is to JS. A callback wrapped in it can await when a JS API calls it synchronously, which a bare Lua function cannot now that calls from JS are always synchronous. The wrapper is a Lua closure over `fn`, compiled on first use, and the arguments of a call move between Lua stacks without becoming JS values.
- state.async(fn, options) replaces callAsync: it returns the asynchronous counterpart of a Lua function, the mirror of async(fn) in Lua, ready to hand to whatever takes a callback - inject takes the names to define (['Promise', 'async']), so async and Promise no longer come with the null sentinel - asynchronous runs of a function start under the same limits as a doString, the state's instruction budget included, with the function timeout on top - LuaRuntime.canAwait tells whether the platform can await, before loading anything - onAsyncError receives the error of an async(fn) call nothing was waiting on, which is otherwise an unhandled rejection - a function that returns nothing or nil resolves to undefined, as a run does, and the await error names async(fn) and state.async(fn)
better async model
Remove Deno references
utils/create-bindings.js now writes src/bindings.gen.ts and the emcc export list instead of printing blocks to paste, and build:wasm runs it. LuaModule extends the generated class, so each binding is declared once instead of in three hand-kept lists. No change to the bindings, their types or the wasm: the generated declarations match the hand-written ones, and glue.wasm and both glues come out byte for byte the same.
generate the lua bindings from the headers
copy/proxy/opaque/raw replace decorate, defineType and defineClass replace registerTypeExtension and its priorities, and a function is no longer guessed to be a class. LuaLimits (timeout, maxInstructions, signal) is the one shape for state.limits and for a run's options, and applies to every run, including a call of a Lua function and one made from inside another.
declarative marshalling, one limits vocabulary
chai 6.3.0, mocha 12.0.3, oxfmt 0.79.0, oxlint 1.94.0, playwright 1.65.1, rolldown 1.3.3, tslib 2.9.1 and @types/node 26.6.6 in the lockfile, plus npm audit fix for the transitive brace-expansion and serialize-javascript.
FS.filesystems is gone, so mounts reach NODEFS through the module instead, which the build now exports. FS.analyzePath is gone under STRICT, so exists() does the same lookup itself. The glue no longer declares EmscriptenEH, which the unwind brand plugin patched. It was never thrown in 6.0.4 either, only declared: with SUPPORT_LONGJMP=wasm every unwind is a WebAssembly.Exception, so the brand never did anything and goes with the plugin. The docker fallback of build:wasm ran the untagged emsdk image and is pinned to the version CI installs, so a local build makes the glue CI tests. The glue drops from 86.8 to 79 KB.
It was on a commit between releases. CI now checks the submodule sits on a release tag of lua/lua, so it cannot drift back to one.
Update dependencies, Emscripten 7.0.0 and Lua 5.5.1
The generated constructor spelled out this.exported( 147 times and this.wrapWithStringArguments( 37 times, and a minifier has to leave a method name alone. Two locals in the constructor take their place, so the named stores stay as they were and dist/index.js goes from 113.4 kB to 110.7 kB. The README size table was stale (108 + 194) and now carries the measured numbers.
Shorten the generated bindings in the bundle
Add fs: 'none', load each glue on demand and fetch the wasm alongside it
Fall back to jsDelivr and check the wasm against this build's hash
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.
Fixes #21 #83 #127 #149 #148 #143 #134
Tried to fix #61, but emscripten have a very limited support for deno