More missing internal flags.
[mono.git] / mono / metadata / domain-internals.h
1 /*
2  * Appdomain-related internal data structures and functions.
3  */
4 #ifndef __MONO_METADATA_DOMAIN_INTERNALS_H__
5 #define __MONO_METADATA_DOMAIN_INTERNALS_H__
6
7 #include <mono/metadata/appdomain.h>
8 #include <mono/utils/mono-codeman.h>
9 #include <mono/utils/mono-hash.h>
10 #include <mono/utils/mono-compiler.h>
11 #include <mono/io-layer/io-layer.h>
12
13 extern CRITICAL_SECTION mono_delegate_section;
14
15 /* This is a copy of System.AppDomainSetup */
16 typedef struct {
17         MonoObject object;
18         MonoString *application_base;
19         MonoString *application_name;
20         MonoString *cache_path;
21         MonoString *configuration_file;
22         MonoString *dynamic_base;
23         MonoString *license_file;
24         MonoString *private_bin_path;
25         MonoString *private_bin_path_probe;
26         MonoString *shadow_copy_directories;
27         MonoString *shadow_copy_files;
28         MonoBoolean publisher_policy;
29         MonoBoolean path_changed;
30         int loader_optimization;
31         MonoBoolean disallow_binding_redirects;
32         MonoBoolean disallow_code_downloads;
33 } MonoAppDomainSetup;
34
35 typedef GArray MonoJitInfoTable;
36
37 typedef struct {
38         guint32  flags;
39         gint32   exvar_offset;
40         gpointer try_start;
41         gpointer try_end;
42         gpointer handler_start;
43         union {
44                 MonoClass *catch_class;
45                 gpointer filter;
46         } data;
47 } MonoJitExceptionInfo;
48
49 struct _MonoJitInfo {
50         MonoMethod *method;
51         gpointer    code_start;
52         guint32     used_regs;
53         int         code_size;
54         guint32     num_clauses:24;
55         /* Whenever the code is domain neutral or 'shared' */
56         gboolean    domain_neutral:1;
57         gboolean    cas_inited:1;
58         gboolean    cas_class_assert:1;
59         gboolean    cas_class_deny:1;
60         gboolean    cas_class_permitonly:1;
61         gboolean    cas_method_assert:1;
62         gboolean    cas_method_deny:1;
63         gboolean    cas_method_permitonly:1;
64         MonoJitExceptionInfo clauses [MONO_ZERO_LEN_ARRAY];
65 };
66
67 typedef struct {
68         MonoJitInfo *ji;
69         MonoCodeManager *code_mp;
70 } MonoJitDynamicMethodInfo;
71
72 struct _MonoAppContext {
73         MonoObject obj;
74         gint32 domain_id;
75         gint32 context_id;
76         gpointer *static_data;
77 };
78
79 typedef enum {
80         MONO_APPDOMAIN_CREATED,
81         MONO_APPDOMAIN_UNLOADING,
82         MONO_APPDOMAIN_UNLOADED
83 } MonoAppDomainState;
84
85 struct _MonoDomain {
86         MonoAppDomain      *domain;
87         CRITICAL_SECTION    lock;
88         MonoMemPool        *mp;
89         MonoCodeManager    *code_mp;
90         MonoGHashTable     *env;
91         GSList             *domain_assemblies;
92         MonoAssembly       *entry_assembly;
93         MonoAppDomainSetup *setup;
94         char               *friendly_name;
95         guint32            state;
96         MonoGHashTable     *ldstr_table;
97         GHashTable         *class_vtable_hash;
98         /* maps MonoString -> MonoRemoteClass */
99         MonoGHashTable     *proxy_vtable_hash;
100         MonoGHashTable     *static_data_hash;
101         GHashTable         *jit_code_hash;
102         /* maps MonoMethod -> MonoJitDynamicMethodInfo */
103         GHashTable         *dynamic_code_hash;
104         /* maps delegate trampoline addr -> delegate object */
105         MonoGHashTable     *delegate_hash_table;
106         MonoJitInfoTable   *jit_info_table;
107         /* hashtables for Reflection handles */
108         MonoGHashTable     *type_hash;
109         MonoGHashTable     *refobject_hash;
110         /* Needed by Thread:GetDomainID() */
111         gint32             domain_id;
112         /* Used when loading assemblies */
113         gchar **search_path;
114         /* Used by remoting proxies */
115         MonoMethod         *create_proxy_for_type_method;
116         MonoMethod         *private_invoke_method;
117         MonoAppContext     *default_context;
118         MonoException      *out_of_memory_ex;
119         MonoException      *null_reference_ex;
120         MonoException      *stack_overflow_ex;
121         /* Used to store offsets of thread and context static fields */
122         GHashTable         *special_static_fields;
123         GHashTable         *jump_target_hash;
124         GHashTable         *class_init_trampoline_hash;
125         GHashTable         *jump_trampoline_hash;
126         GHashTable         *jit_trampoline_hash;
127         GHashTable         *delegate_trampoline_hash;
128         /* 
129          * This must be a GHashTable, since these objects can't be finalized
130          * if the hashtable contains a GC visible reference to them.
131          */
132         GHashTable         *finalizable_objects_hash;
133         /* Used when accessing 'domain_assemblies' */
134         CRITICAL_SECTION    assemblies_lock;
135 };
136
137 typedef struct  {
138         guint16 major, minor, build, revision;
139 } AssemblyVersionSet;
140
141 /* MonoRuntimeInfo: Contains information about versions supported by this runtime */
142 typedef struct  {
143         const char runtime_version [12];
144         const char framework_version [4];
145         const AssemblyVersionSet version_sets [2];
146 } MonoRuntimeInfo;
147
148 #define mono_domain_lock(domain)   EnterCriticalSection(&(domain)->lock)
149 #define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
150 #define mono_domain_assemblies_lock(domain)   EnterCriticalSection(&(domain)->assemblies_lock)
151 #define mono_domain_assemblies_unlock(domain) LeaveCriticalSection(&(domain)->assemblies_lock)
152
153 void
154 mono_jit_info_table_add    (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
155
156 void
157 mono_jit_info_table_remove (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
158
159 void
160 mono_jit_info_add_aot_module (MonoImage *image, gpointer start, gpointer end) MONO_INTERNAL;
161
162 /* 
163  * Installs a new function which is used to return a MonoJitInfo for a method inside
164  * an AOT module.
165  */
166 typedef MonoJitInfo *(*MonoJitInfoFindInAot)         (MonoDomain *domain, MonoImage *image, gpointer addr);
167 void          mono_install_jit_info_find_in_aot (MonoJitInfoFindInAot func) MONO_INTERNAL;
168
169 MonoAppDomain *
170 ves_icall_System_AppDomain_getCurDomain            (void) MONO_INTERNAL;
171
172 MonoAppDomain *
173 ves_icall_System_AppDomain_getRootDomain           (void) MONO_INTERNAL;
174
175 MonoAppDomain *
176 ves_icall_System_AppDomain_createDomain            (MonoString         *friendly_name,
177                                                     MonoAppDomainSetup *setup) MONO_INTERNAL;
178
179 MonoObject *
180 ves_icall_System_AppDomain_GetData                 (MonoAppDomain *ad, 
181                                                     MonoString    *name) MONO_INTERNAL;
182
183 MonoReflectionAssembly *
184 ves_icall_System_AppDomain_LoadAssemblyRaw         (MonoAppDomain *ad,
185                                                     MonoArray *raw_assembly, 
186                                                     MonoArray *raw_symbol_store,
187                                                     MonoObject *evidence,
188                                                     MonoBoolean refonly) MONO_INTERNAL;
189
190 void
191 ves_icall_System_AppDomain_SetData                 (MonoAppDomain *ad, 
192                                                     MonoString    *name, 
193                                                     MonoObject    *data) MONO_INTERNAL;
194
195 MonoAppDomainSetup *
196 ves_icall_System_AppDomain_getSetup                (MonoAppDomain *ad) MONO_INTERNAL;
197
198 MonoString *
199 ves_icall_System_AppDomain_getFriendlyName         (MonoAppDomain *ad) MONO_INTERNAL;
200
201 MonoArray *
202 ves_icall_System_AppDomain_GetAssemblies           (MonoAppDomain *ad,
203                                                     MonoBoolean refonly) MONO_INTERNAL;
204
205 MonoReflectionAssembly *
206 ves_icall_System_Reflection_Assembly_LoadFrom      (MonoString *fname,
207                                                     MonoBoolean refonly) MONO_INTERNAL;
208
209 MonoReflectionAssembly *
210 ves_icall_System_AppDomain_LoadAssembly            (MonoAppDomain *ad, 
211                                                     MonoString *assRef,
212                                                     MonoObject    *evidence,
213                                                     MonoBoolean refonly) MONO_INTERNAL;
214
215 gboolean
216 ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id) MONO_INTERNAL;
217
218 void
219 ves_icall_System_AppDomain_InternalUnload          (gint32 domain_id) MONO_INTERNAL;
220
221 gint32
222 ves_icall_System_AppDomain_ExecuteAssembly         (MonoAppDomain *ad, 
223                                                     MonoString    *file, 
224                                                     MonoObject    *evidence,
225                                                     MonoArray     *args) MONO_INTERNAL;
226
227 MonoAppDomain * 
228 ves_icall_System_AppDomain_InternalSetDomain       (MonoAppDomain *ad) MONO_INTERNAL;
229
230 MonoAppDomain * 
231 ves_icall_System_AppDomain_InternalSetDomainByID   (gint32 domainid) MONO_INTERNAL;
232
233 void
234 ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad) MONO_INTERNAL;
235
236 void
237 ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id) MONO_INTERNAL;
238
239 void
240 ves_icall_System_AppDomain_InternalPopDomainRef (void) MONO_INTERNAL;
241
242 MonoAppContext * 
243 ves_icall_System_AppDomain_InternalGetContext      (void) MONO_INTERNAL;
244
245 MonoAppContext * 
246 ves_icall_System_AppDomain_InternalGetDefaultContext      (void) MONO_INTERNAL;
247
248 MonoAppContext * 
249 ves_icall_System_AppDomain_InternalSetContext      (MonoAppContext *mc) MONO_INTERNAL;
250
251 gint32 
252 ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad) MONO_INTERNAL;
253
254 MonoString *
255 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid) MONO_INTERNAL;
256
257 MonoAssembly *
258 mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *status) MONO_INTERNAL;
259
260 const MonoRuntimeInfo*
261 mono_get_runtime_info (void) MONO_INTERNAL;
262
263 gboolean
264 mono_assembly_name_parse (const char *name, MonoAssemblyName *aname) MONO_INTERNAL;
265
266 void
267 mono_assembly_name_free (MonoAssemblyName *aname) MONO_INTERNAL;
268
269 #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */