Index: src/snapshot/code-serializer.cc |
diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc |
index 74ccf5f26064b04617df74f59577126dcdc2b3fe..10ea5ddde741499f38785b3476d139938198abe4 100644 |
--- a/src/snapshot/code-serializer.cc |
+++ b/src/snapshot/code-serializer.cc |
@@ -223,12 +223,15 @@ std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule( |
Handle<wasm::WasmCompiledModule>::cast(input); |
WasmCompiledModuleSerializer wasm_cs(isolate, 0); |
wasm_cs.reference_map()->AddAttachedReference(*isolate->native_context()); |
+ Handle<SeqOneByteString> wire_bytes = compiled_module->module_bytes(); |
Yang
2016/10/20 06:46:17
Another way to do this is to use attached referenc
Mircea Trofin
2016/10/20 07:22:30
Oh... yes. Yes, makes sense :) Thanks!
|
+ compiled_module->reset_module_bytes(); |
ScriptData* data = wasm_cs.Serialize(compiled_module); |
+ compiled_module->set_module_bytes(wire_bytes); |
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; |
@@ -250,8 +253,16 @@ 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()); |
+ 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; |
+ |
+ compiled_module->set_module_bytes( |
+ handle(SeqOneByteString::cast(*wire_bytes_as_string))); |
wasm::WasmCompiledModule::RecreateModuleWrapper(isolate, compiled_module); |
return compiled_module; |
} |