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