2 * Appdomain-related internal data structures and functions.
4 #ifndef __MONO_METADATA_DOMAIN_INTERNALS_H__
5 #define __MONO_METADATA_DOMAIN_INTERNALS_H__
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/utils/mono-internal-hash.h>
12 #include <mono/io-layer/io-layer.h>
14 extern CRITICAL_SECTION mono_delegate_section;
16 /* This is a copy of System.AppDomainSetup */
19 MonoString *application_base;
20 MonoString *application_name;
21 MonoString *cache_path;
22 MonoString *configuration_file;
23 MonoString *dynamic_base;
24 MonoString *license_file;
25 MonoString *private_bin_path;
26 MonoString *private_bin_path_probe;
27 MonoString *shadow_copy_directories;
28 MonoString *shadow_copy_files;
29 MonoBoolean publisher_policy;
30 MonoBoolean path_changed;
31 int loader_optimization;
32 MonoBoolean disallow_binding_redirects;
33 MonoBoolean disallow_code_downloads;
36 typedef GArray MonoJitInfoTable;
43 gpointer handler_start;
45 MonoClass *catch_class;
48 } MonoJitExceptionInfo;
51 /* NOTE: These first two elements (method and
52 next_jit_code_hash) must be in the same order and at the
53 same offset as in RuntimeMethod, because of the jit_code_hash
54 internal hash table in MonoDomain. */
56 struct _MonoJitInfo *next_jit_code_hash;
60 guint32 num_clauses:24;
61 /* Whenever the code is domain neutral or 'shared' */
62 gboolean domain_neutral:1;
63 gboolean cas_inited:1;
64 gboolean cas_class_assert:1;
65 gboolean cas_class_deny:1;
66 gboolean cas_class_permitonly:1;
67 gboolean cas_method_assert:1;
68 gboolean cas_method_deny:1;
69 gboolean cas_method_permitonly:1;
70 MonoJitExceptionInfo clauses [MONO_ZERO_LEN_ARRAY];
75 MonoCodeManager *code_mp;
76 } MonoJitDynamicMethodInfo;
78 struct _MonoAppContext {
82 gpointer *static_data;
86 MONO_APPDOMAIN_CREATED,
87 MONO_APPDOMAIN_UNLOADING,
88 MONO_APPDOMAIN_UNLOADED
91 typedef struct _MonoJitCodeHash MonoJitCodeHash;
94 CRITICAL_SECTION lock;
96 MonoCodeManager *code_mp;
98 * keep all the managed objects close to each other for the precise GC
99 * For the Boehm GC we additionally keep close also other GC-tracked pointers.
101 #define MONO_DOMAIN_FIRST_OBJECT setup
102 MonoAppDomainSetup *setup;
103 MonoAppDomain *domain;
104 MonoAppContext *default_context;
105 MonoException *out_of_memory_ex;
106 MonoException *null_reference_ex;
107 MonoException *stack_overflow_ex;
108 #define MONO_DOMAIN_FIRST_GC_TRACKED env
110 MonoGHashTable *ldstr_table;
111 /* hashtables for Reflection handles */
112 MonoGHashTable *type_hash;
113 MonoGHashTable *refobject_hash;
114 /* a GC-tracked array to keep references to the static fields of types */
115 gpointer *static_data_array;
116 /* maps class -> type initialization exception object */
117 MonoGHashTable *type_init_exception_hash;
118 /* maps delegate trampoline addr -> delegate object */
119 MonoGHashTable *delegate_hash_table;
120 #define MONO_DOMAIN_LAST_GC_TRACKED delegate_hash_table
122 /* Needed by Thread:GetDomainID() */
124 GSList *domain_assemblies;
125 MonoAssembly *entry_assembly;
127 GHashTable *class_vtable_hash;
128 /* maps remote class key -> MonoRemoteClass */
129 GHashTable *proxy_vtable_hash;
130 MonoInternalHashTable jit_code_hash;
131 /* maps MonoMethod -> MonoJitDynamicMethodInfo */
132 GHashTable *dynamic_code_hash;
133 MonoJitInfoTable *jit_info_table;
134 /* Used when loading assemblies */
136 /* Used by remoting proxies */
137 MonoMethod *create_proxy_for_type_method;
138 MonoMethod *private_invoke_method;
139 /* Used to store offsets of thread and context static fields */
140 GHashTable *special_static_fields;
141 GHashTable *jump_target_hash;
142 GHashTable *class_init_trampoline_hash;
143 GHashTable *jump_trampoline_hash;
144 GHashTable *jit_trampoline_hash;
145 GHashTable *delegate_trampoline_hash;
146 GHashTable *delegate_invoke_impl_with_target_hash;
147 GHashTable *delegate_invoke_impl_no_target_hash;
149 * This must be a GHashTable, since these objects can't be finalized
150 * if the hashtable contains a GC visible reference to them.
152 GHashTable *finalizable_objects_hash;
153 /* Used when accessing 'domain_assemblies' */
154 CRITICAL_SECTION assemblies_lock;
158 guint16 major, minor, build, revision;
159 } AssemblyVersionSet;
161 /* MonoRuntimeInfo: Contains information about versions supported by this runtime */
163 const char runtime_version [12];
164 const char framework_version [4];
165 const AssemblyVersionSet version_sets [2];
168 #define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
169 #define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
170 #define mono_domain_assemblies_lock(domain) EnterCriticalSection(&(domain)->assemblies_lock)
171 #define mono_domain_assemblies_unlock(domain) LeaveCriticalSection(&(domain)->assemblies_lock)
174 mono_init_com_types (void) MONO_INTERNAL;
177 mono_cleanup (void) MONO_INTERNAL;
180 mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
183 mono_jit_info_table_remove (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
186 mono_jit_info_add_aot_module (MonoImage *image, gpointer start, gpointer end) MONO_INTERNAL;
189 * Installs a new function which is used to return a MonoJitInfo for a method inside
192 typedef MonoJitInfo *(*MonoJitInfoFindInAot) (MonoDomain *domain, MonoImage *image, gpointer addr);
193 void mono_install_jit_info_find_in_aot (MonoJitInfoFindInAot func) MONO_INTERNAL;
196 mono_jit_code_hash_init (MonoInternalHashTable *jit_code_hash) MONO_INTERNAL;
199 ves_icall_System_AppDomain_getCurDomain (void) MONO_INTERNAL;
202 ves_icall_System_AppDomain_getRootDomain (void) MONO_INTERNAL;
205 ves_icall_System_AppDomain_createDomain (MonoString *friendly_name,
206 MonoAppDomainSetup *setup) MONO_INTERNAL;
209 ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
210 MonoString *name) MONO_INTERNAL;
212 MonoReflectionAssembly *
213 ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
214 MonoArray *raw_assembly,
215 MonoArray *raw_symbol_store,
216 MonoObject *evidence,
217 MonoBoolean refonly) MONO_INTERNAL;
220 ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
222 MonoObject *data) MONO_INTERNAL;
225 ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad) MONO_INTERNAL;
228 ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad) MONO_INTERNAL;
231 ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad,
232 MonoBoolean refonly) MONO_INTERNAL;
234 MonoReflectionAssembly *
235 ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname,
236 MonoBoolean refonly) MONO_INTERNAL;
238 MonoReflectionAssembly *
239 ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,
241 MonoObject *evidence,
242 MonoBoolean refonly) MONO_INTERNAL;
245 ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id) MONO_INTERNAL;
248 ves_icall_System_AppDomain_InternalUnload (gint32 domain_id) MONO_INTERNAL;
251 ves_icall_System_AppDomain_ExecuteAssembly (MonoAppDomain *ad,
253 MonoObject *evidence,
254 MonoArray *args) MONO_INTERNAL;
257 ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad) MONO_INTERNAL;
260 ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid) MONO_INTERNAL;
263 ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad) MONO_INTERNAL;
266 ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id) MONO_INTERNAL;
269 ves_icall_System_AppDomain_InternalPopDomainRef (void) MONO_INTERNAL;
272 ves_icall_System_AppDomain_InternalGetContext (void) MONO_INTERNAL;
275 ves_icall_System_AppDomain_InternalGetDefaultContext (void) MONO_INTERNAL;
278 ves_icall_System_AppDomain_InternalSetContext (MonoAppContext *mc) MONO_INTERNAL;
281 ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad) MONO_INTERNAL;
284 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid) MONO_INTERNAL;
287 mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *status) MONO_INTERNAL;
289 const MonoRuntimeInfo*
290 mono_get_runtime_info (void) MONO_INTERNAL;
293 mono_assembly_name_parse (const char *name, MonoAssemblyName *aname) MONO_INTERNAL;
296 mono_assembly_name_free (MonoAssemblyName *aname) MONO_INTERNAL;
298 MonoImage *mono_assembly_open_from_bundle (const char *filename,
299 MonoImageOpenStatus *status,
300 gboolean refonly) MONO_INTERNAL;
303 mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointer data, guint32 *bitmap);
305 #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */