Implement mono_gc_alloc_fixed on Boehm to be uncollectable. This matches SGen behavio...
[mono.git] / mono / mini / interpreter / interp.h
1 #include <setjmp.h>
2 #include <glib.h>
3 #include <mono/metadata/loader.h>
4 #include <mono/metadata/object.h>
5 #include <mono/metadata/domain-internals.h>
6 #include <mono/metadata/class-internals.h>
7 #include "config.h"
8
9 enum {
10         VAL_I32     = 0,
11         VAL_DOUBLE  = 1,
12         VAL_I64     = 2,
13         VAL_VALUET  = 3,
14         VAL_POINTER = 4,
15         VAL_NATI    = 0 + VAL_POINTER,
16         VAL_MP      = 1 + VAL_POINTER,
17         VAL_TP      = 2 + VAL_POINTER,
18         VAL_OBJ     = 3 + VAL_POINTER
19 };
20
21 #if SIZEOF_VOID_P == 4
22 typedef guint32 mono_u;
23 typedef gint32  mono_i;
24 #elif SIZEOF_VOID_P == 8
25 typedef guint64 mono_u;
26 typedef gint64  mono_i;
27 #endif
28
29 /*
30  * Value types are represented on the eval stack as pointers to the
31  * actual storage. The size field tells how much storage is allocated.
32  * A value type can't be larger than 16 MB.
33  */
34 typedef struct {
35         union {
36                 gint32 i;
37                 gint64 l;
38                 double f;
39                 /* native size integer and pointer types */
40                 gpointer p;
41                 mono_u nati;
42                 gpointer vt;
43         } data;
44 #if defined(__ppc__) || defined(__powerpc__)
45         int pad;
46 #endif
47 } stackval;
48
49 typedef struct _MonoInvocation MonoInvocation;
50
51 typedef void (*MonoFuncV) (void);
52 typedef void (*MonoPIFunc) (MonoFuncV callme, void *margs);
53
54 /* 
55  * Structure representing a method transformed for the interpreter 
56  * This is domain specific
57  */
58 typedef struct _RuntimeMethod
59 {
60         /* NOTE: These first two elements (method and
61            next_jit_code_hash) must be in the same order and at the
62            same offset as in MonoJitInfo, because of the jit_code_hash
63            internal hash table in MonoDomain. */
64         MonoMethod *method;
65         struct _RuntimeMethod *next_jit_code_hash;
66         guint32 locals_size;
67         guint32 args_size;
68         guint32 stack_size;
69         guint32 vt_stack_size;
70         guint32 alloca_size;
71         unsigned short *code;
72         unsigned short *new_body_start; /* after all STINARG instrs */
73         MonoPIFunc func;
74         int num_clauses;
75         MonoExceptionClause *clauses;
76         void **data_items;
77         int transformed;
78         guint32 *arg_offsets;
79         guint32 *local_offsets;
80         unsigned int param_count;
81         unsigned int hasthis;
82         unsigned int valuetype;
83 } RuntimeMethod;
84
85 struct _MonoInvocation {
86         MonoInvocation *parent; /* parent */
87         RuntimeMethod  *runtime_method; /* parent */
88         MonoMethod     *method; /* parent */
89         stackval       *retval; /* parent */
90         void           *obj;    /* this - parent */
91         char           *args;
92         stackval       *stack_args; /* parent */
93         stackval       *stack;
94         stackval       *sp; /* For GC stack marking */
95         /* exception info */
96         unsigned char  invoke_trap;
97         const unsigned short  *ip;
98         MonoException     *ex;
99         MonoExceptionClause *ex_handler;
100 };
101
102 typedef struct {
103         MonoDomain *domain;
104         MonoInvocation *base_frame;
105         MonoInvocation *current_frame;
106         MonoInvocation *env_frame;
107         jmp_buf *current_env;
108         unsigned char search_for_handler;
109         unsigned char managed_code;
110 } ThreadContext;
111
112 void mono_init_icall (void);
113
114 MonoException *
115 mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *context);
116
117 MonoDelegate*
118 mono_interp_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
119
120 int
121 interp_regression_list (int verbose, int count, char *images []);
122
123 void
124 mono_interp_transform_init (void);
125
126 static void inline stackval_from_data (MonoType *type, stackval *result, char *data, gboolean pinvoke);
127 static void inline stackval_to_data (MonoType *type, stackval *val, char *data, gboolean pinvoke);
128 void ves_exec_method (MonoInvocation *frame);
129
130 MonoDomain *
131 mono_interp_init(const char *file);
132
133 /*
134  * defined in an arch specific file.
135  */
136 MonoPIFunc
137 mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor);
138
139 RuntimeMethod *
140 mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error);
141
142 void *mono_arch_create_method_pointer (MonoMethod *method);
143
144 extern int mono_interp_traceopt;