Skip to content

Define postMessage of shared Memory - #90

Merged
binji merged 2 commits into
WebAssembly:masterfrom
littledan:structured-clone-memory
Mar 5, 2018
Merged

binji merged 2 commits into
WebAssembly:masterfrom
littledan:structured-clone-memory

Conversation

@littledan

Copy link
Copy Markdown
Contributor

[spec] Normative: Store is per agent cluster

With the WebAssembly threads proposal, a single Memory can be shared between
multiple agents within an agent cluster. This patch associates a WebAssembly
store with an agent cluster, rather than an agent, and updates the WebAssembly
JS API to define the store for an agent as the store for its surrounding
agent cluster.

[spec] Normative: Define serialization for SAB Memory

The semantics here are

  • forStorage serialization is disallowed
  • Transfers are only permitted within an agent cluster
  • Transfer of Memory backed by SharedArrayBuffers makes the buffer available in
    the source and the destination, with no resulting detached buffer.
  • Transfer of Memory backed by ArrayBuffers is disallowed.

This specification attempts to be well-integrated with HTML by defining
n terms of the serialization behavior of Memory as a platform object, and
using the sub-serialization of the underlying SharedArrayBuffer to check
for transferring within an agent cluster, and not to IndexedDB.

Based on the earlier PR at WebAssembly/design#1074

With the WebAssembly threads proposal, a single Memory can be shared between
multiple agents within an agent cluster. This patch associates a WebAssembly
store with an agent cluster, rather than an agent, and updates the WebAssembly
JS API to define the store for an agent as the store for its surrounding
agent cluster.
The semantics here are
- forStorage serialization is disallowed
- Transfers are only permitted within an agent cluster
- Transfer of Memory backed by SharedArrayBuffers makes the buffer available in
  the source and the destination, with no resulting detached buffer.
- Transfer of Memory backed by ArrayBuffers is disallowed.

This specification attempts to be well-integrated with HTML by defining
n terms of the serialization behavior of Memory as a platform object, and
using the sub-serialization of the underlying SharedArrayBuffer to check
for transferring within an agent cluster, and not to IndexedDB.

Based on the earlier PR at WebAssembly/design#1074

@binji binji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, lgtm!

@littledan

Copy link
Copy Markdown
Contributor Author

This patch is missing tests; we should follow up with those. But it looks like there are a lot of missing tests compared to the current specification, so maybe this shouldn't block landing. Feel free to merge this patch if you feel it's appropriate; I don't have any other planned changes.

@lars-t-hansen

Copy link
Copy Markdown

LGTM too. There's an implementation of (what purports to be) this algorithm in Firefox Nightly. I do have some test cases - using the FF test harness - in https://dxr.mozilla.org/mozilla-central/source/js/src/jit-test/tests/wasm/memory-*.js.

@littledan

Copy link
Copy Markdown
Contributor Author

@lars-t-hansen Are you facing any sort of barrier to developing these as web-platform-tests rather than using the Firefox test harness?

@lars-t-hansen

Copy link
Copy Markdown

It's a lame excuse, but I can write jit-tests in my sleep while wpt requires a larger time investment... Also the jit-tests run in the spidermonkey shell, which is important for development speed, I don't want to rebuild Firefox in order to test.

@binji
binji merged commit 41a0f9f into WebAssembly:master Mar 5, 2018
@binji

binji commented Mar 5, 2018

Copy link
Copy Markdown
Member

Cool, I'm OK with landing tests in another PR.

@binji binji mentioned this pull request Jan 29, 2019
stevenfontanella pushed a commit to stevenfontanella/threads that referenced this pull request Feb 11, 2026
stevenfontanella pushed a commit to stevenfontanella/threads that referenced this pull request Feb 11, 2026
* Rename "index type" to "address type" across the spec

* Update "index type" to "address type" in the spec interpreter

* Update section underlines

It is very important that you have precisely the correct number of dots.
It would be too much work for the computer otherwise.

* Rename "address type" to "addr type" in the spec interpreter

* Revert one stray interpreter update
stevenfontanella pushed a commit to stevenfontanella/threads that referenced this pull request Feb 11, 2026
…bAssembly#94)

"index" was renamed to "address". Without this change, all JS tests
generated from the core tests will fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants