[mono/mono] [2 commits] 7f61dee2: [jit] Implement support for OP_TLS_GET_REG on amd64 linux.

"Zoltan Varga ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <000001421441f258-c97af943-590d-43ba-9d05-5b14e7130fcd-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/be5870433987...2594b363632d

   Commit: 7f61dee23f44b6c58ae8cd776b69dc1a4ca64ced
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-11-01 15:19:38 GMT
      URL: https://github.com/mono/mono/commit/7f61dee23f44b6c58ae8cd776b69dc1a4ca64ced

[jit] Implement support for OP_TLS_GET_REG on amd64 linux.

Changed paths:
  M mono/mini/cpu-amd64.md
  M mono/mini/mini-amd64.c
  M mono/mini/mini-amd64.h

Modified: mono/mini/cpu-amd64.md
===================================================================
@@ -292,7 +292,7 @@ amd64_set_xmmreg_r4: dest:f src1:f len:14 clob:m
 amd64_set_xmmreg_r8: dest:f src1:f len:14 clob:m
 amd64_save_sp_to_lmf: len:16
 tls_get: dest:i len:16
-tls_get_reg: dest:i src1:i len:20
+tls_get_reg: dest:i src1:i len:32
 atomic_add_i4: src1:b src2:i dest:i len:32
 atomic_add_new_i4: src1:b src2:i dest:i len:32
 atomic_exchange_i4: src1:b src2:i dest:a len:32

Modified: mono/mini/mini-amd64.c
===================================================================
@@ -3646,6 +3646,39 @@
 	return code;
 }
 
+static guint8*
+emit_tls_get_reg (guint8* code, int dreg, int offset_reg)
+{
+#ifdef TARGET_OSX
+	// FIXME: tls_gs_offset can change too, do these when calculating the tls offset
+	if (dreg != offset_reg)
+		amd64_mov_reg_reg (code, dreg, offset_reg, sizeof (gpointer));
+	amd64_shift_reg_imm (code, X86_SHL, dreg, 3);
+	if (tls_gs_offset)
+		amd64_alu_reg_imm (code, X86_ADD, dreg, tls_gs_offset);
+	x86_prefix (code, X86_GS_PREFIX);
+	amd64_mov_reg_membase (code, dreg, dreg, 0, sizeof (gpointer));
+#elif defined(__linux__)
+	int tmpreg = -1;
+
+	if (dreg == offset_reg) {
+		/* Use a temporary reg by saving it to the redzone */
+		tmpreg = dreg == AMD64_RAX ? AMD64_RCX : AMD64_RAX;
+		amd64_mov_membase_reg (code, AMD64_RSP, -8, tmpreg, 8);
+		amd64_mov_reg_reg (code, tmpreg, offset_reg, sizeof (gpointer));
+		offset_reg = tmpreg;
+	}
+	x86_prefix (code, X86_FS_PREFIX);
+	amd64_mov_reg_mem (code, dreg, 0, 8);
+	amd64_mov_reg_memindex (code, dreg, dreg, 0, offset_reg, 0, 8);
+	if (tmpreg != -1)
+		amd64_mov_reg_membase (code, tmpreg, AMD64_RSP, -8, 8);
+#else
+	g_assert_not_reached ();
+#endif
+	return code;
+}
+
 /*
  * emit_setup_lmf:
  *
@@ -5573,18 +5606,8 @@
 			break;
 		}
 		case OP_TLS_GET_REG:
-#ifdef TARGET_OSX
-			// FIXME: tls_gs_offset can change too, do these when calculating the tls offset
-			if (ins->dreg != ins->sreg1)
-				amd64_mov_reg_reg (code, ins->dreg, ins->sreg1, sizeof (gpointer));
-			amd64_shift_reg_imm (code, X86_SHL, ins->dreg, 3);
-			if (tls_gs_offset)
-				amd64_alu_reg_imm (code, X86_ADD, ins->dreg, tls_gs_offset);
-			x86_prefix (code, X86_GS_PREFIX);
-			amd64_mov_reg_membase (code, ins->dreg, ins->dreg, 0, sizeof (gpointer));
-#else
-			g_assert_not_reached ();
-#endif
+			code = emit_tls_get_reg (code, ins->dreg, ins->sreg1);
+			break;
 			break;
 		case OP_MEMORY_BARRIER: {
 			switch (ins->backend.memory_barrier_kind) {

Modified: mono/mini/mini-amd64.h
===================================================================
@@ -397,7 +397,7 @@ struct MonoLMF {
 #define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
 #define MONO_ARCH_HAVE_CREATE_LLVM_NATIVE_THUNK 1
 
-#ifdef TARGET_OSX
+#if defined(TARGET_OSX) || defined(__linux__)
 #define MONO_ARCH_HAVE_TLS_GET_REG 1
 #endif
 

   Commit: 2594b363632d507e20dbc728f48bcb4bfef7295f
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-11-01 15:19:38 GMT
      URL: https://github.com/mono/mono/commit/2594b363632d507e20dbc728f48bcb4bfef7295f

[sgen] Use mono_class_has_parent () instead of mono_class_has_parent_fast () in one place.

Changed paths:
  M mono/metadata/sgen-gc.c

Modified: mono/metadata/sgen-gc.c
===================================================================
@@ -896,7 +896,7 @@ struct _EphemeronLinkNode {
 	/* The object could be a proxy for an object in the domain
 	   we're deleting. */
 #ifndef DISABLE_REMOTING
-	if (mono_class_has_parent_fast (vt->klass, mono_defaults.real_proxy_class)) {
+	if (mono_class_has_parent (vt->klass, mono_defaults.real_proxy_class)) {
 		MonoObject *server = ((MonoRealProxy*)start)->unwrapped_server;
 
 		/* The server could already have been zeroed out, so


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.