fitzgen requested alexcrichton for a review on PR #13695.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13695.
fitzgen opened PR #13695 from fitzgen:inline-enter-exit-sync-call-in-sync-to-sync-adapters to bytecodealliance:main:
See each commit for details.
fitzgen requested wasmtime-wasi-reviewers for a review on PR #13695.
fitzgen requested wasmtime-core-reviewers for a review on PR #13695.
fitzgen updated PR #13695.
github-actions[bot] added the label wasmtime:api on PR #13695.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
IIRC you were thinking this might be const-
false, did that not end up being the case?
:speech_balloon: alexcrichton created PR review comment:
I realize this is preexisting, but is there an issue on file and/or could you file an issue for deduplicating all this? This seems pretty verbose, duplicative, and error-prone if we have refactorings in the future. I'd love to move towards a world where
VMContextand/orVMOffsetsis largely defined by a macro for example which could perhaps help a lot here. I don't have any idea how we'd do that, though, and I don't want to block this, but I think it'd be good to track this in an issue.
:speech_balloon: alexcrichton created PR review comment:
Could this include some small notes/references to how this is implemented in a dual of CLIF-generated code + the libcall itself?
:speech_balloon: alexcrichton created PR review comment:
Mind going through these tests and trimming down these comments? I suspect most of these can be shortened to just decribing what the test is doing
:speech_balloon: alexcrichton created PR review comment:
Perhaps
Option<VmPtr<VMDeferredThread>>to juggle provenance?
:speech_balloon: alexcrichton created PR review comment:
Like above, could this have a comment as well?
:speech_balloon: alexcrichton created PR review comment:
(not blocking) this is another file where a macro might be able to help reduce all the boilerplate needed here...
:speech_balloon: alexcrichton created PR review comment:
Could this have a comment explaining what it's doing?
:speech_balloon: alexcrichton created PR review comment:
before I forget about this, can you add notes/docs to enter/exit as-implemented in the concurrent.rs file indicating that the implementation is additionally in JIT code and the two should be kept in-sync?
:speech_balloon: alexcrichton created PR review comment:
Orthogonally (sort of) it's kind of a bummer that a whole new
FuncKeyis added here when it's basically not used anywhere. Could the "known imports" field transition to being aenum { FuncKey, Trampoline }and would that help avoid adding this as a newFuncKeyand having to handle it places?
:speech_balloon: alexcrichton created PR review comment:
This is a good point, and something that I'm a bit worried about. Calling
set_trappedabove is not something that memory safety relies on, just correctness. Here however this is load-bearing for memory safety and if we ever forget to do this it's quite bad.I'm not confident that this block is hit for every single possible trap in wasm code. Basically I'm worried we have preexisting niche cases that
set_trappeddoesn't get called today, and those cases are now extending to this. I'm not certain of this, though, because I can't articulate the exact sequence that would lead to this...WDYT though about moving this reset to JIT code itself? That should be possible, I believe, from our entry trampolines when concurrency is enabled. Does that sound ok? I'd be a bit more comfortable in accepting that that would catch everything personally. This is a pretty mild preference, though, so feel free to push back.
:thumbs_up: alexcrichton submitted PR review:
Actually I'll go ahead and flag this for merge. One thing I'd recommend, if you can, is to get an LLM review locally as well to double-check this signs off with no known bugs. If nothing materially changes from my suggestions/comments though seems fine to land.
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
Sure. I've wanted to use macros to generate all the offsets stuff and the type definition itself for a while now, and this is just another place where we would reuse that same infrastructure.
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
Filed https://github.com/bytecodealliance/wasmtime/issues/13707
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
I was confusing sync type vs sync ABI (that is,
self.types[adapter.lift.ty].async_versusadapter.lift.options.async_). The inlining only happens for sync-to-sync ABIs but the callee's type can still be either async or sync, and replaying the deferred thread creation requires remembering this inVMDeferredThread::callee_async, IIUC.
fitzgen updated PR #13695.
fitzgen updated PR #13695.
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
fitzgen updated PR #13695.
fitzgen updated PR #13695.
fitzgen updated PR #13695.
fitzgen updated PR #13695.
fitzgen updated PR #13695.
fitzgen has enabled auto merge for PR #13695.
fitzgen added PR #13695 Inline {enter,exit}_sync_call trampolines into sync-to-sync fused adapters to the merge queue.
github-merge-queue[bot] removed PR #13695 Inline {enter,exit}_sync_call trampolines into sync-to-sync fused adapters from the merge queue.
fitzgen updated PR #13695.
fitzgen has enabled auto merge for PR #13695.
fitzgen updated PR #13695.
fitzgen updated PR #13695.
fitzgen added PR #13695 Inline {enter,exit}_sync_call trampolines into sync-to-sync fused adapters to the merge queue.
:check: fitzgen merged PR #13695.
fitzgen removed PR #13695 Inline {enter,exit}_sync_call trampolines into sync-to-sync fused adapters from the merge queue.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
TODO FITZGEN
:speech_balloon: alexcrichton created PR review comment:
Could this "1" constant be moved to the
wasmtime_environcrate or similar?
:speech_balloon: alexcrichton created PR review comment:
Either that or could there be a compile-time assertion that "1" is the pattern used here, with a comment saying that if the constant changes it needs to update the compiler too?
:speech_balloon: alexcrichton created PR review comment:
How come this is necessary? (same for the one below too)
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
Whoops, thanks for catching this
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
It's more defensive than strictly required as the code exists today. The problem is that we hand out
ComponentTaskStatewhich contains the concurrent state, which contains the unforced current thread, but by doing so the code that gets that state can't have access to the store at teh same time due to borrow rules so it can't get the actual/forced current thread, so we defensively update the unforced current thread eagerly before passing out theComponentTaskState.I think ideally we would completely remove the current thread from the concurrent state and only have it on store and refactor the rest of the code accordingly, but that seemed like a pretty big task to do in this PR.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
Code isn't expected to access
unforced_current_threadthough, right? I'd expect that if the current thread was needed it'd be done withStoreOpaquebefore gettingComponentTaskState, and by gettingComponentTaskStatecode would otherwise follow the convention of not even looking atunforced_current_statedue to the scary name.
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
Ideally, yes, but there is a lot of existing code that doesn't have access to a store and only has the
ComponentTaskState. I felt it was better to be safe than sorry.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
Makes sense yeah, I've addressed these in https://github.com/bytecodealliance/wasmtime/pull/13758 and https://github.com/bytecodealliance/wasmtime/pull/13759
Last updated: Jul 29 2026 at 05:03 UTC