#define __MONO_METADATA_DOMAIN_INTERNALS_H__
#include <mono/metadata/appdomain.h>
+#include <mono/metadata/lock-tracer.h>
#include <mono/utils/mono-codeman.h>
#include <mono/utils/mono-hash.h>
#include <mono/utils/mono-compiler.h>
#include <mono/io-layer/io-layer.h>
extern CRITICAL_SECTION mono_delegate_section;
+extern CRITICAL_SECTION mono_strtod_mutex;
/*
* If this is set, the memory belonging to appdomains is not freed when a domain is
MonoMethod *method;
struct _MonoJitInfo *next_jit_code_hash;
gpointer code_start;
+ /* This might contain an id for the unwind info instead of a register mask */
guint32 used_regs;
int code_size;
- guint32 num_clauses:16;
+ guint32 num_clauses:15;
/* Whenever the code is domain neutral or 'shared' */
gboolean domain_neutral:1;
gboolean cas_inited:1;
gboolean cas_method_deny:1;
gboolean cas_method_permitonly:1;
gboolean has_generic_jit_info:1;
+ gboolean from_aot:1;
MonoJitExceptionInfo clauses [MONO_ZERO_LEN_ARRAY];
/* There is an optional MonoGenericJitInfo after the clauses */
};
gpointer *static_data;
};
+/*
+ * We have two unloading states because the domain
+ * must remain fully functional while AppDomain::DomainUnload is
+ * processed.
+ * After that unloading began and all domain facilities are teared down
+ * such as execution of new threadpool jobs.
+ */
typedef enum {
MONO_APPDOMAIN_CREATED,
+ MONO_APPDOMAIN_UNLOADING_START,
MONO_APPDOMAIN_UNLOADING,
MONO_APPDOMAIN_UNLOADED
} MonoAppDomainState;
typedef struct _MonoJitCodeHash MonoJitCodeHash;
struct _MonoDomain {
+ /*
+ * This lock must never be taken before the loader lock,
+ * i.e. if both are taken by the same thread, the loader lock
+ * must taken first.
+ */
CRITICAL_SECTION lock;
MonoMemPool *mp;
MonoCodeManager *code_mp;
MonoGHashTable *type_init_exception_hash;
/* maps delegate trampoline addr -> delegate object */
MonoGHashTable *delegate_hash_table;
-#define MONO_DOMAIN_LAST_GC_TRACKED delegate_hash_table
+ /* typeof (void) */
+ MonoObject *typeof_void;
+#define MONO_DOMAIN_LAST_GC_TRACKED typeof_void
guint32 state;
/* Needed by Thread:GetDomainID() */
gint32 domain_id;
/* Used when accessing 'domain_assemblies' */
CRITICAL_SECTION assemblies_lock;
- GHashTable *shared_generics_hash;
GHashTable *method_rgctx_hash;
GHashTable *generic_virtual_cases;
/* Information maintained by the JIT engine */
gpointer runtime_info;
+
+ /*thread pool jobs, used to coordinate shutdown.*/
+ int threadpool_jobs;
+ HANDLE cleanup_semaphore;
};
typedef struct {
const AssemblyVersionSet version_sets [2];
} MonoRuntimeInfo;
-#define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
-#define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
-#define mono_domain_assemblies_lock(domain) EnterCriticalSection(&(domain)->assemblies_lock)
-#define mono_domain_assemblies_unlock(domain) LeaveCriticalSection(&(domain)->assemblies_lock)
-#define mono_domain_jit_code_hash_lock(domain) EnterCriticalSection(&(domain)->jit_code_hash_lock)
-#define mono_domain_jit_code_hash_unlock(domain) LeaveCriticalSection(&(domain)->jit_code_hash_lock)
+#define mono_domain_lock(domain) mono_locks_acquire(&(domain)->lock, DomainLock)
+#define mono_domain_unlock(domain) mono_locks_release(&(domain)->lock, DomainLock)
+#define mono_domain_assemblies_lock(domain) mono_locks_acquire(&(domain)->assemblies_lock, DomainAssembliesLock)
+#define mono_domain_assemblies_unlock(domain) mono_locks_release(&(domain)->assemblies_lock, DomainAssembliesLock)
+#define mono_domain_jit_code_hash_lock(domain) mono_locks_acquire(&(domain)->jit_code_hash_lock, DomainJitCodeHashLock)
+#define mono_domain_jit_code_hash_unlock(domain) mono_locks_release(&(domain)->jit_code_hash_lock, DomainJitCodeHashLock)
typedef MonoDomain* (*MonoLoadFunc) (const char *filename, const char *runtime_version);
MonoJitInfo*
mono_domain_lookup_shared_generic (MonoDomain *domain, MonoMethod *method) MONO_INTERNAL;
-void
-mono_domain_register_shared_generic (MonoDomain *domain, MonoMethod *method, MonoJitInfo *jit_info) MONO_INTERNAL;
-
char *
-mono_make_shadow_copy (const char *filename);
+mono_make_shadow_copy (const char *filename) MONO_INTERNAL;
+
+gboolean
+mono_is_shadow_copy_enabled (MonoDomain *domain, const gchar *dir_name) MONO_INTERNAL;
gpointer
mono_domain_alloc (MonoDomain *domain, guint size) MONO_INTERNAL;
gpointer
mono_domain_alloc0 (MonoDomain *domain, guint size) MONO_INTERNAL;
+void*
+mono_domain_code_reserve (MonoDomain *domain, int size) MONO_INTERNAL;
+
+void*
+mono_domain_code_reserve_align (MonoDomain *domain, int size, int alignment) MONO_INTERNAL;
+
+void
+mono_domain_code_commit (MonoDomain *domain, void *data, int size, int newsize) MONO_INTERNAL;
+
+void
+mono_domain_code_foreach (MonoDomain *domain, MonoCodeManagerFunc func, void *user_data) MONO_INTERNAL;
+
/*
* Installs a new function which is used to return a MonoJitInfo for a method inside
* an AOT module.
MonoImageOpenStatus *status,
gboolean refonly) MONO_INTERNAL;
+void mono_set_private_bin_path_from_config (MonoDomain *domain) MONO_INTERNAL;
+
+int mono_framework_version (void) MONO_INTERNAL;
+
#endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */