[interp] Allow inlining. (#32574)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 21 Feb 2020 08:43:59 +0000 (03:43 -0500)
committerGitHub <noreply@github.com>
Fri, 21 Feb 2020 08:43:59 +0000 (10:43 +0200)
Implied extra stack use is probably ok now, and this wasn't generally the most problematic stack in the first place, albeit still somewhat worth optimizing.

Might want to leave this alone for now, at least not without testing against current iOS/Blazor.
There is much other mitigating change, but these *might* matter.

Co-authored-by: Jay Krell <jay.krell@cornell.edu>
src/mono/mono/mini/interp/interp.c

index 19719b4..06bd20f 100644 (file)
@@ -650,7 +650,7 @@ interp_pop_lmf (MonoLMFExt *ext)
        mono_pop_lmf (&ext->lmf);
 }
 
-static MONO_NEVER_INLINE InterpMethod*
+static InterpMethod*
 get_virtual_method (InterpMethod *imethod, MonoVTable *vtable)
 {
        MonoMethod *m = imethod->method;
@@ -774,7 +774,7 @@ alloc_method_table (MonoVTable *vtable, int offset)
        return table;
 }
 
-static MONO_NEVER_INLINE InterpMethod* // Inlining causes additional stack use in caller.
+static InterpMethod* // Inlining causes additional stack use in caller.
 get_virtual_method_fast (InterpMethod *imethod, MonoVTable *vtable, int offset)
 {
        gpointer *table;
@@ -1227,7 +1227,7 @@ ves_array_get (InterpFrame *frame, stackval *sp, stackval *retval, MonoMethodSig
        return NULL;
 }
 
-static MONO_NEVER_INLINE MonoException*
+static MonoException*
 ves_array_element_address (InterpFrame *frame, MonoClass *required_type, MonoArray *ao, stackval *sp, gboolean needs_typecheck)
 {
        MonoClass *ac = ((MonoObject *) ao)->vtable->klass;
@@ -2505,7 +2505,7 @@ do_transform_method (InterpFrame *frame, ThreadContext *context)
        return mono_error_convert_to_exception (error);
 }
 
-static MONO_NEVER_INLINE guchar*
+static guchar*
 copy_varargs_vtstack (MonoMethodSignature *csig, stackval *sp, guchar *vt_sp_start)
 {
        stackval *first_arg = sp - csig->param_count;
@@ -3065,7 +3065,7 @@ static long opcode_counts[MINT_LASTOP];
                } \
        } while (0);
 
-static MONO_NEVER_INLINE MonoObject*
+static MonoObject*
 mono_interp_new (MonoDomain* domain, MonoClass* klass)
 {
        ERROR_DECL (error);
@@ -3074,11 +3074,7 @@ mono_interp_new (MonoDomain* domain, MonoClass* klass)
        return object;
 }
 
-static
-#ifndef DISABLE_REMOTING
-MONO_NEVER_INLINE // To reduce stack.
-#endif
-void
+static void
 mono_interp_load_remote_field (
        InterpMethod* imethod,
        MonoObject* o,
@@ -3104,9 +3100,6 @@ mono_interp_load_remote_field (
 }
 
 static
-#ifndef DISABLE_REMOTING
-MONO_NEVER_INLINE // To reduce stack.
-#endif
 guchar* // Return new vt_sp instead of take-address.
 mono_interp_load_remote_field_vt (
        InterpMethod* imethod,
@@ -3137,7 +3130,7 @@ mono_interp_load_remote_field_vt (
        return vt_sp + ALIGN_TO (i32, MINT_VT_ALIGNMENT);
 }
 
-static MONO_NEVER_INLINE gboolean
+static gboolean
 mono_interp_isinst (MonoObject* object, MonoClass* klass)
 {
        ERROR_DECL (error);
@@ -3152,8 +3145,7 @@ mono_interp_isinst (MonoObject* object, MonoClass* klass)
        return isinst;
 }
 
-// This function is outlined to help save stack in its caller, on the premise
-// that it is relatively rarely called. This also lets it use alloca.
+// Do not inline use of alloca.
 static MONO_NEVER_INLINE void
 mono_interp_calli_nat_dynamic_pinvoke (
        // Parameters are sorted by name.
@@ -3190,9 +3182,7 @@ mono_interp_calli_nat_dynamic_pinvoke (
        interp_exec_method (child_frame, context, error);
 }
 
-// Leave is split into pieces in order to consume less stack,
-// but not have to change how exception handling macros access labels and locals.
-static MONO_NEVER_INLINE MonoException*
+static MonoException*
 mono_interp_leave (InterpFrame* child_frame)
 {
        stackval tmp_sp;
@@ -3206,7 +3196,7 @@ mono_interp_leave (InterpFrame* child_frame)
        return (MonoException*)tmp_sp.data.p;
 }
 
-static MONO_NEVER_INLINE void
+static void
 mono_interp_enum_hasflag (stackval* sp, MonoClass* klass)
 {
        guint64 a_val = 0, b_val = 0;
@@ -3216,7 +3206,7 @@ mono_interp_enum_hasflag (stackval* sp, MonoClass* klass)
        sp->data.i = (a_val & b_val) == b_val;
 }
 
-static MONO_NEVER_INLINE int
+static int
 mono_interp_box_nullable (InterpFrame* frame, const guint16* ip, stackval* sp, MonoError* error)
 {
        InterpMethod* const imethod = frame->imethod;
@@ -3233,7 +3223,7 @@ mono_interp_box_nullable (InterpFrame* frame, const guint16* ip, stackval* sp, M
        return pop_vt_sp ? ALIGN_TO (size, MINT_VT_ALIGNMENT) : 0;
 }
 
-static MONO_NEVER_INLINE int
+static int
 mono_interp_box_vt (InterpFrame* frame, const guint16* ip, stackval* sp)
 {
        InterpMethod* const imethod = frame->imethod;
@@ -3254,7 +3244,7 @@ mono_interp_box_vt (InterpFrame* frame, const guint16* ip, stackval* sp)
        return pop_vt_sp ? ALIGN_TO (size, MINT_VT_ALIGNMENT) : 0;
 }
 
-static MONO_NEVER_INLINE void
+static void
 mono_interp_box (InterpFrame* frame, const guint16* ip, stackval* sp)
 {
        MonoObject *o; // See the comment about GC safety.
@@ -3269,7 +3259,7 @@ mono_interp_box (InterpFrame* frame, const guint16* ip, stackval* sp)
        sp [-1 - offset].data.p = o;
 }
 
-static MONO_NEVER_INLINE int
+static int
 mono_interp_store_remote_field_vt (InterpFrame* frame, const guint16* ip, stackval* sp, MonoError* error)
 {
        InterpMethod* const imethod = frame->imethod;