[interp] Avoid declaring MonoError's in interp_exec_method_full (), it increases...
authorZoltan Varga <vargaz@gmail.com>
Tue, 9 Jul 2019 19:16:46 +0000 (15:16 -0400)
committerGitHub <noreply@github.com>
Tue, 9 Jul 2019 19:16:46 +0000 (15:16 -0400)
* [interp] Avoid declaring MonoError's in interp_exec_method_full (), it increases the native stack frame size because the optimizer can't seem to figure out live ranges.

* Remove some unused fields from InterpFrame.

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

src/mono/mono/mini/interp/interp-internals.h
src/mono/mono/mini/interp/interp.c

index 80fa33e..3947367 100644 (file)
@@ -131,10 +131,8 @@ struct _InterpFrame {
        char           *varargs;
        stackval       *stack_args; /* parent */
        stackval       *stack;
-       stackval       *sp; /* For GC stack marking */
        unsigned char  *locals;
        /* exception info */
-       unsigned char  invoke_trap;
        const unsigned short  *ip;
        MonoException     *ex;
 };
index 1ee52cc..5cc7ccf 100644 (file)
@@ -109,7 +109,6 @@ init_frame (InterpFrame *frame, InterpFrame *parent_frame, InterpMethod *rmethod
        frame->imethod = rmethod;
        frame->ex = NULL;
        frame->ip = NULL;
-       frame->invoke_trap = 0;
 }
 
 #define INIT_FRAME(frame,parent_frame,method_args,method_retval,domain,mono_method,error) do { \
@@ -117,7 +116,7 @@ init_frame (InterpFrame *frame, InterpFrame *parent_frame, InterpMethod *rmethod
        init_frame ((frame), (parent_frame), _rmethod, (method_args), (method_retval)); \
        } while (0)
 
-#define interp_exec_method(frame, context) interp_exec_method_full ((frame), (context), NULL)
+#define interp_exec_method(frame, context, error) interp_exec_method_full ((frame), (context), NULL, error)
 
 /*
  * List of classes whose methods will be executed by transitioning to JITted code.
@@ -131,7 +130,7 @@ static gboolean ss_enabled;
 
 static gboolean interp_init_done = FALSE;
 
-static void interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args);
+static void interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args, MonoError *error);
 static InterpMethod* lookup_method_pointer (gpointer addr);
 
 typedef void (*ICallMethod) (InterpFrame *frame);
@@ -287,7 +286,7 @@ get_context (void)
        return context;
 }
 
-static void
+static MONO_NEVER_INLINE void
 ves_real_abort (int line, MonoMethod *mh,
                const unsigned short *ip, stackval *stack, stackval *sp)
 {
@@ -452,7 +451,7 @@ interp_pop_lmf (MonoLMFExt *ext)
        mono_pop_lmf (&ext->lmf);
 }
 
-static InterpMethod*
+static MONO_NEVER_INLINE InterpMethod*
 get_virtual_method (InterpMethod *imethod, MonoObject *obj)
 {
        MonoMethod *m = imethod->method;
@@ -992,7 +991,7 @@ ves_array_calculate_index (MonoArray *ao, stackval *sp, InterpFrame *frame, gboo
        return pos;
 }
 
-static void
+static MONO_NEVER_INLINE void
 ves_array_set (InterpFrame *frame, stackval *sp, MonoMethodSignature *sig)
 {
        MonoObject *o = sp->data.o;
@@ -1735,10 +1734,7 @@ interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject
 
        INIT_FRAME (&frame, NULL, args, &result, domain, invoke_wrapper, error);
 
-       if (exc)
-               frame.invoke_trap = 1;
-
-       interp_exec_method (&frame, context);
+       interp_exec_method (&frame, context, error);
 
        if (frame.ex) {
                if (exc) {
@@ -1843,7 +1839,8 @@ interp_entry (InterpEntryData *data)
                break;
        }
 
-       interp_exec_method (&frame, context);
+       ERROR_DECL (error);
+       interp_exec_method (&frame, context, error);
 
        if (rmethod->needs_thread_attach)
                mono_threads_detach_coop (orig_domain, &attach_cookie);
@@ -2326,7 +2323,7 @@ do_transform_method (InterpFrame *frame, ThreadContext *context)
                interp_pop_lmf (&ext);
 }
 
-static void
+static MONO_NEVER_INLINE void
 copy_varargs_vtstack (MonoMethodSignature *csig, stackval *sp, unsigned char **vt_sp)
 {
        char *vt = *(char**)vt_sp;
@@ -2563,7 +2560,8 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
        /* Copy the args saved in the trampoline to the frame stack */
        mono_arch_get_native_call_context_args (ccontext, &frame, sig);
 
