4 ms·
That's a link to the spec, which documents the fact that every memory operator refers to a single "default" linear memory (which can be shared or private). I d
by panic 8y ago
That's a link to the spec, which documents the fact that every memory operator refers to a single "default" linear memory (which can be shared or private). I don't think any of the features on the roadmap (https://webassembly.org/docs/future-features/ https://webassembly.org/docs/future-features/) include support for this kind of chunked memory. I agree that it would be very useful, though!
- danShumway 8y agoLinear memories (default or otherwise) can either be imported or defined inside the module. ... In the MVP, linear memory cannot be shared between threads of execution. The addition of threads :unicorn: will allow this. To me that sounds like, "define multiple linear memories, then import them after you instantiate the module." But I could be misinterpreting.
- panic 8y agoI don't think the thread proposal will change anything here. Like the existing memory instructions, the atomic instructions proposed for threads (https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md https://github.com/WebAssembly/threads/blob/master/proposals...) don't take a linear memory parameter. That means they operate on the same default linear memory.
- danShumway 8y agoYou are very right, dug into it a bit more and none of the memory functions (new atomic ones included) have parameters to specify a memidex. Thanks for looking into that, it's good to know. > In the current version of WebAssembly, at most one memory may be defined or imported in a single module, and all constructs implicitly reference this memory 0. This restriction may be lifted in future versions. But I don't get the impression that it's completely unplanned. Modules still take a vector of linear memories, not just one[0], which would be pointless if it wasn't planned to let you access the others at some point. Data segments also explicitly allow referencing a memidx[1] (even if right now 0 is the only one that's allowed). Still, I've been under the impression that this was going in as part of threads, and I was all excited since threads were making such good progress. I'm a little disappointed to find out it's not. It's also possible globals[2] might solve some of the same problems? But I haven't dug into them enough to know what their memory model looks like or how well they work across multiple modules, and in any case, sharing multiple globals is probably going to be less convenient than just sharing memory, so I'd still like to see the ability to import multiple chunks of memory. [0]: https://webassembly.github.io/threads/syntax/modules.html# https://webassembly.github.io/threads/syntax/modules.html# [1]: https://webassembly.github.io/threads/syntax/modules.html#syntax-mem https://webassembly.github.io/threads/syntax/modules.html#sy... [2]: https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API#Globals https://developer.mozilla.org/en-US/docs/WebAssembly/Using_t...