[interp] Possible code size savings via goto instead of macros. (mono/mono#16531)
authorJay Krell <jaykrell@microsoft.com>
Wed, 28 Aug 2019 16:59:11 +0000 (09:59 -0700)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Wed, 28 Aug 2019 16:59:11 +0000 (12:59 -0400)
[interp] Possible code size savings via goto instead of macros.

Possibly the compilers do this already.

Commit migrated from https://github.com/mono/mono/commit/a0ba2cbce52dd312fb34a39d366dde5b4a878fe3

src/mono/mono/mini/interp/interp.c

index 605bc0d..99953d8 100644 (file)
@@ -299,7 +299,7 @@ ves_real_abort (int line, MonoMethod *mh,
 #define ves_abort() \
        do {\
                ves_real_abort(__LINE__, frame->imethod->method, ip, frame->stack, sp); \
-               THROW_EX (mono_get_exception_execution_engine (NULL), ip); \
+               goto abort_label; \
        } while (0);
 
 static InterpMethod*
@@ -927,13 +927,9 @@ interp_throw (ThreadContext *context, MonoException *ex, InterpFrame *frame, con
 
 #define THROW_EX(exception,ex_ip) THROW_EX_GENERAL ((exception), (ex_ip), FALSE)
 
-#define THROW_EX_OVF(ip) THROW_EX (mono_get_exception_overflow (), ip)
-
-#define THROW_EX_DIV_ZERO(ip) THROW_EX (mono_get_exception_divide_by_zero (), ip)
-
 #define NULL_CHECK(o) do { \
        if (G_UNLIKELY (!(o))) \
-               THROW_EX (mono_get_exception_null_reference (), ip); \
+               goto null_label; \
        } while (0)
 
 #define EXCEPTION_CHECKPOINT   \
@@ -2878,7 +2874,7 @@ static int opcode_counts[512];
                if (G_UNLIKELY (!(vtable)->initialized)) { \
                        mono_runtime_class_init_full ((vtable), error); \
                        if (!is_ok (error)) \
-                               THROW_EX (mono_error_convert_to_exception (error), ip); \
+                               goto throw_error_label; \
                } \
        } while (0);
 
@@ -4300,16 +4296,16 @@ main_loop:
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_DIV_I4)
                        if (sp [-1].data.i == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        if (sp [-1].data.i == (-1) && sp [-2].data.i == G_MININT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(i, /);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_DIV_I8)
                        if (sp [-1].data.l == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        if (sp [-1].data.l == (-1) && sp [-2].data.l == G_MININT64)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(l, /);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_DIV_R4)
@@ -4325,26 +4321,26 @@ main_loop:
        ++ip;
                MINT_IN_CASE(MINT_DIV_UN_I4)
                        if (sp [-1].data.i == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        BINOP_CAST(i, /, guint32);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_DIV_UN_I8)
                        if (sp [-1].data.l == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        BINOP_CAST(l, /, guint64);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_REM_I4)
                        if (sp [-1].data.i == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        if (sp [-1].data.i == (-1) && sp [-2].data.i == G_MININT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(i, %);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_REM_I8)
                        if (sp [-1].data.l == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        if (sp [-1].data.l == (-1) && sp [-2].data.l == G_MININT64)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(l, %);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_REM_R4)
@@ -4361,12 +4357,12 @@ main_loop:
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_REM_UN_I4)
                        if (sp [-1].data.i == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        BINOP_CAST(i, %, guint32);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_REM_UN_I8)
                        if (sp [-1].data.l == 0)
-                               THROW_EX_DIV_ZERO (ip);
+                               goto div_zero_label;
                        BINOP_CAST(l, %, guint64);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_AND_I4)
@@ -4668,7 +4664,7 @@ main_loop:
                        sp -= param_count;
                        sp->data.o = ves_array_create (frame->imethod->domain, newobj_class, param_count, sp, error);
                        if (!is_ok (error))
-                               THROW_EX (mono_error_convert_to_exception (error), ip);
+                               goto throw_error_label;
 
                        ++sp;
                        ip += 3;
@@ -4695,7 +4691,7 @@ main_loop:
                        frame_objref (frame) = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
                        if (G_UNLIKELY (!frame_objref (frame))) {
                                mono_error_set_out_of_memory (error, "Could not allocate %i bytes", m_class_get_instance_size (vtable->klass));
-                               THROW_EX (mono_error_convert_to_exception (error), ip);
+                               goto throw_error_label;
                        }
 
                        sp [0].data.o = frame_objref (frame);
@@ -4863,7 +4859,7 @@ main_loop:
                                        if (isinst_instr)
                                                sp [-1].data.p = NULL;
                                        else
