Add --js-call-indirect option. #5864
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently Chrome and Firefox are unhelpful in diagnosing
call_indirect
errors, but when one occurs, a blank error printis logged.
This challenge was discussed in emscripten-core/emscripten#16126 and there were workarounds presented there:
-Wbad-function-cast -Wcast-function-type
or even-Werror=bad-function-cast -Werror=cast-function-type
. However, in our huge codebase, we get tons of diagnostics from these in 3rd party code paths that are never exercised, or are false positives, so it does not help one to target an immediate bug scenario - and would not help see into issues where the function pointers to call_indirect are either null, or corrupted.-fsanitize=undefined
. However unfortunately our codebase is too large, and we get alocal count too large
error.Hence I would like to improve the debuggability of
call_indirect
s from the toolchain side to help figure out when the function signature does not match, or when the function pointer is bad.To do that, my idea is to try to route all
call_indirect
s instead over tojs_call_indirect_sig
functions on the JS import side, which could do analysis on the calls, and then refer to the WebAssembly.Table (wasmTable
object in Emscripten JS runtime).