Skip to content

Commit ce58915

Browse files
authored
Introduce WASM JITs for interpreter opcodes, do_jit_call, and interp_entry wrappers (#76477)
This PR introduces a "jiterpreter" just-in-time WASM compiler for interpreter opcodes along with a set of specialized WASM JIT compilers to improve the performance of interp_entry and do_jit_call. The result is significantly improved performance for pure-interpreter workloads along with measurable speedups for interp->aot and aot->interp transitions in mixed mode AOT applications. In this commit it is disabled by default, with the exception of an optimization to use wasm exception handling if available for do_jit_call (as a replacement for mono_llvm_catch_cpp_exception). It will be enabled by default in a future PR.
1 parent f652776 commit ce58915

32 files changed

+8808
-23
lines changed

src/mono/mono/mini/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ set(interp_sources
284284
interp/mintops.c
285285
interp/transform.c
286286
interp/tiering.h
287-
interp/tiering.c)
287+
interp/tiering.c
288+
interp/jiterpreter.c)
288289
set(interp_stub_sources
289290
interp-stubs.c)
290291

src/mono/mono/mini/driver.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
#include "mini-runtime.h"
6363
#include "interp/interp.h"
6464

65+
#if HOST_BROWSER
66+
#include "interp/jiterpreter.h"
67+
#endif
68+
6569
#include <string.h>
6670
#include <ctype.h>
6771
#include <locale.h>
@@ -1843,6 +1847,9 @@ mono_jit_parse_options (int argc, char * argv[])
18431847
} else if (strncmp (argv [i], "--profile=", 10) == 0) {
18441848
mini_add_profiler_argument (argv [i] + 10);
18451849
} else if (argv [i][0] == '-' && argv [i][1] == '-' && mini_parse_debug_option (argv [i] + 2)) {
1850+
#if HOST_BROWSER
1851+
} else if (argv [i][0] == '-' && argv [i][1] == '-' && mono_jiterp_parse_option (argv [i] + 2)) {
1852+
#endif
18461853
} else {
18471854
fprintf (stderr, "Unsupported command line option: '%s'\n", argv [i]);
18481855
exit (1);

src/mono/mono/mini/interp/interp-internals.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,43 @@ mono_interp_jit_call_supported (MonoMethod *method, MonoMethodSignature *sig);
298298
void
299299
mono_interp_error_cleanup (MonoError *error);
300300

301+
gboolean
302+
mono_interp_is_method_multicastdelegate_invoke (MonoMethod *method);
303+
304+
MONO_NEVER_INLINE void
305+
mono_interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args);
306+
307+
#if HOST_BROWSER
308+
309+
gboolean
310+
mono_jiterp_isinst (MonoObject* object, MonoClass* klass);
311+
312+
void
313+
mono_jiterp_check_pending_unwind (ThreadContext *context);
314+
315+
void *
316+
mono_jiterp_get_context (void);
317+
318+
int
319+
mono_jiterp_overflow_check_i4 (gint32 lhs, gint32 rhs, int opcode);
320+
321+
int
322+
mono_jiterp_overflow_check_u4 (guint32 lhs, guint32 rhs, int opcode);
323+
324+
void
325+
mono_jiterp_ld_delegate_method_ptr (gpointer *destination, MonoDelegate **source);
326+
327+
int
328+
mono_jiterp_stackval_to_data (MonoType *type, stackval *val, void *data);
329+
330+
int
331+
mono_jiterp_stackval_from_data (MonoType *type, stackval *result, const void *data);
332+
333+
gpointer
334+
mono_jiterp_frame_data_allocator_alloc (FrameDataAllocator *stack, InterpFrame *frame, int size);
335+
336+
#endif
337+
301338
static inline int
302339
mint_type(MonoType *type)
303340
{

0 commit comments

Comments
 (0)