Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: src/value-serializer.cc

Issue 2579963002: Revert of Disallow passing a SharedArrayBuffer in the transfer list. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/value-serializer.h ('k') | test/unittests/value-serializer-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/value-serializer.cc
diff --git a/src/value-serializer.cc b/src/value-serializer.cc
index 55c0ffb0eb29840436c41f622f92d4f37854796c..81301fd55395b4e8d2f356ec9413da6b6425953b 100644
--- a/src/value-serializer.cc
+++ b/src/value-serializer.cc
@@ -110,8 +110,8 @@
// ObjectReference to one) serialized just before it. This is a quirk arising
// from the previous stack-based implementation.
kArrayBufferView = 'V',
- // Shared array buffer. transferID:uint32_t
- kSharedArrayBuffer = 'u',
+ // Shared array buffer (transferred). transferID:uint32_t
+ kSharedArrayBufferTransfer = 'u',
// Compiled WebAssembly module. encodingType:(one-byte tag).
// If encodingType == 'y' (raw bytes):
// wasmWireByteLength:uint32_t, then raw data
@@ -269,7 +269,6 @@
void ValueSerializer::TransferArrayBuffer(uint32_t transfer_id,
Handle<JSArrayBuffer> array_buffer) {
DCHECK(!array_buffer_transfer_map_.Find(array_buffer));
- DCHECK(!array_buffer->is_shared());
array_buffer_transfer_map_.Set(array_buffer, transfer_id);
}
@@ -443,7 +442,7 @@
case JS_SET_TYPE:
return WriteJSSet(Handle<JSSet>::cast(receiver));
case JS_ARRAY_BUFFER_TYPE:
- return WriteJSArrayBuffer(Handle<JSArrayBuffer>::cast(receiver));
+ return WriteJSArrayBuffer(JSArrayBuffer::cast(*receiver));
case JS_TYPED_ARRAY_TYPE:
case JS_DATA_VIEW_TYPE:
return WriteJSArrayBufferView(JSArrayBufferView::cast(*receiver));
@@ -725,29 +724,20 @@
return Just(true);
}
-Maybe<bool> ValueSerializer::WriteJSArrayBuffer(
- Handle<JSArrayBuffer> array_buffer) {
- if (array_buffer->is_shared()) {
- if (!delegate_) {
- ThrowDataCloneError(MessageTemplate::kDataCloneError, array_buffer);
- return Nothing<bool>();
- }
-
- v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate_);
- Maybe<uint32_t> index = delegate_->GetSharedArrayBufferId(
- v8_isolate, Utils::ToLocalShared(array_buffer));
- RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate_, Nothing<bool>());
-
- WriteTag(SerializationTag::kSharedArrayBuffer);
- WriteVarint(index.FromJust());
- return Just(true);
- }
-
+Maybe<bool> ValueSerializer::WriteJSArrayBuffer(JSArrayBuffer* array_buffer) {
uint32_t* transfer_entry = array_buffer_transfer_map_.Find(array_buffer);
if (transfer_entry) {
- WriteTag(SerializationTag::kArrayBufferTransfer);
+ WriteTag(array_buffer->is_shared()
+ ? SerializationTag::kSharedArrayBufferTransfer
+ : SerializationTag::kArrayBufferTransfer);
WriteVarint(*transfer_entry);
return Just(true);
+ }
+
+ if (array_buffer->is_shared()) {
+ ThrowDataCloneError(
+ MessageTemplate::kDataCloneErrorSharedArrayBufferNotTransferred);
+ return Nothing<bool>();
}
if (array_buffer->was_neutered()) {
ThrowDataCloneError(MessageTemplate::kDataCloneErrorNeuteredArrayBuffer);
@@ -755,7 +745,7 @@
}
double byte_length = array_buffer->byte_length()->Number();
if (byte_length > std::numeric_limits<uint32_t>::max()) {
- ThrowDataCloneError(MessageTemplate::kDataCloneError, array_buffer);
+ ThrowDataCloneError(MessageTemplate::kDataCloneError, handle(array_buffer));
return Nothing<bool>();
}
WriteTag(SerializationTag::kArrayBuffer);
@@ -1115,7 +1105,7 @@
const bool is_shared = false;
return ReadTransferredJSArrayBuffer(is_shared);
}
- case SerializationTag::kSharedArrayBuffer: {
+ case SerializationTag::kSharedArrayBufferTransfer: {
const bool is_shared = true;
return ReadTransferredJSArrayBuffer(is_shared);
}
« no previous file with comments | « src/value-serializer.h ('k') | test/unittests/value-serializer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698