Author: zoltan
Date: 2005-02-27 14:01:32 -0500 (Sun, 27 Feb 2005)
New Revision: 41264

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/tramp-amd64.c
Log:
2005-02-27  Zoltan Varga  <[EMAIL PROTECTED]>

        * tramp-amd64.c (amd64_magic_trampoline): Disable the method_ptr
        patching stuff, since delegates use jump trampolines so there is
        no caller.

        * tramp-amd64.c (create_trampoline_code): Pass NULL as 'code' in 
        jump trampolines.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2005-02-27 18:04:46 UTC (rev 41263)
+++ trunk/mono/mono/mini/ChangeLog      2005-02-27 19:01:32 UTC (rev 41264)
@@ -1,5 +1,12 @@
 2005-02-27  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * tramp-amd64.c (amd64_magic_trampoline): Disable the method_ptr
+       patching stuff, since delegates use jump trampolines so there is
+       no caller.
+
+       * tramp-amd64.c (create_trampoline_code): Pass NULL as 'code' in 
+       jump trampolines.
+       
        * tramp-amd64.c: Fix build.
 
        * mini-x86.c tramp-x86.c: Moved get_vtable_slot_addr into mini-x86.c 
and rename

Modified: trunk/mono/mono/mini/tramp-amd64.c
===================================================================
--- trunk/mono/mono/mini/tramp-amd64.c  2005-02-27 18:04:46 UTC (rev 41263)
+++ trunk/mono/mono/mini/tramp-amd64.c  2005-02-27 19:01:32 UTC (rev 41264)
@@ -77,7 +77,7 @@
 amd64_magic_trampoline (long *regs, guint8 *code, MonoMethod *m, guint8* tramp)
 {
        gpointer addr;
-       gpointer *vtable_slot, *method_ptr;
+       gpointer *vtable_slot;
 
        addr = mono_compile_method (m);
        g_assert (addr);
@@ -86,6 +86,7 @@
 
        /* the method was jumped to */
        if (!code)
+               /* FIXME: Optimize the case when the call is from a delegate 
wrapper */
                return addr;
 
        vtable_slot = mono_arch_get_vcall_slot_addr (code, (gpointer*)regs);
@@ -131,17 +132,6 @@
                                InterlockedExchangePointer (got_entry, addr);
                        }
                }
-               else if ((method_ptr = mono_arch_get_delegate_method_ptr_addr 
(code, regs))) {
-                       /* This is a call inside a delegate wrapper to the 
target method */
-                       MonoJitInfo *ji = 
-                               mono_jit_info_table_find (mono_domain_get (), 
code);
-                       MonoJitInfo *target_ji = 
-                               mono_jit_info_table_find (mono_domain_get (), 
addr);
-
-                       if (ji && (ji->method->wrapper_type == 
MONO_WRAPPER_DELEGATE_INVOKE) && mono_method_same_domain (ji, target_ji)) {
-                               InterlockedExchangePointer (method_ptr, addr);
-                       }
-               }
        }
 
        return addr;
@@ -249,11 +239,17 @@
 {
        guint8 *buf, *code, *tramp;
        int i, lmf_offset, offset, method_offset, tramp_offset, 
saved_regs_offset, saved_fpregs_offset, framesize;
+       gboolean has_caller;
        static guint8 *trampoline_code [16];
 
        if (trampoline_code [tramp_type])
                return trampoline_code [tramp_type];
 
+       if (tramp_type == MONO_TRAMPOLINE_JUMP)
+               has_caller = FALSE;
+       else
+               has_caller = TRUE;
+
        code = buf = mono_global_codeman_reserve (512);
 
        framesize = 512 + sizeof (MonoLMF);
@@ -300,10 +296,10 @@
        lmf_offset = - offset;
 
        /* Save ip */
-       if (tramp_type == MONO_TRAMPOLINE_JUMP)
-               amd64_mov_reg_imm (code, AMD64_R11, 0);
-       else
+       if (has_caller)
                amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, 8, 8);
+       else
+               amd64_mov_reg_imm (code, AMD64_R11, 0);
        amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + G_STRUCT_OFFSET 
(MonoLMF, rip), AMD64_R11, 8);
        /* Save fp */
        amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + G_STRUCT_OFFSET 
(MonoLMF, ebp), AMD64_RBP, 8);
@@ -338,7 +334,10 @@
        amd64_lea_membase (code, AMD64_RDI, AMD64_RBP, saved_regs_offset);
 
        /* Arg2 is the address of the calling code */
-       amd64_mov_reg_membase (code, AMD64_RSI, AMD64_RBP, 8, 8);
+       if (has_caller)
+               amd64_mov_reg_membase (code, AMD64_RSI, AMD64_RBP, 8, 8);
+       else
+               amd64_mov_reg_imm (code, AMD64_RSI, 0);
 
        /* Arg3 is the method/vtable ptr */
        amd64_mov_reg_membase (code, AMD64_RDX, AMD64_RBP, method_offset, 8);

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

Reply via email to