6 ms·
I think you could share an address space by using the same SharedArrayBuffer to back the linear memory of both? I could be wrong here, I haven’t done it, but I
by paulgb 4y ago
I think you could share an address space by using the same SharedArrayBuffer to back the linear memory of both?
I could be wrong here, I haven’t done it, but I thought this was the reason for supporting atomics in the first place.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- kllrnohj 4y agoThat only shares one allocation (like shared memory does in regular multi-process scenarios), but you still can't share the address space or even any object heaps at all. Like it's not possible to allocate javascript objects out of a SharedArrayBuffer such that you could pretend you had a shared address space by sticking everything in that. As in, SharedArrayBuffer is equivalent to shm_open. Which means it's not even that good as a shared memory construct as it's missing all the protection enforcement of memfd (or Android's ashmem)
- circuit10 4y agoWASM stores everything in an array buffer, it doesn't use JavaScript objects because it's not JavaScript (though there are starting to be features that allow it to interoperate with JS objects). If it didn't store everything in a big memory array then it wouldn't really work because C assumes that And no, WASM doesn't support memory protection
- monocasa 4y agoBut shared array buffer is the underlying primitive generally for webassembly accessible memory.