Author: zoltan
Date: 2005-03-20 04:44:18 -0500 (Sun, 20 Mar 2005)
New Revision: 42035
Modified:
trunk/mono/mono/mini/ChangeLog
trunk/mono/mono/mini/mini-x86.c
Log:
2005-03-20 Zoltan Varga <[EMAIL PROTECTED]>
* mini-x86.c (emit_tls_get): Move tls handling into a separate helper
function.
Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog 2005-03-19 23:55:09 UTC (rev 42034)
+++ trunk/mono/mono/mini/ChangeLog 2005-03-20 09:44:18 UTC (rev 42035)
@@ -1,3 +1,7 @@
+2005-03-20 Zoltan Varga <[EMAIL PROTECTED]>
+
+ * mini-x86.c (emit_tls_get): Move tls handling into a separate helper
function.
+
2005-03-19 Zoltan Varga <[EMAIL PROTECTED]>
* mini.h mini.c: Add mono_get_jit_tls_key ().
Modified: trunk/mono/mono/mini/mini-x86.c
===================================================================
--- trunk/mono/mono/mini/mini-x86.c 2005-03-19 23:55:09 UTC (rev 42034)
+++ trunk/mono/mono/mini/mini-x86.c 2005-03-20 09:44:18 UTC (rev 42035)
@@ -2707,6 +2707,27 @@
return code;
}
+static guint8*
+emit_tls_get (guint8* code, int dreg, int tls_offset)
+{
+#ifdef PLATFORM_WIN32
+ /*
+ * See the Under the Hood article in the May 1996 issue of Microsoft
Systems
+ * Journal and/or a disassembly of the TlsGet () function.
+ */
+ g_assert (tls_offset < 64);
+ x86_prefix (code, X86_FS_PREFIX);
+ x86_mov_reg_mem (code, dreg, 0x18, 4);
+ /* Dunno what this does but TlsGetValue () contains it */
+ x86_alu_membase_imm (code, X86_AND, dreg, 0x34, 0);
+ x86_mov_reg_membase (code, dreg, dreg, 3600 + (tls_offset * 4), 4);
+#else
+ x86_prefix (code, X86_GS_PREFIX);
+ x86_mov_reg_mem (code, dreg, tls_offset, 4);
+#endif
+ return code;
+}
+
#define REAL_PRINT_REG(text,reg) \
mono_assert (reg >= 0); \
x86_push_reg (code, X86_EAX); \
@@ -3963,20 +3984,7 @@
break;
}
case OP_TLS_GET: {
-#ifdef PLATFORM_WIN32
- /*
- * See the Under the Hood article in the May 1996 issue
of Microsoft Systems
- * Journal and/or a disassembly of the TlsGet ()
function.
- */
- x86_prefix (code, X86_FS_PREFIX);
- x86_mov_reg_mem (code, ins->dreg, 0x18, 4);
- /* Dunno what this does but TlsGetValue () contains it
*/
- x86_alu_membase_imm (code, X86_AND, ins->dreg, 0x34, 0);
- x86_mov_reg_membase (code, ins->dreg, ins->dreg, 3600 +
(ins->inst_offset * 4), 4);
-#else
- x86_prefix (code, X86_GS_PREFIX);
- x86_mov_reg_mem (code, ins->dreg, ins->inst_offset, 4);
-#endif
+ code = emit_tls_get (code, ins->dreg, ins->inst_offset);
break;
}
case OP_ATOMIC_ADD_I4: {
@@ -4192,18 +4200,11 @@
if (lmf_tls_offset != -1) {
guint8 *buf;
+ code = emit_tls_get ( code, X86_EAX, lmf_tls_offset);
#ifdef PLATFORM_WIN32
/* The TLS key actually contains a pointer to the
MonoJitTlsData structure */
- x86_prefix (code, X86_FS_PREFIX);
- x86_mov_reg_mem (code, X86_EAX, 0x18, 4);
- /* Dunno what this does but TlsGetValue () contains it
*/
- x86_alu_membase_imm (code, X86_AND, X86_EAX, 0x34, 0);
- x86_mov_reg_membase (code, X86_EAX, X86_EAX, 3600 +
(lmf_tls_offset * 4), 4);
/* FIXME: Add a separate key for LMF to avoid this */
x86_alu_reg_imm (code, X86_ADD, X86_EAX,
G_STRUCT_OFFSET (MonoJitTlsData, lmf));
-#else
- x86_prefix (code, X86_GS_PREFIX);
- x86_mov_reg_mem (code, X86_EAX, lmf_tls_offset, 4);
#endif
x86_test_reg_reg (code, X86_EAX, X86_EAX);
buf = code;
@@ -4242,18 +4243,11 @@
*/
if (lmf_tls_offset != -1) {
/* Load lmf quicky using the GS register */
+ code = emit_tls_get (code, X86_EAX, lmf_tls_offset);
#ifdef PLATFORM_WIN32
/* The TLS key actually contains a pointer to the
MonoJitTlsData structure */
- x86_prefix (code, X86_FS_PREFIX);
- x86_mov_reg_mem (code, X86_EAX, 0x18, 4);
- /* Dunno what this does but TlsGetValue () contains it
*/
- x86_alu_membase_imm (code, X86_AND, X86_EAX, 0x34, 0);
- x86_mov_reg_membase (code, X86_EAX, X86_EAX, 3600 +
(lmf_tls_offset * 4), 4);
/* FIXME: Add a separate key for LMF to avoid this */
x86_alu_reg_imm (code, X86_ADD, X86_EAX,
G_STRUCT_OFFSET (MonoJitTlsData, lmf));
-#else
- x86_prefix (code, X86_GS_PREFIX);
- x86_mov_reg_mem (code, X86_EAX, lmf_tls_offset, 4);
#endif
}
else {
@@ -4660,32 +4654,30 @@
struct sigaltstack sa;
#endif
-#ifdef PLATFORM_WIN32
- /*
- * We need to init this multiple times, since when we are first called,
the key might not
- * be initialized yet.
- */
- if (!getenv ("MONO_NO_TLS")) {
- appdomain_tls_offset = mono_domain_get_tls_key ();
- lmf_tls_offset = mono_get_jit_tls_key ();
- thread_tls_offset = mono_thread_get_tls_key ();
-
- /* Only 64 tls entries can be accessed using inline code */
- if (appdomain_tls_offset >= 64)
- appdomain_tls_offset = -1;
- if (lmf_tls_offset >= 64)
- lmf_tls_offset = -1;
- if (thread_tls_offset >= 64)
- thread_tls_offset = -1;
- }
-#endif
-
if (!tls_offset_inited) {
- tls_offset_inited = TRUE;
if (!getenv ("MONO_NO_TLS")) {
+#ifdef PLATFORM_WIN32
+ /*
+ * We need to init this multiple times, since when we
are first called, the key might not
+ * be initialized yet.
+ */
+ appdomain_tls_offset = mono_domain_get_tls_key ();
+ lmf_tls_offset = mono_get_jit_tls_key ();
+ thread_tls_offset = mono_thread_get_tls_key ();
+
+ /* Only 64 tls entries can be accessed using inline
code */
+ if (appdomain_tls_offset >= 64)
+ appdomain_tls_offset = -1;
+ if (lmf_tls_offset >= 64)
+ lmf_tls_offset = -1;
+ if (thread_tls_offset >= 64)
+ thread_tls_offset = -1;
+#else
+ tls_offset_inited = TRUE;
appdomain_tls_offset = mono_domain_get_tls_offset ();
lmf_tls_offset = mono_get_lmf_tls_offset ();
thread_tls_offset = mono_thread_get_tls_offset ();
+#endif
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches