From 3f7ee53b8e016240759ac428d5f537252fe4355b Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Sun, 15 Sep 2019 12:26:41 -0700 Subject: [PATCH] [interp] Speed up passing this parameter. (mono/mono#16846) Commit migrated from https://github.com/mono/mono/commit/304f3add20dcdb32a3c4c095779efba3a8f5bca1 --- src/mono/mono/mini/interp/interp.c | 7 +++++++ src/mono/mono/mini/interp/mintops.def | 1 + src/mono/mono/mini/interp/transform.c | 9 +++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 05b23a9..22c5801 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -6216,6 +6216,11 @@ main_loop: sp->data.datamem = (argtype) frame->stack_args [ip [1]].data.datamem; \ ip += 2; \ ++sp; + +#define LDARGn(datamem, argtype, n) \ + sp->data.datamem = (argtype) frame->stack_args [n].data.datamem; \ + ++ip; \ + ++sp; MINT_IN_CASE(MINT_LDARG_I1) LDARG(i, gint8); MINT_IN_BREAK; MINT_IN_CASE(MINT_LDARG_U1) LDARG(i, guint8); MINT_IN_BREAK; @@ -6228,6 +6233,8 @@ main_loop: MINT_IN_CASE(MINT_LDARG_O) LDARG(p, gpointer); MINT_IN_BREAK; MINT_IN_CASE(MINT_LDARG_P) LDARG(p, gpointer); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LDARG_P0) LDARGn(p, gpointer, 0); MINT_IN_BREAK; + MINT_IN_CASE(MINT_LDARG_VT) { sp->data.p = vt_sp; int const i32 = READ32 (ip + 2); diff --git a/src/mono/mono/mini/interp/mintops.def b/src/mono/mono/mini/interp/mintops.def index 2a4cac2..6e5844a 100644 --- a/src/mono/mono/mini/interp/mintops.def +++ b/src/mono/mono/mini/interp/mintops.def @@ -55,6 +55,7 @@ OPDEF(MINT_LDARG_R4, "ldarg.r4", 2, Pop0, Push1, MintOpUShortInt) OPDEF(MINT_LDARG_R8, "ldarg.r8", 2, Pop0, Push1, MintOpUShortInt) OPDEF(MINT_LDARG_O, "ldarg.o", 2, Pop0, Push1, MintOpUShortInt) OPDEF(MINT_LDARG_P, "ldarg.p", 2, Pop0, Push1, MintOpUShortInt) +OPDEF(MINT_LDARG_P0, "ldarg.p0", 1, Pop0, Push1, MintOpNoArgs) OPDEF(MINT_LDARG_VT, "ldarg.vt", 4, Pop0, Push1, MintOpShortAndInt) OPDEF(MINT_STARG_I1, "starg.i1", 2, Pop1, Push0, MintOpUShortInt) diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index ae95eda..2dcc70f 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -686,8 +686,7 @@ load_arg(TransformData *td, int n) if (hasthis && n == 0) { mt = MINT_TYPE_P; - interp_add_ins (td, MINT_LDARG_P); - td->last_ins->data [0] = 0; + interp_add_ins (td, MINT_LDARG_P0); klass = NULL; } else { PUSH_VT (td, size); @@ -696,11 +695,9 @@ load_arg(TransformData *td, int n) WRITE32_INS (td->last_ins, 1, &size); } } else { - if (hasthis && n == 0) { + if ((hasthis || mt == MINT_TYPE_P) && n == 0) { mt = MINT_TYPE_P; - interp_add_ins (td, MINT_LDARG_P); - td->last_ins->data [0] = n; - klass = NULL; + interp_add_ins (td, MINT_LDARG_P0); } else { interp_add_ins (td, MINT_LDARG_I1 + (mt - MINT_TYPE_I1)); td->last_ins->data [0] = n; -- 2.7.4