dicej requested alexcrichton for a review on PR #11547.
dicej opened PR #11547 from dicej:deduplicate-resource-table to bytecodealliance:main:
When I started implementing component model async support, I copied
resource_table.rstoconcurrent/table.rsand made some modifications. Now I'm unifying the implementations to reduce duplication.
concurrent/table.rsnow only contains theTableIdtype and theTableDebugtrait; theTabletype has been merged intoResourceTable.
TableIdcan be thought of as a lightweight variation ofResourcerepresenting handles which can't be borrowed. It also implementsCopy,Hash,Debug, etc. for convenience, and can be converted to and fromResource.
ResourceTablenow hasenable_debug,is_empty,add_child,remove_child, anditer_mutmethods.
ConcurrentState::tableis now of typeMutex<ResourceTable>; theMutexwrapper is needed to ensure the field isSync, but we never lock it.Fixes #11190
<!--
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
-->
dicej requested wasmtime-core-reviewers for a review on PR #11547.
dicej updated PR #11547.
dicej updated PR #11547.
alexcrichton created PR review comment:
I'd probably say go ahead and remove this and only have
get_mutfor now
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Could this replace
MutexwithAlwaysMutadded in https://github.com/bytecodealliance/wasmtime/pull/11453?
alexcrichton created PR review comment:
While this is true of indices we hand out to wasm itself, I think this can be removed now? I think that this was required before merging the wasm-facing tables together but nowadays I think this should be unnecessary
alexcrichton created PR review comment:
Have you used per-table debugging in the past? If not how about moving this to a
constin this module? That way it can still be easily flipped but won't take up space at runtime
dicej submitted PR review.
dicej created PR review comment:
You're right that this was originally a hack because I was handing these handles directly to guests in an early draft. Once I stopped doing that, I removed the hack, but later I added it back in -- not because we were handing these handles to guest, but because I found it useful e.g. here.
In other words, it's not strictly necessary, but it could help us catch our own mistakes more easily.
alexcrichton created PR review comment:
Could
u32::MAXbe used there instead? It's effectively a nice property of container-like data structures that creation doesn't require allocation, so that's what I'd like to shoot for here
alexcrichton submitted PR review.
dicej created PR review comment:
I'm using it in some parts of
concurrent-async-testsand did it this way because I didn't want a static or const to bleed over into other tests where it wasn't meant to be enabled, but I guess it's not that important. Maybe I'll just change theself.debugchecks tocfg!(debug_assertions).
dicej submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
That seems reasonable to me as well yeah :+1:
dicej updated PR #11547.
dicej has enabled auto merge for PR #11547.
dicej updated PR #11547.
dicej has disabled auto merge for PR #11547.
dicej merged PR #11547.
Last updated: Dec 06 2025 at 07:03 UTC