From 7a7d142903b6eb18854cb9b955fc728a7e3853bd Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 3 Dec 2016 19:30:55 -0800 Subject: properly legalize imported table elements --- src/passes/LegalizeJSInterface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/passes/LegalizeJSInterface.cpp') diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index c9cada3c0..6e070156f 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -57,6 +57,15 @@ struct LegalizeJSInterface : public Pass { auto* legal = makeLegalStub(im.get(), module, funcName); illegalToLegal[im->name] = funcName; newImports.push_back(legal); + // we need to use the legalized version in the table, as the import from JS + // is legal for JS. Our stub makes it look like a native wasm function. + for (auto& segment : module->table.segments) { + for (auto& name : segment.data) { + if (name == im->name) { + name = funcName; + } + } + } } } if (illegalToLegal.size() > 0) { -- cgit v1.2.3