[mono/mono] 623b9d0d: [jit] Implement support for OP_TLS_GET on amd64+llvm.

"Zoltan Varga ([email protected])" <[email protected]> Fri, 8 Nov 2013 03:42:24 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014235cdbc56-3a620309-940b-4fe4-9d0d-ab1980e15b74-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/3cb85f36f5ce...623b9d0dcf66

   Commit: 623b9d0dcf66a705fd0a101bd55c8e30564e2782
   Author: Zoltan Varga <[email protected]> (vargaz)
     Date: 2013-11-08 03:40:25 GMT
      URL: https://github.com/mono/mono/commit/623b9d0dcf66a705fd0a101bd55c8e30564e2782

[jit] Implement support for OP_TLS_GET on amd64+llvm.

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

Modified: mono/mini/mini-amd64.c
===================================================================
@@ -3612,6 +3612,17 @@
 #endif
 }
 
+int
+mono_amd64_get_tls_gs_offset (void)
+{
+#ifdef TARGET_OSX
+	return tls_gs_offset;
+#else
+	g_assert_not_reached ();
+	return -1;
+#endif
+}
+
 /*
  * mono_amd64_emit_tls_get:
  * @code: buffer to store code to

Modified: mono/mini/mini-amd64.h
===================================================================
@@ -442,6 +442,9 @@ struct MonoLMF {
 GSList*
 mono_amd64_get_exception_trampolines (gboolean aot) MONO_INTERNAL;
 
+int
+mono_amd64_get_tls_gs_offset (void) MONO_INTERNAL;
+
 typedef struct {
 	guint8 *address;
 	guint8 saved_byte;

Modified: mono/mini/mini-llvm.c
===================================================================
@@ -3291,9 +3291,15 @@
 			// 256 == GS segment register
 			LLVMTypeRef ptrtype = LLVMPointerType (IntPtrType (), 256);
 #endif
-
 			// FIXME: XEN
 			values [ins->dreg] = LLVMBuildLoad (builder, LLVMBuildIntToPtr (builder, LLVMConstInt (IntPtrType (), ins->inst_offset, TRUE), ptrtype, ""), "");
+#elif defined(TARGET_AMD64) && defined(TARGET_OSX)
+			/* See mono_amd64_emit_tls_get () */
+			int offset = mono_amd64_get_tls_gs_offset () + (ins->inst_offset * 8);
+
+			// 256 == GS segment register
+			LLVMTypeRef ptrtype = LLVMPointerType (IntPtrType (), 256);
+			values [ins->dreg] = LLVMBuildLoad (builder, LLVMBuildIntToPtr (builder, LLVMConstInt (IntPtrType (), offset, TRUE), ptrtype, ""), "");
 #else
 			LLVM_FAILURE (ctx, "opcode tls-get");
 #endif


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches