diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-12-03 19:30:55 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-12-07 16:50:05 -1000 |
commit | 7a7d142903b6eb18854cb9b955fc728a7e3853bd (patch) | |
tree | 7055e69ad134c0ec577c3e634958ef20770104c7 /src/passes/LegalizeJSInterface.cpp | |
parent | 8ce6594dc19cb3203267d1f5e8f335f0ee5a450e (diff) | |
download | binaryen-7a7d142903b6eb18854cb9b955fc728a7e3853bd.tar.gz binaryen-7a7d142903b6eb18854cb9b955fc728a7e3853bd.tar.bz2 binaryen-7a7d142903b6eb18854cb9b955fc728a7e3853bd.zip |
properly legalize imported table elements
Diffstat (limited to 'src/passes/LegalizeJSInterface.cpp')
-rw-r--r-- | src/passes/LegalizeJSInterface.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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) { |