Skip to content

[threads][test][js-api] Add tests for growing shared memory#248

Open
backes wants to merge 1 commit intoWebAssembly:mainfrom
backes:add-test-for-grow-SAB
Open

[threads][test][js-api] Add tests for growing shared memory#248
backes wants to merge 1 commit intoWebAssembly:mainfrom
backes:add-test-for-grow-SAB

Conversation

@backes
Copy link
Member

@backes backes commented Mar 12, 2026

Add a few first (!) js-api test to this repo. In particular:

  • Growing a non-shared memory always detaches the old buffer and allocates a fresh one (as before).
  • Growing a shared memory only refreshes the buffer if the delta in pages is > 0.
  • Growing a shared memory has no effect on unrelated shared memories.

Note that V8 didn't implement this correctly until https://crrev.com/c/7660970, see https://crbug.com/492128992.

Add a few first (!) js-api test to this repo. In particular:
- Growing a non-shared memory always detaches the old buffer and
  allocates a fresh one (as before).
- Growing a shared memory only refreshes the buffer if the delta in
  pages is > 0.
- Growing a shared memory has no effect on unrelated shared memories.

Note that V8 didn't implement this correctly until
https://crrev.com/c/7660970, see https://crbug.com/492128992.
hubot pushed a commit to v8/v8 that referenced this pull request Mar 16, 2026
Shared ArrayBuffers need replacement whenever their backing store grows,
as they do not update their 'byteLength' automatically.
This was previously done unconditionally for all shared memories on any
growth (via 'UpdateSharedWasmMemoryObjects').
This CL changes it so only those 'JSArrayBuffer's are cleared (and thus
refreshed on their next access) that are actually smaller than their
backing store.

Note that for non-shared memory, 'grow(0)' still detaches and replaces
the buffer, as mandated by the current JS API spec. Shared memory
follows the Threads proposal which specifically preserves identity
when the length doesn't change.

A respective spec test is added in
WebAssembly/threads#248.

R=jkummerow@chromium.org

Bug: 492128992

Change-Id: I76a0f4ce23c98eb73c3a74c36fb0795f08e9ffa4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7660970
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#105812}
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.

1 participant