2008-11-13 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Thu, 13 Nov 2008 14:12:59 +0000 (14:12 -0000)
committerZoltan Varga <vargaz@gmail.com>
Thu, 13 Nov 2008 14:12:59 +0000 (14:12 -0000)
* tramp-x86.c (mono_arch_create_trampoline_code): Rework the return sequence
to preserve %eax for aot plt trampolines.

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

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

index dad45d6e27d59651805deac5f8be6358d54d8ad2..e397126315b73e6aab2ee66c77fb5528b143610f 100644 (file)
@@ -1,5 +1,8 @@
 2008-11-13  Zoltan Varga  <vargaz@gmail.com>
 
+       * tramp-x86.c (mono_arch_create_trampoline_code): Rework the return sequence
+       to preserve %eax for aot plt trampolines.
+
        * aot-compiler.c (compile_method): Don't skip synchronized methods.
        (encode_method_ref): Flag synchronized methods so they won't go through
        the AOT trampoline.
index 25c21da6c7d23bbeccb563bfdc35fdeb26a50a02..771e99508f4b1fc6a7f9f4c983f686182452bb8b 100644 (file)
@@ -354,28 +354,37 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
 
        /* restore LMF end */
 
+       if (!MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type)) {
+               /* 
+                * Overwrite the method ptr with the address we need to jump to,
+                * to free %eax.
+                */
+               x86_mov_membase_reg (buf, X86_ESP, pushed_args * sizeof (gpointer), X86_EAX, 4);
+       }
+
        /* Restore caller saved registers */
        x86_mov_reg_membase (buf, X86_ECX, X86_ESP, (pushed_args - pushed_args_caller_saved + X86_ECX) * 4, 4);
        x86_mov_reg_membase (buf, X86_EDX, X86_ESP, (pushed_args - pushed_args_caller_saved + X86_EDX) * 4, 4);
-       if (tramp_type == MONO_TRAMPOLINE_RESTORE_STACK_PROT)
+       if ((tramp_type == MONO_TRAMPOLINE_RESTORE_STACK_PROT) || (tramp_type == MONO_TRAMPOLINE_AOT_PLT))
                x86_mov_reg_membase (buf, X86_EAX, X86_ESP, (pushed_args - pushed_args_caller_saved + X86_EAX) * 4, 4);
 
-       /* Pop saved reg array + stack align + method ptr */
-       x86_alu_reg_imm (buf, X86_ADD, X86_ESP, 10 * 4);
-
-       pushed_args -= 10;
-
-       /* We've popped one more stack item than we've pushed (the
-          method ptr argument), so we must end up at -1. */
-       g_assert (pushed_args == -1);
-
-       if (MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type)) {
-               x86_ret (buf);
+       if (!MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type)) {
+               /* Pop saved reg array + stack align */
+               x86_alu_reg_imm (buf, X86_ADD, X86_ESP, 9 * 4);
+               pushed_args -= 9;
+               g_assert (pushed_args == 0);
        } else {
-               /* call the compiled method */
-               x86_jump_reg (buf, X86_EAX);
+               /* Pop saved reg array + stack align + method ptr */
+               x86_alu_reg_imm (buf, X86_ADD, X86_ESP, 10 * 4);
+               pushed_args -= 10;
+
+               /* We've popped one more stack item than we've pushed (the
+                  method ptr argument), so we must end up at -1. */
+               g_assert (pushed_args == -1);
        }
 
+       x86_ret (buf);
+
        g_assert ((buf - code) <= 256);
 
        if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {