#if (defined(__i386__) || defined(__x86_64__)) && !defined(HOST_WIN32)
#define NO_TLS_SET_VALUE
#endif
-
-#ifdef HAVE_KW_THREAD
-static __thread MonoDomain * tls_appdomain MONO_TLS_FAST;
+#ifdef MONO_HAVE_FAST_TLS
-#define GET_APPDOMAIN() tls_appdomain
+MONO_FAST_TLS_DECLARE(tls_appdomain);
+
+#define GET_APPDOMAIN() ((MonoDomain*)MONO_FAST_TLS_GET(tls_appdomain))
#ifdef NO_TLS_SET_VALUE
#define SET_APPDOMAIN(x) do { \
- tls_appdomain = x; \
+ MONO_FAST_TLS_SET (tls_appdomain,x); \
} while (FALSE)
#else
#define SET_APPDOMAIN(x) do { \
- tls_appdomain = x; \
+ MONO_FAST_TLS_SET (tls_appdomain,x); \
TlsSetValue (appdomain_thread_id, x); \
} while (FALSE)
#endif
-#else /* !HAVE_KW_THREAD */
+#else /* !MONO_HAVE_FAST_TLS */
#define GET_APPDOMAIN() ((MonoDomain *)TlsGetValue (appdomain_thread_id))
#define SET_APPDOMAIN(x) TlsSetValue (appdomain_thread_id, x);
domain->jit_info_table = jit_info_table_new (domain);
domain->jit_info_free_queue = NULL;
domain->finalizable_objects_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
-#ifndef HAVE_SGEN_GC
domain->track_resurrection_handles_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
-#endif
InitializeCriticalSection (&domain->lock);
InitializeCriticalSection (&domain->assemblies_lock);
#ifdef HOST_WIN32
/* Avoid system error message boxes. */
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
-
+#ifdef ENABLE_COREE
mono_load_coree (exe_filename);
+#endif
#endif
mono_perfcounters_init ();
mono_gc_base_init ();
+ MONO_FAST_TLS_INIT (tls_appdomain);
appdomain_thread_id = TlsAlloc ();
InitializeCriticalSection (&appdomains_mutex);
* exe_image, and close it during shutdown.
*/
get_runtimes_from_exe (exe_filename, &exe_image, runtimes);
-#ifdef HOST_WIN32
+#ifdef ENABLE_COREE
if (!exe_image) {
exe_image = mono_assembly_open_from_bundle (exe_filename, NULL, FALSE);
if (!exe_image)
return ass;
}
-#ifndef HAVE_SGEN_GC
static void
free_slist (gpointer key, gpointer value, gpointer user_data)
{
g_slist_free (value);
}
-#endif
-#if HAVE_SGEN_GC
static void
unregister_vtable_reflection_type (MonoVTable *vtable)
{
MonoObject *type = vtable->type;
if (type->vtable->klass != mono_defaults.monotype_class)
- mono_gc_deregister_root ((char*)&vtable->type);
+ MONO_GC_UNREGISTER_ROOT_IF_MOVING (vtable->type);
}
-#endif
void
mono_domain_free (MonoDomain *domain, gboolean force)
domain->type_init_exception_hash = NULL;
}
-#if HAVE_SGEN_GC
if (domain->class_vtable_array) {
int i;
for (i = 0; i < domain->class_vtable_array->len; ++i)
unregister_vtable_reflection_type (g_ptr_array_index (domain->class_vtable_array, i));
}
-#endif
/* This needs to be done before closing assemblies */
mono_gc_clear_domain (domain);
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
MonoAssembly *ass = tmp->data;
- mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Unloading domain %s %p, assembly %s %p, refcount=%d\n", domain->friendly_name, domain, ass->aname.name, ass, ass->ref_count);
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Unloading domain %s[%p], assembly %s[%p], ref_count=%d\n", domain->friendly_name, domain, ass->aname.name, ass, ass->ref_count);
if (!mono_assembly_close_except_image_pools (ass))
tmp->data = NULL;
}
g_hash_table_destroy (domain->finalizable_objects_hash);
domain->finalizable_objects_hash = NULL;
-#ifndef HAVE_SGEN_GC
if (domain->track_resurrection_objects_hash) {
g_hash_table_foreach (domain->track_resurrection_objects_hash, free_slist, NULL);
g_hash_table_destroy (domain->track_resurrection_objects_hash);
}
if (domain->track_resurrection_handles_hash)
g_hash_table_destroy (domain->track_resurrection_handles_hash);
-#endif
if (domain->method_rgctx_hash) {
g_hash_table_destroy (domain->method_rgctx_hash);
domain->method_rgctx_hash = NULL;
mono_domain_unlock (domain);
}
+#if defined(__native_client_codegen__) && defined(__native_client__)
+/*
+ * Given the temporary buffer (allocated by mono_domain_code_reserve) into which
+ * we are generating code, return a pointer to the destination in the dynamic
+ * code segment into which the code will be copied when mono_domain_code_commit
+ * is called.
+ * LOCKING: Acquires the domain lock.
+ */
+void *
+nacl_domain_get_code_dest (MonoDomain *domain, void *data)
+{
+ void *dest;
+ mono_domain_lock (domain);
+ dest = nacl_code_manager_get_code_dest (domain->code_mp, data);
+ mono_domain_unlock (domain);
+ return dest;
+}
+
+/*
+ * Convenience function which calls mono_domain_code_commit to validate and copy
+ * the code. The caller sets *buf_base and *buf_size to the start and size of
+ * the buffer (allocated by mono_domain_code_reserve), and *code_end to the byte
+ * after the last instruction byte. On return, *buf_base will point to the start
+ * of the copied in the code segment, and *code_end will point after the end of
+ * the copied code.
+ */
+void
+nacl_domain_code_validate (MonoDomain *domain, guint8 **buf_base, int buf_size, guint8 **code_end)
+{
+ guint8 *tmp = nacl_domain_get_code_dest (domain, *buf_base);
+ mono_domain_code_commit (domain, *buf_base, buf_size, *code_end - *buf_base);
+ *code_end = tmp + (*code_end - *buf_base);
+ *buf_base = tmp;
+}
+
+#else
+
+/* no-op versions of Native Client functions */
+
+void *
+nacl_domain_get_code_dest (MonoDomain *domain, void *data)
+{
+ return data;
+}
+
+void
+nacl_domain_code_validate (MonoDomain *domain, guint8 **buf_base, int buf_size, guint8 **code_end)
+{
+}
+
+#endif
+
/*
* mono_domain_code_foreach:
* Iterate over the code thunks of the code manager of @domain.