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

Unified Diff: src/snapshot/code-serializer.cc

Issue 2433273002: [wasm] Avoid double-serializing the wire bytes (Closed)
Patch Set: removed unrelated changes Created 4 years, 2 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
« no previous file with comments | « src/snapshot/code-serializer.h ('k') | test/mjsunit/wasm/compiled-module-serialization.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/code-serializer.cc
diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc
index 74ccf5f26064b04617df74f59577126dcdc2b3fe..7e1e545759ce021d2062bbcf04df85a4ede0c252 100644
--- a/src/snapshot/code-serializer.cc
+++ b/src/snapshot/code-serializer.cc
@@ -223,12 +223,14 @@ std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
Handle<wasm::WasmCompiledModule>::cast(input);
WasmCompiledModuleSerializer wasm_cs(isolate, 0);
wasm_cs.reference_map()->AddAttachedReference(*isolate->native_context());
+ wasm_cs.reference_map()->AddAttachedReference(
+ *compiled_module->module_bytes());
ScriptData* data = wasm_cs.Serialize(compiled_module);
return std::unique_ptr<ScriptData>(data);
}
MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
- Isolate* isolate, ScriptData* data) {
+ Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) {
SerializedCodeData::SanityCheckResult sanity_check_result =
SerializedCodeData::CHECK_SUCCESS;
MaybeHandle<FixedArray> nothing;
@@ -242,6 +244,15 @@ MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
Deserializer deserializer(&scd, true);
deserializer.AddAttachedObject(isolate->native_context());
+ MaybeHandle<String> maybe_wire_bytes_as_string =
+ isolate->factory()->NewStringFromOneByte(wire_bytes, TENURED);
+ Handle<String> wire_bytes_as_string;
+ if (!maybe_wire_bytes_as_string.ToHandle(&wire_bytes_as_string)) {
+ return nothing;
+ }
+ deserializer.AddAttachedObject(
+ handle(SeqOneByteString::cast(*wire_bytes_as_string)));
+
Vector<const uint32_t> stub_keys = scd.CodeStubKeys();
for (int i = 0; i < stub_keys.length(); ++i) {
deserializer.AddAttachedObject(
@@ -250,8 +261,9 @@ MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
MaybeHandle<HeapObject> obj = deserializer.DeserializeObject(isolate);
if (obj.is_null() || !obj.ToHandleChecked()->IsFixedArray()) return nothing;
- Handle<FixedArray> compiled_module =
- Handle<FixedArray>::cast(obj.ToHandleChecked());
+ Handle<wasm::WasmCompiledModule> compiled_module =
+ Handle<wasm::WasmCompiledModule>::cast(obj.ToHandleChecked());
+
wasm::WasmCompiledModule::RecreateModuleWrapper(isolate, compiled_module);
return compiled_module;
}
« no previous file with comments | « src/snapshot/code-serializer.h ('k') | test/mjsunit/wasm/compiled-module-serialization.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698