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

Unified Diff: src/api.cc

Issue 2420373002: [wasm] Test deserialized module still has bytes, + negative test (Closed)
Patch Set: [wasm] Test deserialized module still has bytes, + negative test 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 | « no previous file | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 919e8394d0a0e122fecf26b24ede617937374240..d847d24bd2ee3273237fa6568612b6f0a891cdc1 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -7247,7 +7247,25 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile(
const WasmCompiledModule::CallerOwnedBuffer& serialized_module,
const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) {
MaybeLocal<WasmCompiledModule> ret = Deserialize(isolate, serialized_module);
- if (!ret.IsEmpty()) return ret;
+ if (!ret.IsEmpty()) {
+ // TODO(mtrofin): once we stop taking a dependency on Deserialize,
+ // clean this up to avoid the back and forth between internal
+ // and external representations.
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ i::Vector<const uint8_t> str(wire_bytes.first,
+ static_cast<int>(wire_bytes.second));
+ i::Handle<i::SeqOneByteString> wire_bytes_as_string(
+ i::SeqOneByteString::cast(
+ *i_isolate->factory()->NewStringFromOneByte(str).ToHandleChecked()),
+ i_isolate);
+
+ i::Handle<i::JSObject> obj =
+ i::Handle<i::JSObject>::cast(Utils::OpenHandle(*ret.ToLocalChecked()));
+ i::Handle<i::wasm::WasmCompiledModule> compiled_part =
+ i::handle(i::wasm::WasmCompiledModule::cast(obj->GetInternalField(0)));
+ compiled_part->set_module_bytes(wire_bytes_as_string);
+ return ret;
+ }
return Compile(isolate, wire_bytes.first, wire_bytes.second);
}
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698