Skip to content

Commit

Permalink
Introduce WASM JITs for interpreter opcodes, do_jit_call, and interp_…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
kg authored Nov 15, 2022
1 parent f652776 commit ce58915
Show file tree
Hide file tree
Showing 32 changed files with 8,808 additions and 23 deletions.
3 changes: 2 additions & 1 deletion src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ set(interp_sources
interp/mintops.c
interp/transform.c
interp/tiering.h
interp/tiering.c)
interp/tiering.c
interp/jiterpreter.c)
set(interp_stub_sources
interp-stubs.c)

Expand Down
7 changes: 7 additions & 0 deletions src/mono/mono/mini/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
#include "mini-runtime.h"
#include "interp/interp.h"

#if HOST_BROWSER
#include "interp/jiterpreter.h"
#endif

#include <string.h>
#include <ctype.h>
#include <locale.h>
Expand Down Expand Up @@ -1843,6 +1847,9 @@ mono_jit_parse_options (int argc, char * argv[])
} else if (strncmp (argv [i], "--profile=", 10) == 0) {
mini_add_profiler_argument (argv [i] + 10);
} else if (argv [i][0] == '-' && argv [i][1] == '-' && mini_parse_debug_option (argv [i] + 2)) {
#if HOST_BROWSER
} else if (argv [i][0] == '-' && argv [i][1] == '-' && mono_jiterp_parse_option (argv [i] + 2)) {
#endif
} else {
fprintf (stderr, "Unsupported command line option: '%s'\n", argv [i]);
exit (1);
Expand Down
37 changes: 37 additions & 0 deletions src/mono/mono/mini/interp/interp-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,43 @@ mono_interp_jit_call_supported (MonoMethod *method, MonoMethodSignature *sig);
void
mono_interp_error_cleanup (MonoError *error);

gboolean
mono_interp_is_method_multicastdelegate_invoke (MonoMethod *method);

MONO_NEVER_INLINE void
mono_interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args);

#if HOST_BROWSER

gboolean
mono_jiterp_isinst (MonoObject* object, MonoClass* klass);

void
mono_jiterp_check_pending_unwind (ThreadContext *context);

void *
mono_jiterp_get_context (void);

int
mono_jiterp_overflow_check_i4 (gint32 lhs, gint32 rhs, int opcode);

int
mono_jiterp_overflow_check_u4 (guint32 lhs, guint32 rhs, int opcode);

void
mono_jiterp_ld_delegate_method_ptr (gpointer *destination, MonoDelegate **source);

int
mono_jiterp_stackval_to_data (MonoType *type, stackval *val, void *data);

int
mono_jiterp_stackval_from_data (MonoType *type, stackval *result, const void *data);

gpointer
mono_jiterp_frame_data_allocator_alloc (FrameDataAllocator *stack, InterpFrame *frame, int size);

#endif

static inline int
mint_type(MonoType *type)
{
Expand Down
Loading

0 comments on commit ce58915

Please sign in to comment.