Open NWilson opened 6 years ago
I think this is an interesting idea, see previous discussion on the emscripten repo at https://github.com/kripken/emscripten/issues/6155
Overall, the main issue is with point 1: currently the table is neither imported nor exported, and that turns out to be good for VM optimizations as well as toolchain ones, see last comment in that link.
I've been looking at how Emscripten post-processes the output of LLD in the current Wasm work. It looks like
wasm-emscripten
generates dynCall thunks for every function signature in the table? I can see why you want to do this - to allow callback-style programming.But don't the Web APIs give you what you want already?
You'd need to do something like this:
I can think of three reasons perhaps why you don't do this already - but all of them are surmountable.
table.get(fn)
is really all that much slower than going via your dynCall thunk. It might be marginally quicker - did you test the two approaches?