[interpreter] clean up exported symbols and header organization
authorBernhard Urban <bernhard.urban@xamarin.com>
Thu, 9 Feb 2017 19:42:19 +0000 (20:42 +0100)
committerBernhard Urban <bernhard.urban@xamarin.com>
Thu, 16 Feb 2017 22:09:38 +0000 (23:09 +0100)
mono/mini/Makefile.am.in
mono/mini/driver.c
mono/mini/interpreter/interp-internals.h [new file with mode: 0644]
mono/mini/interpreter/interp.c
mono/mini/interpreter/interp.h
mono/mini/interpreter/transform.c
mono/mini/mini-runtime.c
mono/mini/mini.h
mono/mini/tramp-amd64.c

index 15d192b6ea08bbff3008bb41075c600f1e4a2fed..37c19cabc3eeaa47a134a061d2ecd1f6e7d98522 100755 (executable)
@@ -391,6 +391,7 @@ if ENABLE_INTERPRETER
 interpreter_sources =  \
        interpreter/hacks.h             \
        interpreter/interp.h    \
+       interpreter/interp-internals.h  \
        interpreter/interp.c    \
        interpreter/mintops.h   \
        interpreter/mintops.def \
index 6be511fe010483f10cf64d71ccb33cab105d8113..860e1ca626fd48ee19f6ff11b4f3dd65e8b461d2 100644 (file)
@@ -2066,7 +2066,7 @@ mono_main (int argc, char* argv[])
        case DO_REGRESSION:
 #ifdef ENABLE_INTERPRETER
                if (mono_use_interpreter) {
-                       if (interp_regression_list (2, argc -i, argv + i)) {
+                       if (mono_interp_regression_list (2, argc -i, argv + i)) {
                                g_print ("Regression ERRORS!\n");
                                // mini_cleanup (domain);
                                return 1;
diff --git a/mono/mini/interpreter/interp-internals.h b/mono/mini/interpreter/interp-internals.h
new file mode 100644 (file)
index 0000000..603e20a
--- /dev/null
@@ -0,0 +1,128 @@
+#ifndef __MONO_MINI_INTERPRETER_INTERNALS_H__
+#define __MONO_MINI_INTERPRETER_INTERNALS_H__
+
+#include <setjmp.h>
+#include <glib.h>
+#include <mono/metadata/loader.h>
+#include <mono/metadata/object.h>
+#include <mono/metadata/domain-internals.h>
+#include <mono/metadata/class-internals.h>
+#include "config.h"
+
+enum {
+       VAL_I32     = 0,
+       VAL_DOUBLE  = 1,
+       VAL_I64     = 2,
+       VAL_VALUET  = 3,
+       VAL_POINTER = 4,
+       VAL_NATI    = 0 + VAL_POINTER,
+       VAL_MP      = 1 + VAL_POINTER,
+       VAL_TP      = 2 + VAL_POINTER,
+       VAL_OBJ     = 3 + VAL_POINTER
+};
+
+#if SIZEOF_VOID_P == 4
+typedef guint32 mono_u;
+typedef gint32  mono_i;
+#elif SIZEOF_VOID_P == 8
+typedef guint64 mono_u;
+typedef gint64  mono_i;
+#endif
+
+/*
+ * Value types are represented on the eval stack as pointers to the
+ * actual storage. The size field tells how much storage is allocated.
+ * A value type can't be larger than 16 MB.
+ */
+typedef struct {
+       union {
+               gint32 i;
+               gint64 l;
+               double f;
+               /* native size integer and pointer types */
+               gpointer p;
+               mono_u nati;
+               gpointer vt;
+       } data;
+#if defined(__ppc__) || defined(__powerpc__)
+       int pad;
+#endif
+} stackval;
+
+typedef struct _MonoInvocation MonoInvocation;
+
+typedef void (*MonoFuncV) (void);
+typedef void (*MonoPIFunc) (MonoFuncV callme, void *margs);
+
+/* 
+ * Structure representing a method transformed for the interpreter 
+ * This is domain specific
+ */
+typedef struct _RuntimeMethod
+{
+       /* NOTE: These first two elements (method and
+          next_jit_code_hash) must be in the same order and at the
+          same offset as in MonoJitInfo, because of the jit_code_hash
+          internal hash table in MonoDomain. */
+       MonoMethod *method;
+       struct _RuntimeMethod *next_jit_code_hash;
+       guint32 locals_size;
+       guint32 args_size;
+       guint32 stack_size;
+       guint32 vt_stack_size;
+       guint32 alloca_size;
+       unsigned short *code;
+       unsigned short *new_body_start; /* after all STINARG instrs */
+       MonoPIFunc func;
+       int num_clauses;
+       MonoExceptionClause *clauses;
+       void **data_items;
+       int transformed;
+       guint32 *arg_offsets;
+       guint32 *local_offsets;
+       unsigned int param_count;
+       unsigned int hasthis;
+       unsigned int valuetype;
+} RuntimeMethod;
+
+struct _MonoInvocation {
+       MonoInvocation *parent; /* parent */
+       RuntimeMethod  *runtime_method; /* parent */
+       MonoMethod     *method; /* parent */
+       stackval       *retval; /* parent */
+       char           *args;
+       stackval       *stack_args; /* parent */
+       stackval       *stack;
+       stackval       *sp; /* For GC stack marking */
+       /* exception info */
+       unsigned char  invoke_trap;
+       const unsigned short  *ip;
+       MonoException     *ex;
+       MonoExceptionClause *ex_handler;
+};
+
+typedef struct {
+       MonoDomain *domain;
+       MonoInvocation *base_frame;
+       MonoInvocation *current_frame;
+       MonoInvocation *env_frame;
+       jmp_buf *current_env;
+       unsigned char search_for_handler;
+       unsigned char managed_code;
+} ThreadContext;
+
+extern int mono_interp_traceopt;
+
+MonoException *
+mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *context);
+
+MonoDelegate*
+mono_interp_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
+
+void
+mono_interp_transform_init (void);
+
+RuntimeMethod *
+mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error);
+
+#endif /* __MONO_MINI_INTERPRETER_INTERNALS_H__ */
index 5b7d4142400fbc41e7ee2439a51878ffd33aa21c..355be888649cb14065a976f7cc42f185150261a6 100644 (file)
@@ -58,6 +58,7 @@
 #include <mono/metadata/mono-debug.h>
 
 #include "interp.h"
+#include "interp-internals.h"
 #include "mintops.h"
 #include "hacks.h"
 
@@ -1214,7 +1215,7 @@ get_trace_ips (MonoDomain *domain, MonoInvocation *top)
 #endif
 
 MonoObject*
-interp_mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
+mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
 {
        MonoInvocation frame;
        ThreadContext * volatile context = mono_native_tls_get_value (thread_context_id);
@@ -1471,7 +1472,7 @@ static MonoObject *
 mp_tramp_0 (MonoObject *this_obj, void **params, MonoObject **exc, void *compiled_method) {
        MonoError error;
        void *params_real[] = {this_obj, &params, &exc, &compiled_method};
-       MonoObject *ret = interp_mono_runtime_invoke (method_pointers [0], NULL, params_real, NULL, &error);
+       MonoObject *ret = mono_interp_runtime_invoke (method_pointers [0], NULL, params_real, NULL, &error);
        mono_error_cleanup (&error); /* FIXME: don't swallow the error */
        return ret;
 }
@@ -1480,7 +1481,7 @@ static MonoObject *
 mp_tramp_1 (MonoObject *this_obj, void **params, MonoObject **exc, void *compiled_method) {
        MonoError error;
        void *params_real[] = {this_obj, &params, &exc, &compiled_method};
-       MonoObject *ret = interp_mono_runtime_invoke (method_pointers [1], NULL, params_real, NULL, &error);
+       MonoObject *ret = mono_interp_runtime_invoke (method_pointers [1], NULL, params_real, NULL, &error);
        mono_error_cleanup (&error); /* FIXME: don't swallow the error */
        return ret;
 }
@@ -1490,7 +1491,7 @@ gpointer *mp_tramps[] = {(gpointer) mp_tramp_0, (gpointer) mp_tramp_1};
 static int tramps_used = 0;
 
 gpointer
-interp_create_method_pointer (MonoMethod *method, MonoError *error)
+mono_interp_create_method_pointer (MonoMethod *method, MonoError *error)
 {
        gpointer addr;
        MonoJitInfo *ji;
@@ -4428,7 +4429,7 @@ interp_regression_step (MonoImage *image, int verbose, int *total_run, int *tota
                                         * MonoObject *obj = create_custom_attr (ainfo->image, centry->ctor, centry->data, centry->data_size, &error); */
                                        mono_error_cleanup (&error);
                                        MonoMethod *getter = mono_class_get_method_from_name (klass, "get_Category", -1);
-                                       MonoObject *str = interp_mono_runtime_invoke (getter, obj, NULL, &exc, &error);
+                                       MonoObject *str = mono_interp_runtime_invoke (getter, obj, NULL, &exc, &error);
                                        mono_error_cleanup (&error);
                                        char *utf8_str = mono_string_to_utf8_checked ((MonoString *) str, &error);
                                        mono_error_cleanup (&error);
@@ -4443,7 +4444,7 @@ interp_regression_step (MonoImage *image, int verbose, int *total_run, int *tota
                        MonoError interp_error;
                        MonoObject *exc = NULL;
 
-                       result_obj = interp_mono_runtime_invoke (method, NULL, NULL, &exc, &interp_error);
+                       result_obj = mono_interp_runtime_invoke (method, NULL, NULL, &exc, &interp_error);
                        if (!mono_error_ok (&interp_error)) {
                                cfailed++;
                                g_print ("Test '%s' execution failed.\n", method->name);
@@ -4507,7 +4508,7 @@ interp_regression (MonoImage *image, int verbose, int *total_run)
 }
 
 int
-interp_regression_list (int verbose, int count, char *images [])
+mono_interp_regression_list (int verbose, int count, char *images [])
 {
        int i, total, total_run, run;
        
index e818af53e01c8670bf70371f33f7a3e413b0bf70..718acbcbad7e23efbb9dc89dd5bde87db3abac57 100644 (file)
-#include <setjmp.h>
-#include <glib.h>
-#include <mono/metadata/loader.h>
-#include <mono/metadata/object.h>
-#include <mono/metadata/domain-internals.h>
-#include <mono/metadata/class-internals.h>
-#include "config.h"
-
-enum {
-       VAL_I32     = 0,
-       VAL_DOUBLE  = 1,
-       VAL_I64     = 2,
-       VAL_VALUET  = 3,
-       VAL_POINTER = 4,
-       VAL_NATI    = 0 + VAL_POINTER,
-       VAL_MP      = 1 + VAL_POINTER,
-       VAL_TP      = 2 + VAL_POINTER,
-       VAL_OBJ     = 3 + VAL_POINTER
-};
-
-#if SIZEOF_VOID_P == 4
-typedef guint32 mono_u;
-typedef gint32  mono_i;
-#elif SIZEOF_VOID_P == 8
-typedef guint64 mono_u;
-typedef gint64  mono_i;
-#endif
-
-/*
- * Value types are represented on the eval stack as pointers to the
- * actual storage. The size field tells how much storage is allocated.
- * A value type can't be larger than 16 MB.
- */
-typedef struct {
-       union {
-               gint32 i;
-               gint64 l;
-               double f;
-               /* native size integer and pointer types */
-               gpointer p;
-               mono_u nati;
-               gpointer vt;
-       } data;
-#if defined(__ppc__) || defined(__powerpc__)
-       int pad;
-#endif
-} stackval;
-
-typedef struct _MonoInvocation MonoInvocation;
-
-typedef void (*MonoFuncV) (void);
-typedef void (*MonoPIFunc) (MonoFuncV callme, void *margs);
-
-/* 
- * Structure representing a method transformed for the interpreter 
- * This is domain specific
- */
-typedef struct _RuntimeMethod
-{
-       /* NOTE: These first two elements (method and
-          next_jit_code_hash) must be in the same order and at the
-          same offset as in MonoJitInfo, because of the jit_code_hash
-          internal hash table in MonoDomain. */
-       MonoMethod *method;
-       struct _RuntimeMethod *next_jit_code_hash;
-       guint32 locals_size;
-       guint32 args_size;
-       guint32 stack_size;
-       guint32 vt_stack_size;
-       guint32 alloca_size;
-       unsigned short *code;
-       unsigned short *new_body_start; /* after all STINARG instrs */
-       MonoPIFunc func;
-       int num_clauses;
-       MonoExceptionClause *clauses;
-       void **data_items;
-       int transformed;
-       guint32 *arg_offsets;
-       guint32 *local_offsets;
-       unsigned int param_count;
-       unsigned int hasthis;
-       unsigned int valuetype;
-} RuntimeMethod;
-
-struct _MonoInvocation {
-       MonoInvocation *parent; /* parent */
-       RuntimeMethod  *runtime_method; /* parent */
-       MonoMethod     *method; /* parent */
-       stackval       *retval; /* parent */
-       char           *args;
-       stackval       *stack_args; /* parent */
-       stackval       *stack;
-       stackval       *sp; /* For GC stack marking */
-       /* exception info */
-       unsigned char  invoke_trap;
-       const unsigned short  *ip;
-       MonoException     *ex;
-       MonoExceptionClause *ex_handler;
-};
-
-typedef struct {
-       MonoDomain *domain;
-       MonoInvocation *base_frame;
-       MonoInvocation *current_frame;
-       MonoInvocation *env_frame;
-       jmp_buf *current_env;
-       unsigned char search_for_handler;
-       unsigned char managed_code;
-} ThreadContext;
-
-void mono_init_icall (void);
-
-MonoException *
-mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *context);
-
-MonoDelegate*
-mono_interp_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
+#ifndef __MONO_MINI_INTERPRETER_H__
+#define __MONO_MINI_INTERPRETER_H__
+#include <mono/mini/mini.h>
 
 int
-interp_regression_list (int verbose, int count, char *images []);
+mono_interp_regression_list (int verbose, int count, char *images []);
 
-void
-mono_interp_transform_init (void);
-
-static void inline stackval_from_data (MonoType *type, stackval *result, char *data, gboolean pinvoke);
-static void inline stackval_to_data (MonoType *type, stackval *val, char *data, gboolean pinvoke);
-void ves_exec_method (MonoInvocation *frame);
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info);
 
-/*
- * defined in an arch specific file.
- */
-MonoPIFunc
-mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor);
+void
+mono_interp_init (void);
 
-RuntimeMethod *
-mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error);
+gpointer
+mono_interp_create_method_pointer (MonoMethod *method, MonoError *error);
 
-void *mono_arch_create_method_pointer (MonoMethod *method);
+MonoObject*
+mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error);
 
-extern int mono_interp_traceopt;
+#endif /* __MONO_MINI_INTERPRETER_H__ */
index deac1a6a0ee2373a11717c416ffe4f055ea62dce..149b45278501a1c8431a2004038564f7dc895383 100644 (file)
@@ -18,6 +18,7 @@
 #include <mono/mini/mini.h>
 
 #include "mintops.h"
+#include "interp-internals.h"
 #include "interp.h"
 
 // TODO: export from marshal.c
index 9eade804217ea75654fc94e2b1a1e5eb3ecfa823..ece3233935909c31244c455544e7dea8776d227f 100644 (file)
 #endif
 #endif
 
+#ifdef ENABLE_INTERPRETER
+#include "interpreter/interp.h"
+#endif
+
 static guint32 default_opt = 0;
 static gboolean default_opt_set = FALSE;
 
@@ -1769,7 +1773,7 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoError *er
 
 #ifdef ENABLE_INTERPRETER
        if (mono_use_interpreter)
-               return interp_create_method_pointer (method, error);
+               return mono_interp_create_method_pointer (method, error);
 #endif
 
        if (mono_llvm_only)
@@ -2359,7 +2363,7 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
 
 #ifdef ENABLE_INTERPRETER
        if (mono_use_interpreter)
-               return interp_mono_runtime_invoke (method, obj, params, exc, error);
+               return mono_interp_runtime_invoke (method, obj, params, exc, error);
 #endif
 
        mono_error_init (error);
index 60911597d97062a1ff48288d0b233a9fec6066a0..763153469183c2e8091184ce452f3035716d68d2 100644 (file)
@@ -2820,12 +2820,6 @@ void    mono_arch_notify_pending_exc            (MonoThreadInfo *info);
 guint8* mono_arch_get_call_target               (guint8 *code);
 guint32 mono_arch_get_plt_info_offset           (guint8 *plt_entry, mgreg_t *regs, guint8 *code);
 GSList *mono_arch_get_trampolines               (gboolean aot);
-#ifdef ENABLE_INTERPRETER
-gpointer mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info);
-void mono_interp_init (void);
-gpointer interp_create_method_pointer (MonoMethod *method, MonoError *error);
-MonoObject* interp_mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error);
-#endif
 
 /* Handle block guard */
 gpointer mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value);
index 771b3a01251436ca29772adb649c86fc93baa481..4c64ac240815e6ba5bfcad51d43a12e2104880bf 100644 (file)
 #include "mini-amd64.h"
 #include "debugger-agent.h"
 
+#ifdef ENABLE_INTERPRETER
+#include "interpreter/interp.h"
+#endif
+
 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
 
 #define IS_REX(inst) (((inst) >= 0x40) && ((inst) <= 0x4f))