-                                               THROW_EX (mono_get_exception_invalid_cast (), ip);
+                                               goto invalid_cast_label;
                                }
                        }
                        ip += 2;
@@ -4881,7 +4877,7 @@ main_loop:
                                        if (isinst_instr)
                                                sp [-1].data.p = NULL;
                                        else
-                                               THROW_EX (mono_get_exception_invalid_cast (), ip);
+                                               goto invalid_cast_label;
                                }
                        }
                        ip += 2;
@@ -4897,7 +4893,7 @@ main_loop:
                                        if (isinst_instr)
                                                sp [-1].data.p = NULL;
                                        else
-                                               THROW_EX (mono_get_exception_invalid_cast (), ip);
+                                               goto invalid_cast_label;
                                }
                        }
                        ip += 2;
@@ -4917,7 +4913,7 @@ main_loop:
                        MonoClass* const c = (MonoClass*)frame->imethod->data_items[*(guint16 *)(ip + 1)];
 
                        if (!(m_class_get_rank (o->vtable->klass) == 0 && m_class_get_element_class (o->vtable->klass) == m_class_get_element_class (c)))
-                               THROW_EX (mono_get_exception_invalid_cast (), ip);
+                               goto invalid_cast_label;
 
                        sp [-1].data.p = mono_object_unbox_internal (o);
                        ip += 2;
@@ -5267,65 +5263,65 @@ main_loop:
                }
                MINT_IN_CASE(MINT_CONV_OVF_I4_UN_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint32)sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U8_I4)
                        if (sp [-1].data.i < 0)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.l = sp [-1].data.i;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U8_I8)
                        if (sp [-1].data.l < 0)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I8_U8)
                        if ((guint64) sp [-1].data.l > G_MAXINT64)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U8_R4)
                        if (sp [-1].data.f_r4 < 0 || sp [-1].data.f_r4 > G_MAXUINT64 || isnan (sp [-1].data.f_r4))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.l = (guint64)sp [-1].data.f_r4;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U8_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT64 || isnan (sp [-1].data.f))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.l = (guint64)sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I8_UN_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT64)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.l = (gint64)sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I8_UN_R4)
                        if (sp [-1].data.f_r4 < 0 || sp [-1].data.f_r4 > G_MAXINT64)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.l = (gint64)sp [-1].data.f_r4;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I8_R4)
                        if (sp [-1].data.f_r4 < G_MININT64 || sp [-1].data.f_r4 > G_MAXINT64 || isnan (sp [-1].data.f_r4))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.l = (gint64)sp [-1].data.f_r4;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I8_R8)
                        if (sp [-1].data.f < G_MININT64 || sp [-1].data.f > G_MAXINT64 || isnan (sp [-1].data.f))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.l = (gint64)sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I4_UN_I8)
                        if ((guint64)sp [-1].data.l > G_MAXINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint32)sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
@@ -5348,7 +5344,7 @@ main_loop:
                        MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items[*(guint16 *)(ip + 1)];
                        sp [-1].data.o = (MonoObject*) mono_array_new_specific_checked (vtable, sp [-1].data.i, error);
                        if (!is_ok (error)) {
-                               THROW_EX (mono_error_convert_to_exception (error), ip);
+                               goto throw_error_label;
                        }
                        mono_error_cleanup (error); /* FIXME: don't swallow the error */
                        ip += 2;
