[wasm] Improve jiterpreter trace entry point selection heuristic (#82604)
authorKatelyn Gadd <kg@luminance.org>
Sat, 4 Mar 2023 01:07:20 +0000 (17:07 -0800)
committerGitHub <noreply@github.com>
Sat, 4 Mar 2023 01:07:20 +0000 (17:07 -0800)
commit507acb66e51ccc8fbe5e95f2a07ec4e3280b330c
tree4c115fe48253d18f117f06914f5e79eeac9beb89
parentf6d564eb3301c69dd2efd5008af17c920e772455
[wasm] Improve jiterpreter trace entry point selection heuristic (#82604)

This PR adjusts the jiterpreter's heuristic that decides where it's best to put entry points:
* Adds a requirement that entry points be at least a certain distance apart, since in some cases we can end up with trace entry points right next to each other, which isn't very useful and adds overhead. (Backwards branch targets are exempted from this so loops will still JIT properly).
* If we fail to create a trace exactly located at a backwards branch target, continue trying at blocks afterward. This should help in the rare case where the body of a loop begins with an unsupported instruction.
* When considering how long a trace actually is, we treat conditional aborts (like calls and throws) separately from ignored and supported instructions, so they don't count towards the overall size of the trace. These instructions aren't actually doing any useful work and if executed the trace will exit, so it's better not to consider them when deciding whether a trace is worth compiling.
This PR also manually inlines trace entry logic.
src/mono/mono/mini/interp/interp.c
src/mono/mono/mini/interp/jiterpreter.c
src/mono/mono/utils/options-def.h
src/mono/wasm/runtime/jiterpreter-trace-generator.ts