/* This is the list of runtime versions supported by this JIT.
*/
static const MonoRuntimeInfo supported_runtimes[] = {
- {"v4.0.30319","4.5", NULL, { {4,0,0,0}, {10,0,0,0}, {4,0,0,0}, {4,0,0,0}, {4,0,0,0} } },
- {"mobile", "2.1", "7cec85d7bea7798e", { {2,0,5,0}, {10,0,0,0}, {2,0,5,0}, {2,0,5,0}, {4,0,0,0} } },
- {"moonlight", "2.1", NULL, { {2,0,5,0}, { 9,0,0,0}, {3,5,0,0}, {3,0,0,0}, NOT_AVAIL } },
+ {"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
}
mono_appdomains_unlock ();
-#ifdef HAVE_BOEHM_GC
- 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");
-#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 ();
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;
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);
if (create_domain_hook)
create_domain_hook (domain);
- mono_profiler_appdomain_loaded (domain, MONO_PROFILE_OK);
+ MONO_PROFILER_RAISE (domain_loaded, (domain));
return domain;
}
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;
mono_counters_register ("Max HashTable Chain Length", MONO_COUNTER_INT|MONO_COUNTER_METADATA, &mono_g_hash_table_max_chain_length);
mono_gc_base_init ();
- mono_thread_info_attach (&dummy);
+ mono_thread_info_attach ();
mono_coop_mutex_init_recursive (&appdomains_mutex);
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;
}
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);
* 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);
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);
/*
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;
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)
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);
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);
SET_APPCONTEXT (new_context);
}
+void
+mono_context_set_handle (MonoAppContextHandle new_context)
+{
+ SET_APPCONTEXT (MONO_HANDLE_RAW (new_context));
+}
+
/**
* mono_context_get:
*
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:
* \param context the context to operate on.
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 \c MonoImage* for the \c mscorlib.dll assembly