@@ -5614,155 +5610,155 @@ main_loop:
                }
                MINT_IN_CASE(MINT_CONV_OVF_I4_U4)
                        if (sp [-1].data.i < 0)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I4_I8)
                        if (sp [-1].data.l < G_MININT32 || sp [-1].data.l > G_MAXINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint32) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I4_U8)
                        if (sp [-1].data.l < 0 || sp [-1].data.l > G_MAXINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint32) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I4_R4)
                        if (sp [-1].data.f_r4 < G_MININT32 || sp [-1].data.f_r4 > G_MAXINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint32) sp [-1].data.f_r4;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I4_R8)
                        if (sp [-1].data.f < G_MININT32 || sp [-1].data.f > G_MAXINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint32) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U4_I4)
                        if (sp [-1].data.i < 0)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U4_I8)
                        if (sp [-1].data.l < 0 || sp [-1].data.l > G_MAXUINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (guint32) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U4_R4)
                        if (sp [-1].data.f_r4 < 0 || sp [-1].data.f_r4 > G_MAXUINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (guint32) sp [-1].data.f_r4;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U4_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT32)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (guint32) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I2_I4)
                        if (sp [-1].data.i < G_MININT16 || sp [-1].data.i > G_MAXINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I2_U4)
                        if (sp [-1].data.i < 0 || sp [-1].data.i > G_MAXINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I2_I8)
                        if (sp [-1].data.l < G_MININT16 || sp [-1].data.l > G_MAXINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint16) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I2_U8)
                        if (sp [-1].data.l < 0 || sp [-1].data.l > G_MAXINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint16) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I2_R8)
                        if (sp [-1].data.f < G_MININT16 || sp [-1].data.f > G_MAXINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint16) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I2_UN_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint16) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U2_I4)
                        if (sp [-1].data.i < 0 || sp [-1].data.i > G_MAXUINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U2_I8)
                        if (sp [-1].data.l < 0 || sp [-1].data.l > G_MAXUINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (guint16) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U2_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT16)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (guint16) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I1_I4)
                        if (sp [-1].data.i < G_MININT8 || sp [-1].data.i > G_MAXINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I1_U4)
                        if (sp [-1].data.i < 0 || sp [-1].data.i > G_MAXINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I1_I8)
                        if (sp [-1].data.l < G_MININT8 || sp [-1].data.l > G_MAXINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint8) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I1_U8)
                        if (sp [-1].data.l < 0 || sp [-1].data.l > G_MAXINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint8) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I1_R8)
                        if (sp [-1].data.f < G_MININT8 || sp [-1].data.f > G_MAXINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint8) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_I1_UN_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (gint8) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U1_I4)
                        if (sp [-1].data.i < 0 || sp [-1].data.i > G_MAXUINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U1_I8)
                        if (sp [-1].data.l < 0 || sp [-1].data.l > G_MAXUINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (guint8) sp [-1].data.l;
                        ++ip;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U1_R8)
                        if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT8)
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        sp [-1].data.i = (guint8) sp [-1].data.f;
                        ++ip;
                        MINT_IN_BREAK;
@@ -5805,7 +5801,7 @@ main_loop:
 
                        MonoClass* const c = (MonoClass*)frame->imethod->data_items [*(guint16 *)(ip + 1)];
                        if (c != tref->klass)
-                               THROW_EX (mono_get_exception_invalid_cast (), ip);
+                               goto invalid_cast_label;
 
                        vt_sp -= ALIGN_TO (sizeof (MonoTypedRef), MINT_VT_ALIGNMENT);
 
@@ -5822,62 +5818,62 @@ main_loop:
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_ADD_OVF_I4)
                        if (CHECK_ADD_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(i, +);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_ADD_OVF_I8)
                        if (CHECK_ADD_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(l, +);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_ADD_OVF_UN_I4)
                        if (CHECK_ADD_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP_CAST(i, +, guint32);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_ADD_OVF_UN_I8)
                        if (CHECK_ADD_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP_CAST(l, +, guint64);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_MUL_OVF_I4)
                        if (CHECK_MUL_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(i, *);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_MUL_OVF_I8)
                        if (CHECK_MUL_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(l, *);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_MUL_OVF_UN_I4)
                        if (CHECK_MUL_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP_CAST(i, *, guint32);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_MUL_OVF_UN_I8)
                        if (CHECK_MUL_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP_CAST(l, *, guint64);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_SUB_OVF_I4)
                        if (CHECK_SUB_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(i, -);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_SUB_OVF_I8)
                        if (CHECK_SUB_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP(l, -);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_SUB_OVF_UN_I4)
                        if (CHECK_SUB_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP_CAST(i, -, guint32);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_SUB_OVF_UN_I8)
                        if (CHECK_SUB_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX_OVF (ip);
+                               goto overflow_label;
                        BINOP_CAST(l, -, guint64);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_START_ABORT_PROT)
@@ -6435,7 +6431,7 @@ main_loop:
                }
                MINT_IN_CASE(MINT_LOCALLOC) {
                        if (sp != frame->stack + 1) /*FIX?*/
-                               THROW_EX (mono_get_exception_execution_engine (NULL), ip);
+                               goto abort_label;
 
                        int len = sp [-1].data.i;
                        sp [-1].data.p = alloca (len);
@@ -6590,6 +6586,18 @@ main_loop:
 
        g_assert_not_reached ();
 
+abort_label:
+       THROW_EX (mono_get_exception_execution_engine (NULL), ip);
+null_label:
+       THROW_EX (mono_get_exception_null_reference (), ip);
+div_zero_label:
+       THROW_EX (mono_get_exception_divide_by_zero (), ip);
+overflow_label:
+       THROW_EX (mono_get_exception_overflow (), ip);
+throw_error_label:
+       THROW_EX (mono_error_convert_to_exception (error), ip);
+invalid_cast_label:
+       THROW_EX (mono_get_exception_invalid_cast (), ip);
 resume:
        g_assert (context->has_resume_state);