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

Unified Diff: src/wasm/wasm-module.cc

Issue 2124743002: [wasm] Copy the signature when compiling an imported function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index ddc2eba7c852e471d12a240411f4fa205ed0aefc..68254a125576f734d0181117cbfcacee22d6e1a0 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -648,15 +648,22 @@ bool CompileWrappersToImportedFunctions(Isolate* isolate,
*thrower, isolate->factory(), ffi, index, module_name, function_name);
if (function.is_null()) return false;
- FunctionSig sig(
- ret_count, param_count,
- reinterpret_cast<const MachineRepresentation*>(sig_data->data()));
-
- Handle<Code> code = compiler::CompileWasmToJSWrapper(
- isolate, function.ToHandleChecked(), &sig, index, module_name,
- function_name);
-
- imports.push_back(code);
+ {
+ // Copy the signature to avoid a raw pointer into a heap object when
+ // GC can happen.
+ Zone zone(isolate->allocator());
+ MachineRepresentation* reps =
+ zone.NewArray<MachineRepresentation>(sig_data_size);
+ memcpy(reps, sig_data->data(),
+ sizeof(MachineRepresentation) * sig_data_size);
+ FunctionSig sig(ret_count, param_count, reps);
+
+ Handle<Code> code = compiler::CompileWasmToJSWrapper(
+ isolate, function.ToHandleChecked(), &sig, index, module_name,
+ function_name);
+
+ imports.push_back(code);
+ }
}
}
return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698