-       interp_exec_method (&frame, context);
+       ERROR_DECL (error);
+       interp_exec_method (&frame, context, error);
 
        if (rmethod->needs_thread_attach)
                mono_threads_detach_coop (orig_domain, &attach_cookie);
@@ -2881,9 +2879,11 @@ static int opcode_counts[512];
 /*
  * If EXIT_AT_FINALLY is not -1, exit after exiting the finally clause with that index.
  * If BASE_FRAME is not NULL, copy arguments/locals from BASE_FRAME.
+ * The ERROR argument is used to avoid declaring an error object for every interp frame, its not used
+ * to return error information.
  */
 static void 
-interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args)
+interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args, MonoError *error)
 {
        InterpFrame child_frame;
        GSList *finally_ips = NULL;
@@ -2900,7 +2900,6 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
        int i32;
        unsigned char *vt_sp;
        unsigned char *locals = NULL;
-       ERROR_DECL (error);
        MonoObject *o = NULL;
        MonoClass *c;
 #if USE_COMPUTED_GOTO
@@ -3167,7 +3166,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                                }
                        }
 
-                       interp_exec_method (&child_frame, context);
+                       interp_exec_method (&child_frame, context, error);
 
                        CHECK_RESUME_STATE (context);
 
@@ -3235,7 +3234,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                                child_frame.imethod = mono_interp_get_imethod (imethod->domain, m, error);
                                mono_error_cleanup (error); /* FIXME: don't swallow the error */
 
-                               interp_exec_method (&child_frame, context);
+                               interp_exec_method (&child_frame, context, error);
                        } else {
                                ves_pinvoke_method (&child_frame, csignature, (MonoFuncV) code, FALSE, context, save_last_error);
                        }
@@ -3282,7 +3281,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                                sp [0].data.p = unboxed;
                        }
 
-                       interp_exec_method (&child_frame, context);
+                       interp_exec_method (&child_frame, context, error);
 
                        CHECK_RESUME_STATE (context);
 
@@ -3316,7 +3315,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                        sp -= child_frame.imethod->param_count + child_frame.imethod->hasthis + num_varargs;
                        child_frame.stack_args = sp;
 
-                       interp_exec_method (&child_frame, context);
+                       interp_exec_method (&child_frame, context, error);
 
                        CHECK_RESUME_STATE (context);
 
@@ -3357,7 +3356,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                                }
                        }
 
-                       interp_exec_method (&child_frame, context);
+                       interp_exec_method (&child_frame, context, error);
 
                        CHECK_RESUME_STATE (context);
 
@@ -4404,7 +4403,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                                ip += 4;
                        }
 
-                       interp_exec_method (&child_frame, context);
+                       interp_exec_method (&child_frame, context, error);
 
                        CHECK_RESUME_STATE (context);
 
@@ -4481,7 +4480,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                                }
                        }
 
-                       interp_exec_method (&child_frame, context);
+                       interp_exec_method (&child_frame, context, error);
 
                        CHECK_RESUME_STATE (context);
 
@@ -6407,6 +6406,8 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
 
 exit_frame:
 
+       error_init_reuse (error);
+
        if (clause_args && clause_args->base_frame)
                memcpy (clause_args->base_frame->args, frame->args, imethod->alloca_size);
 
@@ -6463,8 +6464,6 @@ interp_parse_options (const char *options)
        }
 }
 
-typedef int (*TestMethod) (void);
-
 /*
  * interp_set_resume_state:
  *
@@ -6510,7 +6509,8 @@ interp_run_finally (StackFrameInfo *frame, int clause_index, gpointer handler_ip
        clause_args.end_at_ip = (guint16*) handler_ip_end;
        clause_args.exit_clause = clause_index;
 
-       interp_exec_method_full (iframe, context, &clause_args);
+       ERROR_DECL (error);
+       interp_exec_method_full (iframe, context, &clause_args, error);
        if (context->has_resume_state) {
                return TRUE;
        } else {
@@ -6550,7 +6550,8 @@ interp_run_filter (StackFrameInfo *frame, MonoException *ex, int clause_index, g
        clause_args.filter_exception = ex;
        clause_args.base_frame = iframe;
 
-       interp_exec_method_full (&child_frame, context, &clause_args);
+       ERROR_DECL (error);
+       interp_exec_method_full (&child_frame, context, &clause_args, error);
        /* ENDFILTER stores the result into child_frame->retval */
        return child_frame.retval->data.i ? TRUE : FALSE;
 }