Commit 182a8283 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

Reland "[serialize] Fix serializing wasm backed ArrayBuffer"

Skipped test: https://crrev.com/c/3561199.
This is a reland of commit 6e2c9bb2

Original change's description:
> [serialize] copy bytes for non detachable array_buffer
> in WriteJSArrayBuffer when array_buffer is not in
> array_buffer_transfer_map_
>
> According to https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal
> steps 13.3.2-4, should normally serialize array buffer which
> is not detachable.
>
> Bug: v8:12703
> Change-Id: I4554c5d07ae85e1a96a728ebba04c6a071575f6f
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3518910
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Commit-Queue: Marja Hölttä <marja@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#79466}

Bug: v8:12703
Change-Id: I1ad1b8159ac7b13011831a4590e8577e954db946
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3557689Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79714}
parent ca505562
......@@ -5011,7 +5011,8 @@ class Serializer : public ValueSerializer::Delegate {
Local<ArrayBuffer> array_buffer =
Local<ArrayBuffer>::New(isolate_, global_array_buffer);
if (!array_buffer->IsDetachable()) {
isolate_->ThrowError("ArrayBuffer could not be transferred");
isolate_->ThrowError(
"ArrayBuffer is not detachable and could not be transferred");
return Nothing<bool>();
}
......
......@@ -907,10 +907,6 @@ Maybe<bool> ValueSerializer::WriteJSArrayBuffer(
WriteVarint(index.FromJust());
return ThrowIfOutOfMemory();
}
if (!array_buffer->is_detachable()) {
return ThrowDataCloneError(
MessageTemplate::kDataCloneErrorNonDetachableArrayBuffer);
}
uint32_t* transfer_entry = array_buffer_transfer_map_.Find(array_buffer);
if (transfer_entry) {
......
......@@ -15,7 +15,13 @@
let worker = new Worker('', {type: 'string'});
let memory = new WebAssembly.Memory({initial: 1, maximum: 2});
assertThrows(() => worker.postMessage(memory.buffer), Error);
worker.postMessage(memory.buffer);
assertThrows(() => {
worker.postMessage(memory.buffer, [memory.buffer])
}, Error)
assertThrows(() => {
worker.postMessage(undefined, [memory.buffer])
}, Error)
})();
// Can't use assert in a worker.
......
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