Skip to content

Commit

Permalink
Add caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
vargaz committed Jun 15, 2021
1 parent bda1a90 commit 5e0f16b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/mono/mono/mini/interp/interp-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct InterpMethod {
MonoType *rtype;
MonoType **param_types;
MonoJitInfo *jinfo;
MonoFtnDesc *ftndesc;

guint32 locals_size;
guint32 alloca_size;
Expand Down
32 changes: 18 additions & 14 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1675,8 +1675,13 @@ ftnptr_to_imethod (gpointer addr)
g_assert (ftndesc);
g_assert (ftndesc->method);

imethod = mono_interp_get_imethod (ftndesc->method, error);
mono_error_assert_ok (error);
imethod = ftndesc->interp_method;
if (!imethod) {
imethod = mono_interp_get_imethod (ftndesc->method, error);
mono_error_assert_ok (error);
mono_memory_barrier ();
ftndesc->interp_method = imethod;
}
} else {
/* Function pointers are represented by their InterpMethod */
imethod = (InterpMethod*)addr;
Expand All @@ -1690,8 +1695,13 @@ imethod_to_ftnptr (InterpMethod *imethod)
if (mono_llvm_only) {
ERROR_DECL (error);
/* Function pointers are represented by a MonoFtnDesc structure */
MonoFtnDesc *ftndesc = mini_llvmonly_load_method_ftndesc (imethod->method, FALSE, FALSE, error);
mono_error_assert_ok (error);
MonoFtnDesc *ftndesc = imethod->ftndesc;
if (!ftndesc) {
ftndesc = mini_llvmonly_load_method_ftndesc (imethod->method, FALSE, FALSE, error);
mono_error_assert_ok (error);
mono_memory_barrier ();
imethod->ftndesc = ftndesc;
}
return ftndesc;
} else {
return imethod;
Expand Down Expand Up @@ -6520,16 +6530,10 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
error_init_reuse (error);

MonoMethod *cmethod = LOCAL_VAR (ip [2], MonoMethod*);
if (mono_llvm_only) {
/* Function pointers are represented by a MonoFtnDesc structure */
MonoFtnDesc *ftndesc = mini_llvmonly_load_method_ftndesc (cmethod, FALSE, FALSE, error);
mono_error_assert_ok (error);
LOCAL_VAR (ip [1], gpointer) = ftndesc;
} else {
InterpMethod *m = mono_interp_get_imethod (cmethod, error);
mono_error_assert_ok (error);
LOCAL_VAR (ip [1], gpointer) = m;
}

InterpMethod *m = mono_interp_get_imethod (cmethod, error);
mono_error_assert_ok (error);
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (m);
ip += 3;
MINT_IN_BREAK;
}
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/mini/mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,9 @@ typedef struct
{
gpointer addr;
gpointer arg;
/* Might be null */
MonoMethod *method;
/* InterpMethod* */
gpointer interp_method;
} MonoFtnDesc;

typedef enum {
Expand Down

0 comments on commit 5e0f16b

Please sign in to comment.