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/io-layer/io-layer.h>
13 extern CRITICAL_SECTION mono_delegate_section;
15 /* This is a copy of System.AppDomainSetup */
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;
35 typedef GArray MonoJitInfoTable;
42 gpointer handler_start;
44 MonoClass *catch_class;
47 } MonoJitExceptionInfo;
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];
69 MonoCodeManager *code_mp;
70 } MonoJitDynamicMethodInfo;
72 struct _MonoAppContext {
76 gpointer *static_data;
80 MONO_APPDOMAIN_CREATED,
81 MONO_APPDOMAIN_UNLOADING,
82 MONO_APPDOMAIN_UNLOADED
86 CRITICAL_SECTION lock;
88 MonoCodeManager *code_mp;
90 * keep all the managed objects close to each other for the precise GC
91 * For the Boehm GC we additionally keep close also other GC-tracked pointers.
93 #define MONO_DOMAIN_FIRST_OBJECT setup
94 MonoAppDomainSetup *setup;
95 MonoAppDomain *domain;
96 MonoAppContext *default_context;
97 MonoException *out_of_memory_ex;
98 MonoException *null_reference_ex;
99 MonoException *stack_overflow_ex;
100 #define MONO_DOMAIN_FIRST_GC_TRACKED env
102 MonoGHashTable *ldstr_table;
103 /* hashtables for Reflection handles */
104 MonoGHashTable *type_hash;
105 MonoGHashTable *refobject_hash;
106 /* a GC-tracked array to keep references to the static fields of types */
107 gpointer *static_data_array;
108 /* maps delegate trampoline addr -> delegate object */
109 MonoGHashTable *delegate_hash_table;
110 #define MONO_DOMAIN_LAST_GC_TRACKED delegate_hash_table
112 /* Needed by Thread:GetDomainID() */
114 GSList *domain_assemblies;
115 MonoAssembly *entry_assembly;
117 GHashTable *class_vtable_hash;
118 /* maps remote class key -> MonoRemoteClass */
119 GHashTable *proxy_vtable_hash;
120 GHashTable *jit_code_hash;
121 /* maps MonoMethod -> MonoJitDynamicMethodInfo */
122 GHashTable *dynamic_code_hash;
123 MonoJitInfoTable *jit_info_table;
124 /* Used when loading assemblies */
126 /* Used by remoting proxies */
127 MonoMethod *create_proxy_for_type_method;
128 MonoMethod *private_invoke_method;
129 /* Used to store offsets of thread and context static fields */
130 GHashTable *special_static_fields;
131 GHashTable *jump_target_hash;
132 GHashTable *class_init_trampoline_hash;
133 GHashTable *jump_trampoline_hash;
134 GHashTable *jit_trampoline_hash;
135 GHashTable *delegate_trampoline_hash;
137 * This must be a GHashTable, since these objects can't be finalized
138 * if the hashtable contains a GC visible reference to them.
140 GHashTable *finalizable_objects_hash;
141 /* Used when accessing 'domain_assemblies' */
142 CRITICAL_SECTION assemblies_lock;
146 guint16 major, minor, build, revision;
147 } AssemblyVersionSet;
149 /* MonoRuntimeInfo: Contains information about versions supported by this runtime */
151 const char runtime_version [12];
152 const char framework_version [4];
153 const AssemblyVersionSet version_sets [2];
156 #define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
157 #define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
158 #define mono_domain_assemblies_lock(domain) EnterCriticalSection(&(domain)->assemblies_lock)
159 #define mono_domain_assemblies_unlock(domain) LeaveCriticalSection(&(domain)->assemblies_lock)
162 mono_cleanup (void) MONO_INTERNAL;
165 mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
168 mono_jit_info_table_remove (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
171 mono_jit_info_add_aot_module (MonoImage *image, gpointer start, gpointer end) MONO_INTERNAL;
174 * Installs a new function which is used to return a MonoJitInfo for a method inside
177 typedef MonoJitInfo *(*MonoJitInfoFindInAot) (MonoDomain *domain, MonoImage *image, gpointer addr);
178 void mono_install_jit_info_find_in_aot (MonoJitInfoFindInAot func) MONO_INTERNAL;
181 ves_icall_System_AppDomain_getCurDomain (void) MONO_INTERNAL;
184 ves_icall_System_AppDomain_getRootDomain (void) MONO_INTERNAL;
187 ves_icall_System_AppDomain_createDomain (MonoString *friendly_name,
188 MonoAppDomainSetup *setup) MONO_INTERNAL;
191 ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
192 MonoString *name) MONO_INTERNAL;
194 MonoReflectionAssembly *
195 ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
196 MonoArray *raw_assembly,
197 MonoArray *raw_symbol_store,
198 MonoObject *evidence,
199 MonoBoolean refonly) MONO_INTERNAL;
202 ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
204 MonoObject *data) MONO_INTERNAL;
207 ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad) MONO_INTERNAL;
210 ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad) MONO_INTERNAL;
213 ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad,
214 MonoBoolean refonly) MONO_INTERNAL;
216 MonoReflectionAssembly *
217 ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname,
218 MonoBoolean refonly) MONO_INTERNAL;
220 MonoReflectionAssembly *
221 ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,
223 MonoObject *evidence,
224 MonoBoolean refonly) MONO_INTERNAL;
227 ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id) MONO_INTERNAL;
230 ves_icall_System_AppDomain_InternalUnload (gint32 domain_id) MONO_INTERNAL;
233 ves_icall_System_AppDomain_ExecuteAssembly (MonoAppDomain *ad,
235 MonoObject *evidence,
236 MonoArray *args) MONO_INTERNAL;
239 ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad) MONO_INTERNAL;
242 ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid) MONO_INTERNAL;
245 ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad) MONO_INTERNAL;
248 ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id) MONO_INTERNAL;
251 ves_icall_System_AppDomain_InternalPopDomainRef (void) MONO_INTERNAL;
254 ves_icall_System_AppDomain_InternalGetContext (void) MONO_INTERNAL;
257 ves_icall_System_AppDomain_InternalGetDefaultContext (void) MONO_INTERNAL;
260 ves_icall_System_AppDomain_InternalSetContext (MonoAppContext *mc) MONO_INTERNAL;
263 ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad) MONO_INTERNAL;
266 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid) MONO_INTERNAL;
269 mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *status) MONO_INTERNAL;
271 const MonoRuntimeInfo*
272 mono_get_runtime_info (void) MONO_INTERNAL;
275 mono_assembly_name_parse (const char *name, MonoAssemblyName *aname) MONO_INTERNAL;
278 mono_assembly_name_free (MonoAssemblyName *aname) MONO_INTERNAL;
281 mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointer data, guint32 *bitmap);
283 #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */