Skip to content

Commit

Permalink
[wasm] Optimize out redundant null checks in the jiterpreter (#81811)
Browse files Browse the repository at this point in the history
* Optimize out duplicate null checks in the jiterpreter
* Fix the last opcode of a jiterpreter trace sometimes executing again after the end of the trace
  • Loading branch information
kg authored Feb 9, 2023
1 parent 4570167 commit 2b70123
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 74 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/utils/options-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ DEFINE_BOOL(jiterpreter_dump_traces, "jiterpreter-dump-traces", FALSE, "Dump the
// Use runtime imports for pointer constants
// Currently reduces performance significantly :(
DEFINE_BOOL(jiterpreter_use_constants, "jiterpreter-use-constants", FALSE, "Use runtime imports for pointer constants")
// Attempt to eliminate redundant null checks in compiled traces
DEFINE_BOOL(jiterpreter_eliminate_null_checks, "jiterpreter-eliminate-null-checks", TRUE, "Attempt to eliminate redundant null checks in traces")
// When compiling a jit_call wrapper, bypass sharedvt wrappers if possible by inlining their
// logic into the compiled wrapper and calling the target AOTed function with native call convention
DEFINE_BOOL(jiterpreter_direct_jit_call, "jiterpreter-direct-jit-calls", TRUE, "Bypass gsharedvt wrappers when compiling JIT call wrappers")
Expand Down
5 changes: 4 additions & 1 deletion src/mono/wasm/runtime/jiterpreter-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ export const counters = {
jitCallsCompiled: 0,
directJitCallsCompiled: 0,
failures: 0,
bytesGenerated: 0
bytesGenerated: 0,
nullChecksEliminated: 0,
};

export const _now = (globalThis.performance && globalThis.performance.now)
Expand Down Expand Up @@ -946,6 +947,7 @@ export type JiterpreterOptions = {
useConstants: boolean;
// Unwrap gsharedvt wrappers when compiling jitcalls if possible
directJitCalls: boolean;
eliminateNullChecks: boolean;
minimumTraceLength: number;
minimumTraceHitCount: number;
jitCallHitCount: number;
Expand All @@ -969,6 +971,7 @@ const optionNames : { [jsName: string] : string } = {
"countBailouts": "jiterpreter-count-bailouts",
"dumpTraces": "jiterpreter-dump-traces",
"useConstants": "jiterpreter-use-constants",
"eliminateNullChecks": "jiterpreter-eliminate-null-checks",
"directJitCalls": "jiterpreter-direct-jit-calls",
"minimumTraceLength": "jiterpreter-minimum-trace-length",
"minimumTraceHitCount": "jiterpreter-minimum-trace-hit-count",
Expand Down
Loading

0 comments on commit 2b70123

Please sign in to comment.