diff options
-rw-r--r-- | mono/mini/interp/interp.c | 34 | ||||
-rw-r--r-- | mono/mini/interp/mintops.def | 18 | ||||
-rw-r--r-- | mono/mini/interp/transform.c | 27 |
3 files changed, 43 insertions, 36 deletions
diff --git a/mono/mini/interp/interp.c b/mono/mini/interp/interp.c index fdc1febec68..e180f4ff6a9 100644 --- a/mono/mini/interp/interp.c +++ b/mono/mini/interp/interp.c @@ -3396,28 +3396,40 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st } MINT_IN_BREAK; } - MINT_IN_CASE(MINT_LDIND_I1) + MINT_IN_CASE(MINT_LDIND_I1_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; sp[-1].data.i = *(gint8*)sp[-1].data.p; MINT_IN_BREAK; - MINT_IN_CASE(MINT_LDIND_U1) + MINT_IN_CASE(MINT_LDIND_U1_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; sp[-1].data.i = *(guint8*)sp[-1].data.p; MINT_IN_BREAK; - MINT_IN_CASE(MINT_LDIND_I2) + MINT_IN_CASE(MINT_LDIND_I2_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; sp[-1].data.i = *(gint16*)sp[-1].data.p; MINT_IN_BREAK; - MINT_IN_CASE(MINT_LDIND_U2) + MINT_IN_CASE(MINT_LDIND_U2_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; sp[-1].data.i = *(guint16*)sp[-1].data.p; MINT_IN_BREAK; - MINT_IN_CASE(MINT_LDIND_I4) /* Fall through */ - MINT_IN_CASE(MINT_LDIND_U4) + MINT_IN_CASE(MINT_LDIND_I4_CHECK) /* Fall through */ + MINT_IN_CASE(MINT_LDIND_U4_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; sp[-1].data.i = *(gint32*)sp[-1].data.p; MINT_IN_BREAK; - MINT_IN_CASE(MINT_LDIND_I8) + MINT_IN_CASE(MINT_LDIND_I8_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; /* memmove handles unaligned case */ memmove (&sp [-1].data.l, sp [-1].data.p, sizeof (gint64)); @@ -3428,11 +3440,15 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st ip += 2; MINT_IN_BREAK; } - MINT_IN_CASE(MINT_LDIND_R4) + MINT_IN_CASE(MINT_LDIND_R4_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; sp[-1].data.f = *(gfloat*)sp[-1].data.p; MINT_IN_BREAK; - MINT_IN_CASE(MINT_LDIND_R8) + MINT_IN_CASE(MINT_LDIND_R8_CHECK) + if (!sp[-1].data.p) + THROW_EX (mono_get_exception_null_reference (), ip); ++ip; sp[-1].data.f = *(gdouble*)sp[-1].data.p; MINT_IN_BREAK; diff --git a/mono/mini/interp/mintops.def b/mono/mini/interp/mintops.def index 38e51648850..78f1c8563d0 100644 --- a/mono/mini/interp/mintops.def +++ b/mono/mini/interp/mintops.def @@ -148,16 +148,16 @@ OPDEF(MINT_STLOC_NP_O, "stloc.np.o", 2, MintOpUShortInt) OPDEF(MINT_LDLOCA_S, "ldloca.s", 2, MintOpUShortInt) -OPDEF(MINT_LDIND_I1, "ldind.i1", 1, MintOpNoArgs) -OPDEF(MINT_LDIND_U1, "ldind.u1", 1, MintOpNoArgs) -OPDEF(MINT_LDIND_I2, "ldind.i2", 1, MintOpNoArgs) -OPDEF(MINT_LDIND_U2, "ldind.u2", 1, MintOpNoArgs) -OPDEF(MINT_LDIND_I4, "ldind.i4", 1, MintOpNoArgs) -OPDEF(MINT_LDIND_U4, "ldind.u4", 1, MintOpNoArgs) -OPDEF(MINT_LDIND_I8, "ldind.i8", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_I1_CHECK, "ldind.i1.check", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_U1_CHECK, "ldind.u1.check", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_I2_CHECK, "ldind.i2.check", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_U2_CHECK, "ldind.u2.check", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_I4_CHECK, "ldind.i4.check", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_U4_CHECK, "ldind.u4.check", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_I8_CHECK, "ldind.i8.check", 1, MintOpNoArgs) OPDEF(MINT_LDIND_I, "ldind.i", 2, MintOpUShortInt) -OPDEF(MINT_LDIND_R4, "ldind.r4", 1, MintOpNoArgs) -OPDEF(MINT_LDIND_R8, "ldind.r8", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_R4_CHECK, "ldind.r4.check", 1, MintOpNoArgs) +OPDEF(MINT_LDIND_R8_CHECK, "ldind.r8.check", 1, MintOpNoArgs) OPDEF(MINT_LDIND_REF, "ldind.ref", 1, MintOpNoArgs) OPDEF(MINT_STIND_I1, "stind.i1", 1, MintOpNoArgs) OPDEF(MINT_STIND_I2, "stind.i2", 1, MintOpNoArgs) diff --git a/mono/mini/interp/transform.c b/mono/mini/interp/transform.c index 66c5b880aeb..948dbfac1bf 100644 --- a/mono/mini/interp/transform.c +++ b/mono/mini/interp/transform.c @@ -2624,50 +2624,43 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, unsig } case CEE_LDIND_I1: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_I1); + SIMPLE_OP (td, MINT_LDIND_I1_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I4); BARRIER_IF_VOLATILE (td); break; case CEE_LDIND_U1: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_U1); + SIMPLE_OP (td, MINT_LDIND_U1_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I4); BARRIER_IF_VOLATILE (td); break; case CEE_LDIND_I2: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_I2); + SIMPLE_OP (td, MINT_LDIND_I2_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I4); BARRIER_IF_VOLATILE (td); break; case CEE_LDIND_U2: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_U2); + SIMPLE_OP (td, MINT_LDIND_U2_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I4); BARRIER_IF_VOLATILE (td); break; case CEE_LDIND_I4: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_I4); + SIMPLE_OP (td, MINT_LDIND_I4_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I4); BARRIER_IF_VOLATILE (td); break; case CEE_LDIND_U4: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_U4); + SIMPLE_OP (td, MINT_LDIND_U4_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I4); BARRIER_IF_VOLATILE (td); break; case CEE_LDIND_I8: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_I8); + SIMPLE_OP (td, MINT_LDIND_I8_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_I8); BARRIER_IF_VOLATILE (td); break; @@ -2681,15 +2674,13 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, unsig break; case CEE_LDIND_R4: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_R4); + SIMPLE_OP (td, MINT_LDIND_R4_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_R8); BARRIER_IF_VOLATILE (td); break; case CEE_LDIND_R8: CHECK_STACK (td, 1); - ADD_CODE (td, MINT_CKNULL); - SIMPLE_OP (td, MINT_LDIND_R8); + SIMPLE_OP (td, MINT_LDIND_R8_CHECK); SET_SIMPLE_TYPE(td->sp - 1, STACK_TYPE_R8); BARRIER_IF_VOLATILE (td); break; |