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