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;
34 MonoObject *activation_arguments; /* it is System.Object in 1.x, ActivationArguments in 2.0 */
35 MonoObject *domain_initializer;
36 MonoArray *domain_initializer_args;
37 MonoObject *application_trust; /* it is System.Object in 1.x, ApplicationTrust in 2.0 */
38 MonoBoolean disallow_appbase_probe;
39 MonoArray *configuration_bytes;
42 typedef GArray MonoJitInfoTable;
49 gpointer handler_start;
51 MonoClass *catch_class;
54 } MonoJitExceptionInfo;
57 /* NOTE: These first two elements (method and
58 next_jit_code_hash) must be in the same order and at the
59 same offset as in RuntimeMethod, because of the jit_code_hash
60 internal hash table in MonoDomain. */
62 struct _MonoJitInfo *next_jit_code_hash;
66 guint32 num_clauses:24;
67 /* Whenever the code is domain neutral or 'shared' */
68 gboolean domain_neutral:1;
69 gboolean cas_inited:1;
70 gboolean cas_class_assert:1;
71 gboolean cas_class_deny:1;
72 gboolean cas_class_permitonly:1;
73 gboolean cas_method_assert:1;
74 gboolean cas_method_deny:1;
75 gboolean cas_method_permitonly:1;
76 MonoJitExceptionInfo clauses [MONO_ZERO_LEN_ARRAY];
81 MonoCodeManager *code_mp;
82 } MonoJitDynamicMethodInfo;
84 struct _MonoAppContext {
88 gpointer *static_data;
92 MONO_APPDOMAIN_CREATED,
93 MONO_APPDOMAIN_UNLOADING,
94 MONO_APPDOMAIN_UNLOADED
97 typedef struct _MonoJitCodeHash MonoJitCodeHash;
100 CRITICAL_SECTION lock;
102 MonoCodeManager *code_mp;
104 * keep all the managed objects close to each other for the precise GC
105 * For the Boehm GC we additionally keep close also other GC-tracked pointers.
107 #define MONO_DOMAIN_FIRST_OBJECT setup
108 MonoAppDomainSetup *setup;
109 MonoAppDomain *domain;
110 MonoAppContext *default_context;
111 MonoException *out_of_memory_ex;
112 MonoException *null_reference_ex;
113 MonoException *stack_overflow_ex;
114 #define MONO_DOMAIN_FIRST_GC_TRACKED env
116 MonoGHashTable *ldstr_table;
117 /* hashtables for Reflection handles */
118 MonoGHashTable *type_hash;
119 MonoGHashTable *refobject_hash;
120 /* a GC-tracked array to keep references to the static fields of types */
121 gpointer *static_data_array;
122 /* maps class -> type initialization exception object */
123 MonoGHashTable *type_init_exception_hash;
124 /* maps delegate trampoline addr -> delegate object */
125 MonoGHashTable *delegate_hash_table;
126 #define MONO_DOMAIN_LAST_GC_TRACKED delegate_hash_table
128 /* Needed by Thread:GetDomainID() */
130 gint32 shadow_serial;
131 GSList *domain_assemblies;
132 MonoAssembly *entry_assembly;
134 GHashTable *class_vtable_hash;
135 /* maps remote class key -> MonoRemoteClass */
136 GHashTable *proxy_vtable_hash;
137 MonoInternalHashTable jit_code_hash;
138 /* maps MonoMethod -> MonoJitDynamicMethodInfo */
139 GHashTable *dynamic_code_hash;
140 MonoJitInfoTable *jit_info_table;
141 /* Used when loading assemblies */
143 /* Used by remoting proxies */
144 MonoMethod *create_proxy_for_type_method;
145 MonoMethod *private_invoke_method;
146 /* Used to store offsets of thread and context static fields */
147 GHashTable *special_static_fields;
148 GHashTable *jump_target_hash;
149 GHashTable *class_init_trampoline_hash;
150 GHashTable *jump_trampoline_hash;
151 GHashTable *jit_trampoline_hash;
152 GHashTable *delegate_trampoline_hash;
153 GHashTable *delegate_invoke_impl_with_target_hash;
154 GHashTable *delegate_invoke_impl_no_target_hash;
156 * This must be a GHashTable, since these objects can't be finalized
157 * if the hashtable contains a GC visible reference to them.
159 GHashTable *finalizable_objects_hash;
160 /* Used when accessing 'domain_assemblies' */
161 CRITICAL_SECTION assemblies_lock;
165 guint16 major, minor, build, revision;
166 } AssemblyVersionSet;
168 /* MonoRuntimeInfo: Contains information about versions supported by this runtime */
170 const char runtime_version [12];
171 const char framework_version [4];
172 const AssemblyVersionSet version_sets [2];
175 #define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
176 #define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
177 #define mono_domain_assemblies_lock(domain) EnterCriticalSection(&(domain)->assemblies_lock)
178 #define mono_domain_assemblies_unlock(domain) LeaveCriticalSection(&(domain)->assemblies_lock)
181 mono_init_com_types (void) MONO_INTERNAL;
184 mono_cleanup (void) MONO_INTERNAL;
187 mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
190 mono_jit_info_table_remove (MonoDomain *domain, MonoJitInfo *ji) MONO_INTERNAL;
193 mono_jit_info_add_aot_module (MonoImage *image, gpointer start, gpointer end) MONO_INTERNAL;
196 * Installs a new function which is used to return a MonoJitInfo for a method inside
199 typedef MonoJitInfo *(*MonoJitInfoFindInAot) (MonoDomain *domain, MonoImage *image, gpointer addr);
200 void mono_install_jit_info_find_in_aot (MonoJitInfoFindInAot func) MONO_INTERNAL;
203 mono_jit_code_hash_init (MonoInternalHashTable *jit_code_hash) MONO_INTERNAL;
206 ves_icall_System_AppDomain_getCurDomain (void) MONO_INTERNAL;
209 ves_icall_System_AppDomain_getRootDomain (void) MONO_INTERNAL;
212 ves_icall_System_AppDomain_createDomain (MonoString *friendly_name,
213 MonoAppDomainSetup *setup) MONO_INTERNAL;
216 ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
217 MonoString *name) MONO_INTERNAL;
219 MonoReflectionAssembly *
220 ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
221 MonoArray *raw_assembly,
222 MonoArray *raw_symbol_store,
223 MonoObject *evidence,
224 MonoBoolean refonly) MONO_INTERNAL;
227 ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
229 MonoObject *data) MONO_INTERNAL;
232 ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad) MONO_INTERNAL;
235 ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad) MONO_INTERNAL;
238 ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad,
239 MonoBoolean refonly) MONO_INTERNAL;
241 MonoReflectionAssembly *
242 ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname,
243 MonoBoolean refonly) MONO_INTERNAL;
245 MonoReflectionAssembly *
246 ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,
248 MonoObject *evidence,
249 MonoBoolean refonly) MONO_INTERNAL;
252 ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id) MONO_INTERNAL;
255 ves_icall_System_AppDomain_InternalUnload (gint32 domain_id) MONO_INTERNAL;
258 ves_icall_System_AppDomain_ExecuteAssembly (MonoAppDomain *ad,
260 MonoObject *evidence,
261 MonoArray *args) MONO_INTERNAL;
264 ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad) MONO_INTERNAL;
267 ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid) MONO_INTERNAL;
270 ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad) MONO_INTERNAL;
273 ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id) MONO_INTERNAL;
276 ves_icall_System_AppDomain_InternalPopDomainRef (void) MONO_INTERNAL;
279 ves_icall_System_AppDomain_InternalGetContext (void) MONO_INTERNAL;
282 ves_icall_System_AppDomain_InternalGetDefaultContext (void) MONO_INTERNAL;
285 ves_icall_System_AppDomain_InternalSetContext (MonoAppContext *mc) MONO_INTERNAL;
288 ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad) MONO_INTERNAL;
291 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid) MONO_INTERNAL;
294 mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *status) MONO_INTERNAL;
296 const MonoRuntimeInfo*
297 mono_get_runtime_info (void) MONO_INTERNAL;
300 mono_assembly_name_parse (const char *name, MonoAssemblyName *aname) MONO_INTERNAL;
303 mono_assembly_name_free (MonoAssemblyName *aname) MONO_INTERNAL;
305 MonoImage *mono_assembly_open_from_bundle (const char *filename,
306 MonoImageOpenStatus *status,
307 gboolean refonly) MONO_INTERNAL;
310 mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointer data, guint32 *bitmap);
312 #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */