Commit 55bbcc4c authored by Sven Sauleau's avatar Sven Sauleau Committed by Commit Bot

[wasm] a grown shared memory should stay SharedArrayBuffer

According to WebAssembly's thread proposal, the memory type is decided
at the Object's creation and don't change over time.

When growing a shared memory and the old buffer was marked as shared;
setup the new buffer as shared as well.

Bug: v8:8564
Change-Id: I7e59071d11b41315429232ae0c90436c6810bd0e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1526012Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Sven Sauleau <ssauleau@igalia.com>
Auto-Submit: Sven Sauleau <ssauleau@igalia.com>
Cr-Commit-Position: refs/heads/master@{#60312}
parent f78963de
......@@ -1303,8 +1303,9 @@ int32_t WasmMemoryObject::Grow(Isolate* isolate,
}
// SharedArrayBuffer, but not shared across isolates. Setup a new buffer
// with updated permissions and update the instances.
new_buffer = wasm::SetupArrayBuffer(isolate, backing_store, new_size,
old_buffer->is_external());
new_buffer =
wasm::SetupArrayBuffer(isolate, backing_store, new_size,
old_buffer->is_external(), SharedFlag::kShared);
memory_object->update_instances(isolate, new_buffer);
} else {
if (!MemoryGrowBuffer(isolate, old_buffer, new_size)
......
......@@ -337,3 +337,11 @@ let workerHelpers = assertTrue.toString() + assertIsWasmSharedMemory.toString();
assertTraps(kTrapMemOutOfBounds,
() => instance.exports.atomic_load(25 * kPageSize - 3));
})();
(function TestMemoryBufferTypeAfterGrow() {
const memory = new WebAssembly.Memory({
"initial": 1, "maximum": 2, "shared": true });
assertInstanceof(memory.buffer, SharedArrayBuffer);
assertEquals(memory.grow(1), 1);
assertInstanceof(memory.buffer, SharedArrayBuffer);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment