Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[interp] Add a few super instructions #50361

Merged
merged 4 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3205,10 +3205,6 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
++ip;
mono_break ();
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDNULL)
LOCAL_VAR (ip [1], gpointer) = NULL;
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_INIT_ARGLIST) {
const guint16 *call_ip = frame->parent->state.ip - 6;
g_assert_checked (*call_ip == MINT_CALL_VARARG);
Expand Down Expand Up @@ -3266,6 +3262,10 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
LOCAL_VAR (ip [1], gint32) = READ32 (ip + 2);
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8_0)
LOCAL_VAR (ip [1], gint64) = 0;
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8)
LOCAL_VAR (ip [1], gint64) = READ64 (ip + 2);
ip += 6;
Expand Down Expand Up @@ -3624,6 +3624,12 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
MINT_IN_CASE(MINT_RET)
frame->retval [0] = LOCAL_VAR (ip [1], stackval);
goto exit_frame;
MINT_IN_CASE(MINT_RET_I4_IMM)
frame->retval [0].data.i = (gint16)ip [1];
goto exit_frame;
MINT_IN_CASE(MINT_RET_I8_IMM)
frame->retval [0].data.l = (gint16)ip [1];
goto exit_frame;
MINT_IN_CASE(MINT_RET_VOID)
goto exit_frame;
MINT_IN_CASE(MINT_RET_VT) {
Expand Down Expand Up @@ -4324,10 +4330,18 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) + 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) + (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD1_I8)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) + 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) + (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_I4)
BINOP(gint32, -);
MINT_IN_BREAK;
Expand Down Expand Up @@ -4491,6 +4505,30 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
MINT_IN_CASE(MINT_SHR_UN_I8)
SHIFTOP(guint64, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) << ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) << ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I4_IMM)
LOCAL_VAR (ip [1], guint32) = LOCAL_VAR (ip [2], guint32) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I8_IMM)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_I4)
LOCAL_VAR (ip [1], gint32) = - LOCAL_VAR (ip [2], gint32);
ip += 3;
Expand Down Expand Up @@ -4858,7 +4896,7 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_MARVIN_BLOCK) {
interp_intrins_marvin_block (LOCAL_VAR (ip [1], guint32*), LOCAL_VAR (ip [2], guint32*));
interp_intrins_marvin_block ((guint32*)(locals + ip [1]), (guint32*)(locals + ip [2]));
ip += 3;
MINT_IN_BREAK;
}
Expand Down Expand Up @@ -7184,7 +7222,7 @@ imethod_opcount_comparer (gconstpointer m1, gconstpointer m2)
static void
interp_print_method_counts (void)
{
MonoJitMemoryManager *jit_mm = jit_mm_for_method (method);
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();

jit_mm_lock (jit_mm);
imethods = (InterpMethod**) malloc (jit_mm->interp_code_hash.num_entries * sizeof (InterpMethod*));
Expand Down
22 changes: 19 additions & 3 deletions src/mono/mono/mini/interp/mintops.def
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ OPDEF(MINT_DEF, "def", 2, 1, 0, MintOpNoArgs)
OPDEF(MINT_DUMMY_USE, "dummy_use", 2, 0, 1, MintOpNoArgs)
OPDEF(MINT_BREAK, "break", 1, 0, 0, MintOpNoArgs)
OPDEF(MINT_BREAKPOINT, "breakpoint", 1, 0, 0, MintOpNoArgs)
OPDEF(MINT_LDNULL, "ldnull", 2, 1, 0, MintOpNoArgs)

OPDEF(MINT_RET, "ret", 2, 0, 1, MintOpNoArgs)
OPDEF(MINT_RET_VOID, "ret.void", 1, 0, 0, MintOpNoArgs)
Expand All @@ -33,11 +32,12 @@ OPDEF(MINT_LDC_I4_5, "ldc.i4.5", 2, 1, 0, MintOpNoArgs)
OPDEF(MINT_LDC_I4_6, "ldc.i4.6", 2, 1, 0, MintOpNoArgs)
OPDEF(MINT_LDC_I4_7, "ldc.i4.7", 2, 1, 0, MintOpNoArgs)
OPDEF(MINT_LDC_I4_8, "ldc.i4.8", 2, 1, 0, MintOpNoArgs)

OPDEF(MINT_LDC_I4_S, "ldc.i4.s", 3, 1, 0, MintOpShortInt)
OPDEF(MINT_LDC_I4, "ldc.i4", 4, 1, 0, MintOpInt)
OPDEF(MINT_LDC_I8, "ldc.i8", 6, 1, 0, MintOpLongInt)

OPDEF(MINT_LDC_I8_0, "ldc.i8.0", 2, 1, 0, MintOpNoArgs)
OPDEF(MINT_LDC_I8_S, "ldc.i8.s", 3, 1, 0, MintOpShortInt)
OPDEF(MINT_LDC_I8, "ldc.i8", 6, 1, 0, MintOpLongInt)

OPDEF(MINT_LDC_R4, "ldc.r4", 4, 1, 0, MintOpFloat)
OPDEF(MINT_LDC_R8, "ldc.r8", 6, 1, 0, MintOpDouble)
Expand Down Expand Up @@ -422,6 +422,7 @@ OPDEF(MINT_REM_R8, "rem.r8", 4, 1, 2, MintOpNoArgs)
OPDEF(MINT_REM_UN_I4, "rem.un.i4", 4, 1, 2, MintOpNoArgs)
OPDEF(MINT_REM_UN_I8, "rem.un.i8", 4, 1, 2, MintOpNoArgs)

// Shifts, keep in order with imm versions
OPDEF(MINT_SHR_UN_I4, "shr.un.i4", 4, 1, 2, MintOpNoArgs)
OPDEF(MINT_SHR_UN_I8, "shr.un.i8", 4, 1, 2, MintOpNoArgs)
OPDEF(MINT_SHL_I4, "shl.i4", 4, 1, 2, MintOpNoArgs)
Expand Down Expand Up @@ -595,6 +596,21 @@ OPDEF(MINT_CONV_OVF_U8_R8, "conv.ovf.u8.r8", 3, 1, 1, MintOpNoArgs)
OPDEF(MINT_CEQ0_I4, "ceq0.i4", 3, 1, 1, MintOpNoArgs)
/* unops end */

/* super instructions */
OPDEF(MINT_RET_I4_IMM, "ret.i4.imm", 2, 0, 0, MintOpShortInt)
OPDEF(MINT_RET_I8_IMM, "ret.i8.imm", 2, 0, 0, MintOpShortInt)

OPDEF(MINT_ADD_I4_IMM, "add.i4.imm", 4, 1, 1, MintOpShortInt)
OPDEF(MINT_ADD_I8_IMM, "add.i8.imm", 4, 1, 1, MintOpShortInt)

OPDEF(MINT_SHR_UN_I4_IMM, "shr.un.i4.imm", 4, 1, 1, MintOpShortInt)
OPDEF(MINT_SHR_UN_I8_IMM, "shr.un.i8.imm", 4, 1, 1, MintOpShortInt)
OPDEF(MINT_SHL_I4_IMM, "shl.i4.imm", 4, 1, 1, MintOpShortInt)
OPDEF(MINT_SHL_I8_IMM, "shl.i8.imm", 4, 1, 1, MintOpShortInt)
OPDEF(MINT_SHR_I4_IMM, "shr.i4.imm", 4, 1, 1, MintOpShortInt)
OPDEF(MINT_SHR_I8_IMM, "shr.i8.imm", 4, 1, 1, MintOpShortInt)


OPDEF(MINT_CKFINITE, "ckfinite", 3, 1, 1, MintOpNoArgs)
OPDEF(MINT_MKREFANY, "mkrefany", 4, 1, 1, MintOpClassToken)
OPDEF(MINT_REFANYTYPE, "refanytype", 3, 1, 1, MintOpNoArgs)
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/interp/mintops.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ typedef enum {
#define MINT_IS_CALL(op) ((op) >= MINT_CALL && (op) <= MINT_JIT_CALL)
#define MINT_IS_PATCHABLE_CALL(op) ((op) >= MINT_CALL && (op) <= MINT_VCALL)
#define MINT_IS_LDC_I4(op) ((op) >= MINT_LDC_I4_M1 && (op) <= MINT_LDC_I4)
#define MINT_IS_LDC_I8(op) ((op) >= MINT_LDC_I8_0 && (op) <= MINT_LDC_I8)
#define MINT_IS_UNOP(op) ((op) >= MINT_ADD1_I4 && (op) <= MINT_CEQ0_I4)
#define MINT_IS_BINOP(op) ((op) >= MINT_ADD_I4 && (op) <= MINT_CLT_UN_R8)
#define MINT_IS_BINOP_SHIFT(op) ((op) >= MINT_SHR_UN_I4 && (op) <= MINT_SHR_I8)
#define MINT_IS_LDFLD(op) ((op) >= MINT_LDFLD_I1 && (op) <= MINT_LDFLD_O)
#define MINT_IS_STFLD(op) ((op) >= MINT_STFLD_I1 && (op) <= MINT_STFLD_O)

Expand Down
Loading