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

Unified Diff: src/api.cc

Issue 2404673002: [wasm] Avoid copying when deserializing wasm (Closed)
Patch Set: 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 | « include/v8.h ('k') | 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 20e5e81d3361fed1586b64a1ca3c05e7a6e4ed3b..82ace9c55be6c16cbfa0e9201a910d67ba7a5f12 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -7234,27 +7234,22 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize(
MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile(
Isolate* isolate,
const WasmCompiledModule::SerializedModule& serialized_data,
- Local<String> uncompiled_bytes) {
+ const WasmCompiledModule::UncompiledBytes& uncompiled_bytes) {
MaybeLocal<WasmCompiledModule> ret = Deserialize(isolate, serialized_data);
if (!ret.IsEmpty()) return ret;
- return Compile(isolate, uncompiled_bytes);
+ return Compile(isolate, uncompiled_bytes.first.get(),
+ uncompiled_bytes.second);
}
-MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(
- Isolate* isolate, Local<String> bytes) {
- i::Handle<i::String> module_bytes = Utils::OpenHandle(*bytes);
+MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(Isolate* isolate,
+ const uint8_t* start,
+ size_t length) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Deserialize()");
- i::SeqOneByteString* data = i::SeqOneByteString::cast(*module_bytes);
- // Copy bytes such that GC can not move it during construction of the module.
- // TODO(wasm): Avoid this additional copy.
- i::ScopedVector<unsigned char> bytes_copy(data->length());
- memcpy(bytes_copy.start(), data->GetChars(), data->length());
i::MaybeHandle<i::JSObject> maybe_compiled =
- i::wasm::CreateModuleObjectFromBytes(
- i_isolate, bytes_copy.start(),
- bytes_copy.start() + bytes_copy.length(), &thrower,
- i::wasm::ModuleOrigin::kWasmOrigin);
+ i::wasm::CreateModuleObjectFromBytes(i_isolate, start, start + length,
+ &thrower,
+ i::wasm::ModuleOrigin::kWasmOrigin);
if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>();
return Local<WasmCompiledModule>::Cast(
Utils::ToLocal(maybe_compiled.ToHandleChecked()));
« no previous file with comments | « include/v8.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698