alexcrichton opened PR #13424 from alexcrichton:refactor-table-grow-and-fill to bytecodealliance:main:
This commit refactors the implementation of the
table.{grow,fill}WebAssembly instructions to perform more work in compiled code rather than within the runtime itself. This shrinks the amount of libcalls needed, for example, simplifies some internals by having them build on each other, and additionally helps address #13387 by routing more bulk operations through a "narrow waist".This refactors the internals of
memory.fillandarray.fill, previously refactored before, to share more implementation details. The end result is that the implementation oftable.fillis a one-liner to a generic "fill this thing with this value" helper. Additionally thetable.growinstruction is reimplemented in terms of this, meaning that the host is responsible for growth, but compiled code is responsible for initializing the table.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #13424.
alexcrichton requested cfallin for a review on PR #13424.
alexcrichton requested wasmtime-core-reviewers for a review on PR #13424.
alexcrichton updated PR #13424.
alexcrichton updated PR #13424.
:thumbs_up: cfallin submitted PR review:
Looks good!
:speech_balloon: cfallin created PR review comment:
Add a comment here that we must not have any epoch-yield points within the fill?
(This also seems important in a CM async / cooperative threads context, because otherwise, if an epoch-yield someday becomes run-concurrent-compatible and another async activation runs, it could otherwise observe state halfway through an instruction, right? I don't know if that's a valid concern or if it is statically disallowed but in any case noting the relevant invariants here, and maybe at the bulk-fill loop implementation too, seems like a good idea)
:speech_balloon: cfallin created PR review comment:
s/seew hether/see whether/
github-actions[bot] added the label wasmtime:api on PR #13424.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
That's a good point/question, and definitely related to https://github.com/bytecodealliance/wasmtime/issues/11869. For now we're fine insofar as async libcalls like yield points will lock up the entire store making it statically impossible to read or write anything within the store. While we do want to fix that (at least somewhat) in the future it's a bit of an open question how to do so. One issue is that we definitely cannot allow mutations during yield points, but that'd still be a problem here if we allow reads. I'll leave comments on that issue since I think that's probably the best place (as opposed to the code) since it's a pervasive concern and not necessarily isolated to just this part of the code.
It's unfortunate as well because I think we explicitly want epoch yields here in table growth in case it's a massive table growth...
alexcrichton updated PR #13424.
alexcrichton has enabled auto merge for PR #13424.
alexcrichton added PR #13424 Reimplement table.{grow,fill} to the merge queue
github-merge-queue[bot] removed PR #13424 Reimplement table.{grow,fill} from the merge queue
alexcrichton added PR #13424 Reimplement table.{grow,fill} to the merge queue
:check: alexcrichton merged PR #13424.
alexcrichton removed PR #13424 Reimplement table.{grow,fill} from the merge queue
Last updated: Jun 01 2026 at 09:49 UTC