#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);
#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)
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;
}
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.