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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp

Issue 2255673003: [wasm] Support wasm module structured cloning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android/windows Created 4 years, 4 months 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
Index: third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
index cbfc21cf08d5c6261d2f582d973edadf8e236678..4a881ba0d02d51c132f72cf79d2f4e51575a96da 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
@@ -868,6 +868,9 @@ ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeObject(v8::L
return writeTransferredSharedArrayBuffer(object, index, next);
}
+ if (object->IsWebAssemblyCompiledModule()) {
+ return writeWasmCompiledModule(object, next);
+ }
jsbell 2016/08/18 16:48:02 Nit: no {} necessary for single line ifs
Mircea Trofin 2016/08/18 17:34:08 Acknowledged.
Mircea Trofin 2016/08/18 23:02:59 Done.
// Transferable only objects
if (V8MessagePort::hasInstance(object, isolate())) {
uint32_t index;
@@ -1175,6 +1178,16 @@ ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyArrayBuffer
return nullptr;
}
+ScriptValueSerializer::StateBase* ScriptValueSerializer::writeWasmCompiledModule(v8::Local<v8::Object> object, StateBase* next)
+{
+ v8::Local<v8::WasmCompiledModule> wasmModule = object.As<v8::WasmCompiledModule>();
+ v8::WasmCompiledModule::SerializedModule data = wasmModule->Serialize();
jsbell 2016/08/18 16:48:02 Is this a copy, or does SerializedModule point int
Mircea Trofin 2016/08/18 17:34:08 SerializedModule points to existing bytes, at the
jsbell 2016/08/18 18:13:14 Staging is great! (I'm a fan of leaving TODOs in t
Mircea Trofin 2016/08/18 23:02:59 Done.
+ m_writer.append(WasmModuleTag);
+ m_writer.doWriteUint32(static_cast<uint32_t>(data.second));
+ m_writer.append(data.first.get(), static_cast<int>(data.second));
+ return nullptr;
+}
+
ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyArrayBuffer(v8::Local<v8::Object> object, StateBase* next)
{
DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(object);
@@ -1475,6 +1488,12 @@ bool SerializedScriptValueReader::readWithTag(SerializationTag tag, v8::Local<v8
deserializer.pushObjectReference(*value);
break;
}
+ case WasmModuleTag: {
+ if (!readWasmCompiledModule(value))
+ return false;
+ deserializer.pushObjectReference(*value);
+ break;
+ }
case ArrayBufferTag: {
if (!m_version)
return false;
@@ -1827,6 +1846,25 @@ DOMArrayBuffer* SerializedScriptValueReader::doReadArrayBuffer()
return DOMArrayBuffer::create(bufferStart, byteLength);
}
+bool SerializedScriptValueReader::readWasmCompiledModule(v8::Local<v8::Value>* value)
+{
+ uint32_t size = 0;
+ if (!doReadUint32(&size))
+ return false;
+ if (m_position + size > m_length)
+ return false;
+ const uint8_t* buf = m_buffer + m_position;
+ v8::WasmCompiledModule::SerializedModule data = {
+ std::unique_ptr<const uint8_t[]>(buf),
jsbell 2016/08/18 16:48:02 Uh... it seems like the SerializedModule construct
Mircea Trofin 2016/08/18 17:34:08 SerializedModule is just a pair used by both seria
jsbell 2016/08/18 18:13:14 I'd start with this, pending any better ideas.
Mircea Trofin 2016/08/18 23:02:59 Added a TODO, and will follow with the v8 CL + chr
+ static_cast<size_t>(size)
+ };
+ v8::MaybeLocal<v8::WasmCompiledModule> retval =
+ v8::WasmCompiledModule::Deserialize(isolate(), data);
jbroman 2016/08/18 16:59:09 If I read this correctly, every time the V8 versio
Mircea Trofin 2016/08/18 17:34:08 That's correct, the intent is to not support deser
jbroman 2016/08/18 17:55:50 Seems fine, as long as this is addressed before sh
jsbell 2016/08/18 18:13:14 I think what we settled on (in email conversations
Mircea Trofin 2016/08/18 23:02:59 Done.
+ data.first.release();
+ m_position += size;
+ return retval.ToLocal(value);
+}
+
bool SerializedScriptValueReader::readArrayBuffer(v8::Local<v8::Value>* value)
{
DOMArrayBuffer* arrayBuffer = doReadArrayBuffer();

Powered by Google App Engine
This is Rietveld 408576698