threads icon indicating copy to clipboard operation
threads copied to clipboard

Can tables be shared?

Open qouteall opened this issue 5 months ago • 4 comments

In overview https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md :

[Spec Changes][spec]

The [limits type][] now has an additional field specifying whether the linear memory or table is shared:

limits ::= {min u32, max u32?, share}
share  ::= unshared | shared

But in the specification https://webassembly.github.io/threads/core/syntax/types.html#syntax-limits the limits doesn't have shared. Is the overview outdated? Seems that tables cannot be shared?

qouteall avatar Sep 14 '25 13:09 qouteall

In this version of the proposal, tables can't be shared, only memories. There is an early-stage extension to additionally add shared tables in a separate repository - https://github.com/WebAssembly/shared-everything-threads

conrad-watt avatar Sep 14 '25 13:09 conrad-watt

Note though that shared tables would only be able to hold "shared references", which is a new concept also introduced by the separate proposal I've linked above. This is because some historical technical limitations of the web make it hard to share ordinary references cross-thread. I actually wrote an article about this recently (https://queue.acm.org/detail.cfm?id=3746173).

Do you have a particular motivation for wanting shared tables?

conrad-watt avatar Sep 14 '25 13:09 conrad-watt

Thanks for the quick response. I have read that great article earlier. Just found that the overview has seemingly outdated things.

qouteall avatar Sep 14 '25 13:09 qouteall

Oh, I misunderstood, sorry! Yes, the current overview in this repository doesn't accurately document in that section that we're only allowing memories to be shared. I'll add a quick note to that section of the overview on this.

conrad-watt avatar Sep 14 '25 15:09 conrad-watt