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

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

Issue 2749503002: [wasm] enable wasm structured cloning in specific cases (Closed)
Patch Set: async Created 3 years, 9 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/serialization/V8ScriptValueSerializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
index 267a8ab5d524f53eef7a08b165e1bb09ee43be50..966f948f6a53d976d9e3527dfb9c2b7e8abe076c 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
@@ -49,7 +49,8 @@ V8ScriptValueSerializer::V8ScriptValueSerializer(
m_serializedScriptValue(SerializedScriptValue::create()),
m_serializer(m_scriptState->isolate(), this),
m_transferables(options.transferables),
- m_blobInfoArray(options.blobInfo) {}
+ m_blobInfoArray(options.blobInfo),
+ m_inlineWasm(options.writeWasmToStream) {}
RefPtr<SerializedScriptValue> V8ScriptValueSerializer::serialize(
v8::Local<v8::Value> value,
@@ -420,6 +421,23 @@ v8::Maybe<uint32_t> V8ScriptValueSerializer::GetSharedArrayBufferId(
return v8::Just<uint32_t>(index);
}
+v8::Maybe<uint32_t> V8ScriptValueSerializer::GetWasmModuleTransferId(
+ v8::Isolate* isolate,
+ v8::Local<v8::WasmCompiledModule> module) {
+ if (m_inlineWasm)
+ return v8::Nothing<uint32_t>();
+
+ // We don't expect scenarios with numerous wasm modules being transferred
+ // around. Most likely, we'll have one module. The vector approach is simple
+ // and should perform sufficiently well under these expectations.
+ this->m_serializedScriptValue->wasmModules().push_back(
+ module->GetTransferrableModule());
+ uint32_t size =
+ static_cast<uint32_t>(m_serializedScriptValue->wasmModules().size());
+ DCHECK_GE(size, 1u);
+ return v8::Just(size - 1);
+}
+
void* V8ScriptValueSerializer::ReallocateBufferMemory(void* oldBuffer,
size_t size,
size_t* actualSize) {

Powered by Google App Engine
This is Rietveld 408576698