Commit 542ff03c authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[wasm] Always make a copy of the wire bytes for a synchronous compile.

R=ahaas@chromium.org,mtrofin@chromium.org

Bug: chromium:759624
Change-Id: I032755698c4f404cfd5bf3298df57a4bcfbe6f2c
Reviewed-on: https://chromium-review.googlesource.com/638590Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47652}
parent 3e8ff5cb
......@@ -812,8 +812,13 @@ MaybeHandle<WasmModuleObject> wasm::SyncCompile(Isolate* isolate,
return {};
}
ModuleResult result = SyncDecodeWasmModule(isolate, bytes.start(),
bytes.end(), false, kWasmOrigin);
// TODO(titzer): only make a copy of the bytes if SharedArrayBuffer
std::unique_ptr<byte[]> copy(new byte[bytes.length()]);
memcpy(copy.get(), bytes.start(), bytes.length());
ModuleWireBytes bytes_copy(copy.get(), copy.get() + bytes.length());
ModuleResult result = SyncDecodeWasmModule(
isolate, bytes_copy.start(), bytes_copy.end(), false, kWasmOrigin);
if (result.failed()) {
thrower->CompileFailed("Wasm decoding failed", result);
return {};
......@@ -823,7 +828,7 @@ MaybeHandle<WasmModuleObject> wasm::SyncCompile(Isolate* isolate,
// {CompileToModuleObject}.
Handle<Code> centry_stub = CEntryStub(isolate, 1).GetCode();
ModuleCompiler compiler(isolate, std::move(result.val), centry_stub);
return compiler.CompileToModuleObject(thrower, bytes, Handle<Script>(),
return compiler.CompileToModuleObject(thrower, bytes_copy, Handle<Script>(),
Vector<const byte>());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment