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