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

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

Issue 2486943005: [wasm] Imported WebAssembly function are never wrapped. (Closed)
Patch Set: typo Created 4 years, 1 month 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/mjsunit/wasm/test-import-export-wrapper.js » ('j') | 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 179af57ac6d626c06d0fc315d2aa38826b37892b..3778b6307cc8d0d95eb1cf03aeb62acc6927dbcc 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -916,10 +916,14 @@ static Handle<Code> CompileImportWrapper(Isolate* isolate, int index,
MaybeHandle<String> import_name) {
Handle<Code> code;
WasmFunction* other_func = GetWasmFunctionForImportWrapper(isolate, target);
- if (other_func && sig->Equals(other_func->sig)) {
- // Signature matched. Unwrap the JS->WASM wrapper and return the raw
- // WASM function code.
- return UnwrapImportWrapper(target);
+ if (other_func) {
+ if (sig->Equals(other_func->sig)) {
+ // Signature matched. Unwrap the JS->WASM wrapper and return the raw
+ // WASM function code.
+ return UnwrapImportWrapper(target);
+ } else {
+ return Handle<Code>::null();
+ }
} else {
// Signature mismatch. Compile a new wrapper for the new signature.
return compiler::CompileWasmToJSWrapper(isolate, target, sig, index,
@@ -1449,6 +1453,11 @@ class WasmInstanceBuilder {
Handle<Code> import_wrapper = CompileImportWrapper(
isolate_, index, module_->functions[import.index].sig,
Handle<JSReceiver>::cast(function), module_name, function_name);
+ if (import_wrapper.is_null()) {
+ ReportFFIError("imported function does not match the expected type",
+ index, module_name, function_name);
+ return -1;
+ }
code_table->set(num_imported_functions, *import_wrapper);
RecordStats(isolate_, *import_wrapper);
num_imported_functions++;
« no previous file with comments | « no previous file | test/mjsunit/wasm/test-import-export-wrapper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698