2005-01-24 Ben Maurer <bmaurer@ximian.com>
[mono-project.git] / mono / metadata / domain-internals.h
blob735ea6b8855ce6cc0a06aead99d1dd4c9d367d98
1 /*
2 * Appdomain-related internal data structures and functions.
3 */
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/io-layer/io-layer.h>
12 extern CRITICAL_SECTION mono_delegate_section;
14 /* This is a copy of System.AppDomainSetup */
15 typedef struct {
16 MonoObject object;
17 MonoString *application_base;
18 MonoString *application_name;
19 MonoString *cache_path;
20 MonoString *configuration_file;
21 MonoString *dynamic_base;
22 MonoString *license_file;
23 MonoString *private_bin_path;
24 MonoString *private_bin_path_probe;
25 MonoString *shadow_copy_directories;
26 MonoString *shadow_copy_files;
27 MonoBoolean publisher_policy;
28 MonoBoolean path_changed;
29 int loader_optimization;
30 MonoBoolean disallow_binding_redirects;
31 MonoBoolean disallow_code_downloads;
32 } MonoAppDomainSetup;
34 typedef GArray MonoJitInfoTable;
36 typedef struct {
37 guint32 flags;
38 gint32 exvar_offset;
39 gpointer try_start;
40 gpointer try_end;
41 gpointer handler_start;
42 union {
43 MonoClass *catch_class;
44 gpointer filter;
45 } data;
46 } MonoJitExceptionInfo;
48 struct _MonoJitInfo {
49 MonoMethod *method;
50 gpointer code_start;
51 int code_size;
52 guint32 used_regs;
53 unsigned num_clauses;
54 /* Whenever the code is domain neutral or 'shared' */
55 gboolean domain_neutral:1;
56 gboolean cas_inited:1;
57 gboolean cas_class_assert:1;
58 gboolean cas_class_deny:1;
59 gboolean cas_class_permitonly:1;
60 gboolean cas_method_assert:1;
61 gboolean cas_method_deny:1;
62 gboolean cas_method_permitonly:1;
63 MonoJitExceptionInfo *clauses;
66 typedef struct {
67 MonoJitInfo *ji;
68 MonoCodeManager *code_mp;
69 } MonoJitDynamicMethodInfo;
71 struct _MonoAppContext {
72 MonoObject obj;
73 gint32 domain_id;
74 gint32 context_id;
75 gpointer *static_data;
78 typedef enum {
79 MONO_APPDOMAIN_CREATED,
80 MONO_APPDOMAIN_UNLOADING,
81 MONO_APPDOMAIN_UNLOADED
82 } MonoAppDomainState;
84 struct _MonoDomain {
85 MonoAppDomain *domain;
86 CRITICAL_SECTION lock;
87 MonoMemPool *mp;
88 MonoCodeManager *code_mp;
89 MonoGHashTable *env;
90 GHashTable *assemblies_by_name;
91 GList *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;
127 * This must be a GHashTable, since these objects can't be finalized
128 * if the hashtable contains a GC visible reference to them.
130 GHashTable *finalizable_objects_hash;
133 #define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
134 #define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
136 void
137 mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji);
139 void
140 mono_jit_info_table_remove (MonoDomain *domain, MonoJitInfo *ji);
142 MonoAppDomain *
143 ves_icall_System_AppDomain_getCurDomain (void);
145 MonoAppDomain *
146 ves_icall_System_AppDomain_getRootDomain (void);
148 MonoAppDomain *
149 ves_icall_System_AppDomain_createDomain (MonoString *friendly_name,
150 MonoAppDomainSetup *setup);
152 MonoObject *
153 ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
154 MonoString *name);
156 MonoReflectionAssembly *
157 ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
158 MonoArray *raw_assembly,
159 MonoArray *raw_symbol_store,
160 MonoObject *evidence);
162 void
163 ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
164 MonoString *name,
165 MonoObject *data);
167 MonoAppDomainSetup *
168 ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad);
170 MonoString *
171 ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad);
173 MonoArray *
174 ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad);
176 MonoReflectionAssembly *
177 ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname);
179 MonoReflectionAssembly *
180 ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,
181 MonoString *assRef,
182 MonoObject *evidence);
184 gboolean
185 ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id);
187 void
188 ves_icall_System_AppDomain_InternalUnload (gint32 domain_id);
190 gint32
191 ves_icall_System_AppDomain_ExecuteAssembly (MonoAppDomain *ad,
192 MonoString *file,
193 MonoObject *evidence,
194 MonoArray *args);
196 MonoAppDomain *
197 ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad);
199 MonoAppDomain *
200 ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid);
202 void
203 ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad);
205 void
206 ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id);
208 void
209 ves_icall_System_AppDomain_InternalPopDomainRef (void);
211 MonoAppContext *
212 ves_icall_System_AppDomain_InternalGetContext (void);
214 MonoAppContext *
215 ves_icall_System_AppDomain_InternalGetDefaultContext (void);
217 MonoAppContext *
218 ves_icall_System_AppDomain_InternalSetContext (MonoAppContext *mc);
220 gint32
221 ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad);
223 MonoString *
224 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid);
226 const char*
227 mono_get_framework_version (void);
229 const char*
230 mono_get_runtime_version (void);
233 #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */