X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fdomain.c;h=b0e7068104da81833aea19ca355510216da3032f;hb=30cddad5fb4c3d290906a6e6c33ecd8b07d8b48c;hp=020b0dd00c4406bc0d482714b2af17e65836b0d6;hpb=94b8270e9bdbd9280de1ec144af20877d8c8d055;p=mono.git diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 020b0dd00c4..b0e7068104d 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -1,5 +1,6 @@ -/* - * domain.c: MonoDomain functions +/** + * \file + * MonoDomain functions * * Author: * Dietmar Maurer (dietmar@ximian.com) @@ -31,12 +32,11 @@ #include #include #include -#include +#include +#include #include #include -#include #include -#include #include #include #include @@ -44,47 +44,22 @@ #include #include #include +#include #include #include #include //#define DEBUG_DOMAIN_UNLOAD 1 -/* we need to use both the Tls* functions and __thread because - * some archs may generate faster jit code with one meachanism - * or the other (we used to do it because tls slots were GC-tracked, - * but we can't depend on this). - */ -static MonoNativeTlsKey appdomain_thread_id; - -#ifdef MONO_HAVE_FAST_TLS - -MONO_FAST_TLS_DECLARE(tls_appdomain); - -#define GET_APPDOMAIN() ((MonoDomain*)MONO_FAST_TLS_GET(tls_appdomain)) - +#define GET_APPDOMAIN() ((MonoDomain*)mono_tls_get_domain ()) #define SET_APPDOMAIN(x) do { \ MonoThreadInfo *info; \ - MONO_FAST_TLS_SET (tls_appdomain,x); \ - mono_native_tls_set_value (appdomain_thread_id, x); \ + mono_tls_set_domain (x); \ info = mono_thread_info_current (); \ if (info) \ mono_thread_info_tls_set (info, TLS_KEY_DOMAIN, (x)); \ } while (FALSE) -#else /* !MONO_HAVE_FAST_TLS */ - -#define GET_APPDOMAIN() ((MonoDomain *)mono_native_tls_get_value (appdomain_thread_id)) -#define SET_APPDOMAIN(x) do { \ - MonoThreadInfo *info; \ - mono_native_tls_set_value (appdomain_thread_id, x); \ - info = mono_thread_info_current (); \ - if (info) \ - mono_thread_info_tls_set (info, TLS_KEY_DOMAIN, (x)); \ - } while (FALSE) - -#endif - #define GET_APPCONTEXT() (mono_thread_internal_current ()->current_appcontext) #define SET_APPCONTEXT(x) MONO_OBJECT_SETREF (mono_thread_internal_current (), current_appcontext, (x)) @@ -119,14 +94,18 @@ typedef struct { static const MonoRuntimeInfo *current_runtime = NULL; +#define NOT_AVAIL {0xffffU,0xffffU,0xffffU,0xffffU} + /* This is the list of runtime versions supported by this JIT. */ static const MonoRuntimeInfo supported_runtimes[] = { - {"v4.0.30319","4.5", { {4,0,0,0}, {10,0,0,0}, {4,0,0,0}, {4,0,0,0} } }, - {"mobile", "2.1", { {2,0,5,0}, {10,0,0,0}, {2,0,5,0}, {2,0,5,0} } }, - {"moonlight", "2.1", { {2,0,5,0}, { 9,0,0,0}, {3,5,0,0}, {3,0,0,0} } }, + {"v4.0.30319","4.5", { {4,0,0,0}, {10,0,0,0}, {4,0,0,0}, {4,0,0,0}, {4,0,0,0} } }, + {"mobile", "2.1", { {2,0,5,0}, {10,0,0,0}, {2,0,5,0}, {2,0,5,0}, {4,0,0,0} } }, + {"moonlight", "2.1", { {2,0,5,0}, { 9,0,0,0}, {3,5,0,0}, {3,0,0,0}, NOT_AVAIL } }, }; +#undef NOT_AVAIL + /* The stable runtime version */ #define DEFAULT_RUNTIME_VERSION "v4.0.30319" @@ -144,26 +123,6 @@ get_runtimes_from_exe (const char *exe_file, MonoImage **exe_image, const MonoRu static const MonoRuntimeInfo* get_runtime_by_version (const char *version); -MonoNativeTlsKey -mono_domain_get_tls_key (void) -{ - return appdomain_thread_id; -} - -gint32 -mono_domain_get_tls_offset (void) -{ - int offset = -1; - -#ifdef HOST_WIN32 - if (appdomain_thread_id) - offset = appdomain_thread_id; -#else - MONO_THREAD_VAR_OFFSET (tls_appdomain, offset); -#endif - return offset; -} - #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1)) #define ALIGN_PTR_TO(ptr,align) (gpointer)((((gssize)(ptr)) + (align - 1)) & (~(align - 1))) @@ -267,12 +226,12 @@ mono_install_free_domain_hook (MonoFreeDomainFunc func) /** * mono_string_equal: - * @s1: First string to compare - * @s2: Second string to compare + * \param s1 First string to compare + * \param s2 Second string to compare * - * Compares two `MonoString*` instances ordinally for equality. + * Compares two \c MonoString* instances ordinally for equality. * - * Returns FALSE if the strings differ. + * \returns FALSE if the strings differ. */ gboolean mono_string_equal (MonoString *s1, MonoString *s2) @@ -290,10 +249,10 @@ mono_string_equal (MonoString *s1, MonoString *s2) /** * mono_string_hash: - * @s: the string to hash + * \param s the string to hash * - * Compute the hash for a `MonoString*` - * Returns the hash for the string. + * Compute the hash for a \c MonoString* + * \returns the hash for the string. */ guint mono_string_hash (MonoString *s) @@ -391,11 +350,11 @@ static guint32 domain_shadow_serial = 0L; * mono_domain_create: * * Creates a new application domain, the unmanaged representation - * of the actual domain. Usually you will want to create the + * of the actual domain. * * Application domains provide an isolation facilty for assemblies. You * can load assemblies and execute code in them that will not be visible - * to other application domains. This is a runtime-based virtualization + * to other application domains. This is a runtime-based virtualization * technology. * * It is possible to unload domains, which unloads the assemblies and @@ -405,7 +364,7 @@ static guint32 domain_shadow_serial = 0L; * structures, along a dedicated code manager to hold code that is * associated with the domain. * - * Returns: New initialized MonoDomain, with no configuration or assemblies + * \returns New initialized \c MonoDomain, with no configuration or assemblies * loaded into it. */ MonoDomain * @@ -427,25 +386,19 @@ mono_domain_create (void) } mono_appdomains_unlock (); -#ifdef HAVE_BOEHM_GC - /* - * Boehm doesn't like roots inside GC allocated objects, and alloc_fixed returns - * a GC_MALLOC-ed object, contrary to the api docs. This causes random crashes when - * running the corlib test suite. - * To solve this, we pass a NULL descriptor, and don't register roots. - */ - domain = (MonoDomain *)mono_gc_alloc_fixed (sizeof (MonoDomain), NULL, MONO_ROOT_SOURCE_DOMAIN, "domain object"); -#else - domain = (MonoDomain *)mono_gc_alloc_fixed (sizeof (MonoDomain), domain_gc_desc, MONO_ROOT_SOURCE_DOMAIN, "domain object"); - mono_gc_register_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED), G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_LAST_GC_TRACKED) - G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_FIRST_GC_TRACKED), MONO_GC_DESCRIPTOR_NULL, MONO_ROOT_SOURCE_DOMAIN, "misc domain fields"); -#endif + if (!mono_gc_is_moving ()) { + domain = (MonoDomain *)mono_gc_alloc_fixed (sizeof (MonoDomain), MONO_GC_DESCRIPTOR_NULL, MONO_ROOT_SOURCE_DOMAIN, "domain object"); + } else { + domain = (MonoDomain *)mono_gc_alloc_fixed (sizeof (MonoDomain), domain_gc_desc, MONO_ROOT_SOURCE_DOMAIN, "domain object"); + mono_gc_register_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED), G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_LAST_GC_TRACKED) - G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_FIRST_GC_TRACKED), MONO_GC_DESCRIPTOR_NULL, MONO_ROOT_SOURCE_DOMAIN, "misc domain fields"); + } domain->shadow_serial = shadow_serial; domain->domain = NULL; domain->setup = NULL; domain->friendly_name = NULL; domain->search_path = NULL; - mono_profiler_appdomain_event (domain, MONO_PROFILE_START_LOAD); + MONO_PROFILER_RAISE (domain_loading, (domain)); domain->mp = mono_mempool_new (); domain->code_mp = mono_code_manager_new (); @@ -456,7 +409,6 @@ mono_domain_create (void) domain->assembly_bindings_parsed = FALSE; domain->class_vtable_array = g_ptr_array_new (); domain->proxy_vtable_hash = g_hash_table_new ((GHashFunc)mono_ptrarray_hash, (GCompareFunc)mono_ptrarray_equal); - domain->static_data_array = NULL; mono_jit_code_hash_init (&domain->jit_code_hash); domain->ldstr_table = mono_g_hash_table_new_type ((GHashFunc)mono_string_hash, (GCompareFunc)mono_string_equal, MONO_HASH_KEY_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, "domain string constants table"); domain->num_jit_info_tables = 1; @@ -478,8 +430,8 @@ mono_domain_create (void) mono_appdomains_unlock (); #ifndef DISABLE_PERFCOUNTERS - mono_perfcounters->loader_appdomains++; - mono_perfcounters->loader_total_appdomains++; + InterlockedIncrement (&mono_perfcounters->loader_appdomains); + InterlockedIncrement (&mono_perfcounters->loader_total_appdomains); #endif mono_debug_domain_create (domain); @@ -487,7 +439,7 @@ mono_domain_create (void) if (create_domain_hook) create_domain_hook (domain); - mono_profiler_appdomain_loaded (domain, MONO_PROFILE_OK); + MONO_PROFILER_RAISE (domain_loaded, (domain)); return domain; } @@ -512,7 +464,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * MonoAssembly *ass = NULL; MonoImageOpenStatus status = MONO_IMAGE_OK; const MonoRuntimeInfo* runtimes [G_N_ELEMENTS (supported_runtimes) + 1] = { NULL }; - int n, dummy; + int n; #ifdef DEBUG_DOMAIN_UNLOAD debug_domain_unload = TRUE; @@ -529,13 +481,13 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * #ifndef HOST_WIN32 mono_w32handle_init (); mono_w32handle_namespace_init (); - wapi_init (); #endif mono_w32mutex_init (); mono_w32semaphore_init (); mono_w32event_init (); mono_w32process_init (); + mono_w32file_init (); #ifndef DISABLE_PERFCOUNTERS mono_perfcounters_init (); @@ -546,11 +498,10 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_counters_register ("Max code space allocated in a domain", MONO_COUNTER_INT|MONO_COUNTER_JIT, &max_domain_code_alloc); mono_counters_register ("Total code space allocated", MONO_COUNTER_INT|MONO_COUNTER_JIT, &total_domain_code_alloc); - mono_gc_base_init (); - mono_thread_info_attach (&dummy); + mono_counters_register ("Max HashTable Chain Length", MONO_COUNTER_INT|MONO_COUNTER_METADATA, &mono_g_hash_table_max_chain_length); - MONO_FAST_TLS_INIT (tls_appdomain); - mono_native_tls_alloc (&appdomain_thread_id, NULL); + mono_gc_base_init (); + mono_thread_info_attach (); mono_coop_mutex_init_recursive (&appdomains_mutex); @@ -562,9 +513,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_reflection_init (); mono_runtime_init_tls (); - /* FIXME: When should we release this memory? */ - MONO_GC_REGISTER_ROOT_FIXED (appdomains_list, MONO_ROOT_SOURCE_DOMAIN, "domains list"); - domain = mono_domain_create (); mono_root_domain = domain; @@ -814,7 +762,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * domain->friendly_name = g_path_get_basename (filename); - mono_profiler_appdomain_name (domain, domain->friendly_name); + MONO_PROFILER_RAISE (domain_name, (domain, domain->friendly_name)); return domain; } @@ -838,8 +786,8 @@ mono_init (const char *domain_name) /** * mono_init_from_assembly: - * @domain_name: name to give to the initial domain - * @filename: filename to load on startup + * \param domain_name name to give to the initial domain + * \param filename filename to load on startup * * Used by the runtime, users should use mono_jit_init instead. * @@ -850,7 +798,7 @@ mono_init (const char *domain_name) * provided executable. The version is determined by looking at the exe * configuration file and the version PE field) * - * Returns: the initial domain. + * \returns the initial domain. */ MonoDomain * mono_init_from_assembly (const char *domain_name, const char *filename) @@ -861,15 +809,15 @@ mono_init_from_assembly (const char *domain_name, const char *filename) /** * mono_init_version: * - * Used by the runtime, users should use mono_jit_init instead. + * Used by the runtime, users should use \c mono_jit_init instead. * - * Creates the initial application domain and initializes the mono_defaults + * Creates the initial application domain and initializes the \c mono_defaults * structure. * * This function is guaranteed to not run any IL code. * The runtime is initialized using the provided rutime version. * - * Returns: the initial domain. + * \returns the initial domain. */ MonoDomain * mono_init_version (const char *domain_name, const char *version) @@ -897,14 +845,10 @@ mono_cleanup (void) mono_images_cleanup (); mono_metadata_cleanup (); - mono_native_tls_free (appdomain_thread_id); mono_coop_mutex_destroy (&appdomains_mutex); mono_w32process_cleanup (); - -#ifndef HOST_WIN32 - wapi_cleanup (); -#endif + mono_w32file_cleanup (); } void @@ -933,11 +877,11 @@ mono_get_root_domain (void) /** * mono_domain_get: * - * This method returns the value of the current MonoDomain that this thread + * This method returns the value of the current \c MonoDomain that this thread * and code are running under. To obtain the root domain use - * mono_get_root_domain() API. + * \c mono_get_root_domain API. * - * Returns: the current domain + * \returns the current domain */ MonoDomain * mono_domain_get () @@ -975,9 +919,9 @@ mono_domain_set_internal_with_options (MonoDomain *domain, gboolean migrate_exce /** * mono_domain_set_internal: - * @domain: the new domain + * \param domain the new domain * - * Sets the current domain to @domain. + * Sets the current domain to \p domain. */ void mono_domain_set_internal (MonoDomain *domain) @@ -987,12 +931,12 @@ mono_domain_set_internal (MonoDomain *domain) /** * mono_domain_foreach: - * @func: function to invoke with the domain data - * @user_data: user-defined pointer that is passed to the supplied @func fo reach domain + * \param func function to invoke with the domain data + * \param user_data user-defined pointer that is passed to the supplied \p func fo reach domain * * Use this method to safely iterate over all the loaded application - * domains in the current runtime. The provided @func is invoked with a - * pointer to the MonoDomain and is given the value of the @user_data + * domains in the current runtime. The provided \p func is invoked with a + * pointer to the \c MonoDomain and is given the value of the \p user_data * parameter which can be used to pass state to your called routine. */ void @@ -1020,12 +964,11 @@ mono_domain_foreach (MonoDomainFunc func, gpointer user_data) mono_gc_free_fixed (copy); } +/* FIXME: maybe we should integrate this with mono_assembly_open? */ /** * mono_domain_assembly_open: - * @domain: the application domain - * @name: file name of the assembly - * - * fixme: maybe we should integrate this with mono_assembly_open ?? + * \param domain the application domain + * \param name file name of the assembly */ MonoAssembly * mono_domain_assembly_open (MonoDomain *domain, const char *name) @@ -1048,10 +991,10 @@ mono_domain_assembly_open (MonoDomain *domain, const char *name) current = mono_domain_get (); mono_domain_set (domain, FALSE); - ass = mono_assembly_open (name, NULL); + ass = mono_assembly_open_predicate (name, FALSE, FALSE, NULL, NULL, NULL); mono_domain_set (current, FALSE); } else { - ass = mono_assembly_open (name, NULL); + ass = mono_assembly_open_predicate (name, FALSE, FALSE, NULL, NULL, NULL); } return ass; @@ -1068,8 +1011,8 @@ unregister_vtable_reflection_type (MonoVTable *vtable) /** * mono_domain_free: - * @domain: the domain to release - * @force: if true, it allows the root domain to be released (used at shutdown only). + * \param domain the domain to release + * \param force if TRUE, it allows the root domain to be released (used at shutdown only). * * This releases the resources associated with the specific domain. * This is a low-level function that is invoked by the AppDomain infrastructure @@ -1090,14 +1033,10 @@ mono_domain_free (MonoDomain *domain, gboolean force) if (mono_dont_free_domains) return; - mono_profiler_appdomain_event (domain, MONO_PROFILE_START_UNLOAD); + MONO_PROFILER_RAISE (domain_unloading, (domain)); mono_debug_domain_unload (domain); - mono_appdomains_lock (); - appdomains_list [domain->domain_id] = NULL; - mono_appdomains_unlock (); - /* must do this early as it accesses fields and types */ if (domain->special_static_fields) { mono_alloc_special_static_data_free (domain->special_static_fields); @@ -1181,7 +1120,7 @@ mono_domain_free (MonoDomain *domain, gboolean force) * Send this after the assemblies have been unloaded and the domain is still in a * usable state. */ - mono_profiler_appdomain_event (domain, MONO_PROFILE_END_UNLOAD); + MONO_PROFILER_RAISE (domain_unloaded, (domain)); if (free_domain_hook) free_domain_hook (domain); @@ -1206,10 +1145,6 @@ mono_domain_free (MonoDomain *domain, gboolean force) domain->class_vtable_array = NULL; g_hash_table_destroy (domain->proxy_vtable_hash); domain->proxy_vtable_hash = NULL; - if (domain->static_data_array) { - mono_gc_free_fixed (domain->static_data_array); - domain->static_data_array = NULL; - } mono_internal_hash_table_destroy (&domain->jit_code_hash); /* @@ -1236,7 +1171,8 @@ mono_domain_free (MonoDomain *domain, gboolean force) mono_code_manager_invalidate (domain->code_mp); } else { #ifndef DISABLE_PERFCOUNTERS - mono_perfcounters->loader_bytes -= mono_mempool_get_allocated (domain->mp); + /* FIXME: use an explicit subtraction method as soon as it's available */ + InterlockedAdd (&mono_perfcounters->loader_bytes, -1 * mono_mempool_get_allocated (domain->mp)); #endif mono_mempool_destroy (domain->mp); domain->mp = NULL; @@ -1273,14 +1209,17 @@ mono_domain_free (MonoDomain *domain, gboolean force) domain->setup = NULL; - mono_gc_deregister_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED)); + if (mono_gc_is_moving ()) + mono_gc_deregister_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED)); - /* FIXME: anything else required ? */ + mono_appdomains_lock (); + appdomains_list [domain->domain_id] = NULL; + mono_appdomains_unlock (); mono_gc_free_fixed (domain); #ifndef DISABLE_PERFCOUNTERS - mono_perfcounters->loader_appdomains--; + InterlockedDecrement (&mono_perfcounters->loader_appdomains); #endif if (domain == mono_root_domain) @@ -1289,9 +1228,8 @@ mono_domain_free (MonoDomain *domain, gboolean force) /** * mono_domain_get_by_id: - * @domainid: the ID - * - * Returns: the domain for a specific domain id. + * \param domainid the ID + * \returns the domain for a specific domain id. */ MonoDomain * mono_domain_get_by_id (gint32 domainid) @@ -1308,14 +1246,14 @@ mono_domain_get_by_id (gint32 domainid) return domain; } -/* +/** * mono_domain_get_id: * * A domain ID is guaranteed to be unique for as long as the domain * using it is alive. It may be reused later once the domain has been * unloaded. * - * Returns: The unique ID for @domain. + * \returns The unique ID for \p domain. */ gint32 mono_domain_get_id (MonoDomain *domain) @@ -1323,13 +1261,13 @@ mono_domain_get_id (MonoDomain *domain) return domain->domain_id; } -/* +/** * mono_domain_get_friendly_name: * - * The returned string's lifetime is the same as @domain's. Consider + * The returned string's lifetime is the same as \p domain's. Consider * copying it if you need to store it somewhere. * - * Returns: The friendly name of @domain. Can be NULL if not yet set. + * \returns The friendly name of \p domain. Can be NULL if not yet set. */ const char * mono_domain_get_friendly_name (MonoDomain *domain) @@ -1349,7 +1287,7 @@ mono_domain_alloc (MonoDomain *domain, guint size) mono_domain_lock (domain); #ifndef DISABLE_PERFCOUNTERS - mono_perfcounters->loader_bytes += size; + InterlockedAdd (&mono_perfcounters->loader_bytes, size); #endif res = mono_mempool_alloc (domain->mp, size); mono_domain_unlock (domain); @@ -1369,7 +1307,7 @@ mono_domain_alloc0 (MonoDomain *domain, guint size) mono_domain_lock (domain); #ifndef DISABLE_PERFCOUNTERS - mono_perfcounters->loader_bytes += size; + InterlockedAdd (&mono_perfcounters->loader_bytes, size); #endif res = mono_mempool_alloc0 (domain->mp, size); mono_domain_unlock (domain); @@ -1447,13 +1385,21 @@ mono_domain_code_foreach (MonoDomain *domain, MonoCodeManagerFunc func, void *us mono_domain_unlock (domain); } - +/** + * mono_context_set: + */ void mono_context_set (MonoAppContext * new_context) { SET_APPCONTEXT (new_context); } +void +mono_context_set_handle (MonoAppContextHandle new_context) +{ + SET_APPCONTEXT (MONO_HANDLE_RAW (new_context)); +} + /** * mono_context_get: * @@ -1465,14 +1411,25 @@ mono_context_get (void) return GET_APPCONTEXT (); } +/** + * mono_context_get_handle: + * + * Returns: the current Mono Application Context. + */ +MonoAppContextHandle +mono_context_get_handle (void) +{ + return MONO_HANDLE_NEW (MonoAppContext, GET_APPCONTEXT ()); +} + /** * mono_context_get_id: - * @context: the context to operate on. + * \param context the context to operate on. * * Context IDs are guaranteed to be unique for the duration of a Mono * process; they are never reused. * - * Returns: The unique ID for @context. + * \returns The unique ID for \p context. */ gint32 mono_context_get_id (MonoAppContext *context) @@ -1482,9 +1439,8 @@ mono_context_get_id (MonoAppContext *context) /** * mono_context_get_domain_id: - * @context: the context to operate on. - * - * Returns: The ID of the domain that @context was created in. + * \param context the context to operate on. + * \returns The ID of the domain that \p context was created in. */ gint32 mono_context_get_domain_id (MonoAppContext *context) @@ -1492,46 +1448,10 @@ mono_context_get_domain_id (MonoAppContext *context) return context->domain_id; } -/* LOCKING: the caller holds the lock for this domain */ -void -mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointer data, guint32 *bitmap) -{ - /* Note [Domain Static Data Array]: - * - * Entry 0 in the array is the index of the next free slot. - * Entry 1 is the total size of the array. - */ - int next; - if (domain->static_data_array) { - int size = GPOINTER_TO_INT (domain->static_data_array [1]); - next = GPOINTER_TO_INT (domain->static_data_array [0]); - if (next >= size) { - /* 'data' is allocated by alloc_fixed */ - gpointer *new_array = (gpointer *)mono_gc_alloc_fixed (sizeof (gpointer) * (size * 2), MONO_GC_ROOT_DESCR_FOR_FIXED (size * 2), MONO_ROOT_SOURCE_DOMAIN, "static field list"); - mono_gc_memmove_aligned (new_array, domain->static_data_array, sizeof (gpointer) * size); - size *= 2; - new_array [1] = GINT_TO_POINTER (size); - mono_gc_free_fixed (domain->static_data_array); - domain->static_data_array = new_array; - } - } else { - int size = 32; - gpointer *new_array = (gpointer *)mono_gc_alloc_fixed (sizeof (gpointer) * size, MONO_GC_ROOT_DESCR_FOR_FIXED (size), MONO_ROOT_SOURCE_DOMAIN, "static field list"); - next = 2; - new_array [0] = GINT_TO_POINTER (next); - new_array [1] = GINT_TO_POINTER (size); - domain->static_data_array = new_array; - } - domain->static_data_array [next++] = data; - domain->static_data_array [0] = GINT_TO_POINTER (next); -} - /** * mono_get_corlib: - * - * Use this function to get the `MonoImage*` for the mscorlib.dll assembly - * - * Returns: The MonoImage for mscorlib.dll + * Use this function to get the \c MonoImage* for the \c mscorlib.dll assembly + * \returns The \c MonoImage for mscorlib.dll */ MonoImage* mono_get_corlib (void) @@ -1541,10 +1461,8 @@ mono_get_corlib (void) /** * mono_get_object_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Object`. - * - * Returns: The `MonoClass*` for the `System.Object` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Object . + * \returns The \c MonoClass* for the \c System.Object type. */ MonoClass* mono_get_object_class (void) @@ -1554,10 +1472,8 @@ mono_get_object_class (void) /** * mono_get_byte_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Byte`. - * - * Returns: The `MonoClass*` for the `System.Byte` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Byte . + * \returns The \c MonoClass* for the \c System.Byte type. */ MonoClass* mono_get_byte_class (void) @@ -1567,10 +1483,8 @@ mono_get_byte_class (void) /** * mono_get_void_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Void`. - * - * Returns: The `MonoClass*` for the `System.Void` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Void . + * \returns The \c MonoClass* for the \c System.Void type. */ MonoClass* mono_get_void_class (void) @@ -1580,10 +1494,8 @@ mono_get_void_class (void) /** * mono_get_boolean_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Boolean`. - * - * Returns: The `MonoClass*` for the `System.Boolean` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Boolean . + * \returns The \c MonoClass* for the \c System.Boolean type. */ MonoClass* mono_get_boolean_class (void) @@ -1593,10 +1505,8 @@ mono_get_boolean_class (void) /** * mono_get_sbyte_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.SByte`. - * - * Returns: The `MonoClass*` for the `System.SByte` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.SByte. + * \returns The \c MonoClass* for the \c System.SByte type. */ MonoClass* mono_get_sbyte_class (void) @@ -1606,10 +1516,8 @@ mono_get_sbyte_class (void) /** * mono_get_int16_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Int16`. - * - * Returns: The `MonoClass*` for the `System.Int16` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Int16 . + * \returns The \c MonoClass* for the \c System.Int16 type. */ MonoClass* mono_get_int16_class (void) @@ -1619,10 +1527,8 @@ mono_get_int16_class (void) /** * mono_get_uint16_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.UInt16`. - * - * Returns: The `MonoClass*` for the `System.UInt16` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.UInt16 . + * \returns The \c MonoClass* for the \c System.UInt16 type. */ MonoClass* mono_get_uint16_class (void) @@ -1632,10 +1538,8 @@ mono_get_uint16_class (void) /** * mono_get_int32_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Int32`. - * - * Returns: The `MonoClass*` for the `System.Int32` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Int32 . + * \returns The \c MonoClass* for the \c System.Int32 type. */ MonoClass* mono_get_int32_class (void) @@ -1645,10 +1549,8 @@ mono_get_int32_class (void) /** * mono_get_uint32_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.UInt32`. - * - * Returns: The `MonoClass*` for the `System.UInt32` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.UInt32 . + * \returns The \c MonoClass* for the \c System.UInt32 type. */ MonoClass* mono_get_uint32_class (void) @@ -1658,10 +1560,8 @@ mono_get_uint32_class (void) /** * mono_get_intptr_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.IntPtr`. - * - * Returns: The `MonoClass*` for the `System.IntPtr` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.IntPtr . + * \returns The \c MonoClass* for the \c System.IntPtr type. */ MonoClass* mono_get_intptr_class (void) @@ -1671,10 +1571,8 @@ mono_get_intptr_class (void) /** * mono_get_uintptr_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.UIntPtr`. - * - * Returns: The `MonoClass*` for the `System.UIntPtr` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.UIntPtr . + * \returns The \c MonoClass* for the \c System.UIntPtr type. */ MonoClass* mono_get_uintptr_class (void) @@ -1684,10 +1582,8 @@ mono_get_uintptr_class (void) /** * mono_get_int64_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Int64`. - * - * Returns: The `MonoClass*` for the `System.Int64` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Int64 . + * \returns The \c MonoClass* for the \c System.Int64 type. */ MonoClass* mono_get_int64_class (void) @@ -1697,10 +1593,8 @@ mono_get_int64_class (void) /** * mono_get_uint64_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.UInt64`. - * - * Returns: The `MonoClass*` for the `System.UInt64` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.UInt64 . + * \returns The \c MonoClass* for the \c System.UInt64 type. */ MonoClass* mono_get_uint64_class (void) @@ -1710,10 +1604,8 @@ mono_get_uint64_class (void) /** * mono_get_single_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Single` (32-bit floating points). - * - * Returns: The `MonoClass*` for the `System.Single` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Single (32-bit floating points). + * \returns The \c MonoClass* for the \c System.Single type. */ MonoClass* mono_get_single_class (void) @@ -1723,10 +1615,8 @@ mono_get_single_class (void) /** * mono_get_double_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Double` (64-bit floating points). - * - * Returns: The `MonoClass*` for the `System.Double` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Double (64-bit floating points). + * \returns The \c MonoClass* for the \c System.Double type. */ MonoClass* mono_get_double_class (void) @@ -1736,10 +1626,8 @@ mono_get_double_class (void) /** * mono_get_char_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Char`. - * - * Returns: The `MonoClass*` for the `System.Char` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Char . + * \returns The \c MonoClass* for the \c System.Char type. */ MonoClass* mono_get_char_class (void) @@ -1749,10 +1637,8 @@ mono_get_char_class (void) /** * mono_get_string_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.String`. - * - * Returns: The `MonoClass*` for the `System.String` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.String . + * \returns The \c MonoClass* for the \c System.String type. */ MonoClass* mono_get_string_class (void) @@ -1762,10 +1648,8 @@ mono_get_string_class (void) /** * mono_get_enum_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Enum`. - * - * Returns: The `MonoClass*` for the `System.Enum` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Enum . + * \returns The \c MonoClass* for the \c System.Enum type. */ MonoClass* mono_get_enum_class (void) @@ -1775,10 +1659,8 @@ mono_get_enum_class (void) /** * mono_get_array_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Array`. - * - * Returns: The `MonoClass*` for the `System.Array` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Array . + * \returns The \c MonoClass* for the \c System.Array type. */ MonoClass* mono_get_array_class (void) @@ -1788,10 +1670,8 @@ mono_get_array_class (void) /** * mono_get_thread_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Threading.Thread`. - * - * Returns: The `MonoClass*` for the `System.Threading.Thread` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Threading.Thread . + * \returns The \c MonoClass* for the \c System.Threading.Thread type. */ MonoClass* mono_get_thread_class (void) @@ -1801,10 +1681,8 @@ mono_get_thread_class (void) /** * mono_get_exception_class: - * - * Use this function to get the `MonoClass*` that the runtime is using for `System.Exception`. - * - * Returns: The `MonoClass*` for the `` type. + * Use this function to get the \c MonoClass* that the runtime is using for \c System.Exception . + * \returns The \c MonoClass* for the \c type. */ MonoClass* mono_get_exception_class (void) @@ -2062,3 +1940,24 @@ mono_domain_unlock (MonoDomain *domain) { mono_locks_coop_release (&domain->lock, DomainLock); } + +GPtrArray* +mono_domain_get_assemblies (MonoDomain *domain, gboolean refonly) +{ + GSList *tmp; + GPtrArray *assemblies; + MonoAssembly *ass; + + assemblies = g_ptr_array_new (); + mono_domain_assemblies_lock (domain); + for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { + ass = (MonoAssembly *)tmp->data; + if (refonly != ass->ref_only) + continue; + if (ass->corlib_internal) + continue; + g_ptr_array_add (assemblies, ass); + } + mono_domain_assemblies_unlock (domain); + return assemblies; +}