#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;
/* Used when accessing 'domain_assemblies' */
CRITICAL_SECTION assemblies_lock;
- GHashTable *shared_generics_hash;
GHashTable *method_rgctx_hash;
GHashTable *generic_virtual_cases;
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_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.