2004-08-21 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Sat, 21 Aug 2004 18:05:50 +0000 (18:05 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 21 Aug 2004 18:05:50 +0000 (18:05 -0000)
* mini-amd64.c (read_tls_offset_from_method): Add another code
sequence.

* tramp-amd64.c (amd64_class_init_trampoline): Use a more efficient
instruction sequence for nullifying class init trampolines.

svn path=/trunk/mono/; revision=32624

mono/mini/ChangeLog
mono/mini/mini-amd64.c
mono/mini/tramp-amd64.c

index 77fcdc755abab4f666d6ea753e4b1ee4ece30637..f3678ad274e56ce2a3500c615e4be07b1a010acb 100644 (file)
@@ -1,5 +1,11 @@
 2004-08-21  Zoltan Varga  <vargaz@freemail.hu>
 
+       * mini-amd64.c (read_tls_offset_from_method): Add another code
+       sequence.
+
+       * tramp-amd64.c (amd64_class_init_trampoline): Use a more efficient
+       instruction sequence for nullifying class init trampolines.
+
        * objects.cs: Add new regalloc test.
 
        * mini-amd64.c inssel-amd64.brg: Optimize parameter passing.
index 02a3bb78057e0bf2c608eda0088d18d8cdd747e5..bdfe905bf41bf6616ae84d27731c42b56ff8e15b 100644 (file)
@@ -4983,6 +4983,11 @@ read_tls_offset_from_method (void* method)
                 (code [3] == 0xe5) && (code [4] == 0x64) && (code [5] == 0x48) &&
                 (code [6] == 0x8b) && (code [7] == 0x04) && (code [8] == 0x25)) {
                        return *(gint32*)&(code [9]);
+       } else if
+               /* This is generated by gcc-3.4.1 with -O=2 */
+               ((code [0] == 0x64) && (code [1] == 0x48) && (code [2] == 0x8b) &&
+                (code [3] == 0x04) && (code [4] == 0x25)) {
+               return *(gint32*)&(code [5]);
        }
 
        return -1;
index 59ad9f0770e38eb5246b0a3046ddf544c2385a7b..76093f2aec495d089c35be6d6be9bfb6919e209d 100644 (file)
@@ -138,18 +138,31 @@ amd64_class_init_trampoline (long *regs, guint8 *code, MonoVTable *vtable)
 {
        mono_runtime_class_init (vtable);
 
-       /* FIXME: patch calling code */
-
        code -= 3;
        if ((code [0] == 0x49) && (code [1] == 0xff)) {
                if (!mono_running_on_valgrind ()) {
+                       /* amd64_set_reg_template is 10 bytes long */
+                       guint8* buf = code - 10;
 
                        /* FIXME: Make this thread safe */
-                       code [0] = code [1] = code [2] = 0x90;
+                       /* Padding code suggested by the AMD64 Opt Manual */
+                       buf [0] = 0x66;
+                       buf [1] = 0x66;
+                       buf [2] = 0x66;
+                       buf [3] = 0x90;
+                       buf [4] = 0x66;
+                       buf [5] = 0x66;
+                       buf [6] = 0x66;
+                       buf [7] = 0x90;
+                       buf [8] = 0x66;
+                       buf [9] = 0x66;
+                       buf [10] = 0x90;
+                       buf [11] = 0x66;
+                       buf [12] = 0x90;
                }
        }
        else
-               if (code [0] == 0x90 || code [0] == 0xeb)
+               if (code [0] == 0x90 || code [0] == 0xeb || code [0] == 0x66)
                        /* Already changed by another thread */
                        ;
                else {