2010-03-06 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sat, 6 Mar 2010 19:10:46 +0000 (19:10 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 6 Mar 2010 19:10:46 +0000 (19:10 -0000)
* tramp-amd64.c (mono_arch_create_monitor_exit_trampoline_full): Delegate
the handling of obj->synchronization == null and owner != current thread to
mono_monitor_exit ().

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

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

index 8439f6f29baf41d6392ad3db01e4fe46513ab661..4e89472a04d6fb3fd67a10c9768159880584fe8c 100755 (executable)
@@ -1,3 +1,11 @@
+2010-03-06  Zoltan Varga  <vargaz@gmail.com>
+
+       * tramp-amd64.c (mono_arch_create_monitor_exit_trampoline_full): Delegate
+       the handling of obj->synchronization == null and owner != current thread to
+       mono_monitor_exit ().
+
+       * tramp-x86.c (mono_arch_create_monitor_exit_trampoline_full): Ditto.
+
 
 Sat Mar 6 18:14:15 CET 2010 Paolo Molaro <lupus@ximian.com>
 
index 3f616fa721a430d8c15627a99fa69d1c1e0949ba..45c91722563448398a92013593eca7a00ab7e1a8 100644 (file)
@@ -935,7 +935,7 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
 {
        guint8 *tramp;
        guint8 *code, *buf;
-       guint8 *jump_obj_null, *jump_have_waiters;
+       guint8 *jump_obj_null, *jump_have_waiters, *jump_sync_null, *jump_not_owned;
        guint8 *jump_next;
        int tramp_size;
        int owner_offset, nest_offset, entry_count_offset;
@@ -968,28 +968,22 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
                amd64_mov_reg_membase (code, AMD64_RCX, AMD64_RDI, G_STRUCT_OFFSET (MonoObject, synchronisation), 8);
                /* is synchronization null? */
                amd64_test_reg_reg (code, AMD64_RCX, AMD64_RCX);
-               /* if not, jump to next case */
-               jump_next = code;
-               amd64_branch8 (code, X86_CC_NZ, -1, 1);
-               /* if yes, just return */
-               amd64_ret (code);
+               /* if yes, jump to actual trampoline */
+               jump_sync_null = code;
+               amd64_branch8 (code, X86_CC_Z, -1, 1);
 
                /* next case: synchronization is not null */
-               x86_patch (jump_next, code);
                /* load MonoInternalThread* into RDX */
                code = mono_amd64_emit_tls_get (code, AMD64_RDX, mono_thread_get_tls_offset ());
                /* load TID into RDX */
                amd64_mov_reg_membase (code, AMD64_RDX, AMD64_RDX, G_STRUCT_OFFSET (MonoInternalThread, tid), 8);
                /* is synchronization->owner == TID */
                amd64_alu_membase_reg_size (code, X86_CMP, AMD64_RCX, owner_offset, AMD64_RDX, 8);
-               /* if yes, jump to next case */
-               jump_next = code;
-               amd64_branch8 (code, X86_CC_Z, -1, 1);
-               /* if not, just return */
-               amd64_ret (code);
+               /* if no, jump to actual trampoline */
+               jump_not_owned = code;
+               amd64_branch8 (code, X86_CC_NZ, -1, 1);
 
                /* next case: synchronization->owner == TID */
-               x86_patch (jump_next, code);
                /* is synchronization->nest == 1 */
                amd64_alu_membase_imm_size (code, X86_CMP, AMD64_RCX, nest_offset, 1, 4);
                /* if not, jump to next case */
@@ -1012,6 +1006,8 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
 
                x86_patch (jump_obj_null, code);
                x86_patch (jump_have_waiters, code);
+               x86_patch (jump_not_owned, code);
+               x86_patch (jump_sync_null, code);
        }
 
        /* jump to the actual trampoline */
index a1961773a488f59f2e9e3fc1762770c3dffd9819..593f9138b896a8050710660c955acb5229e29556 100644 (file)
@@ -721,7 +721,7 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
 {
        guint8 *tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_MONITOR_EXIT);
        guint8 *code, *buf;
-       guint8 *jump_obj_null, *jump_have_waiters;
+       guint8 *jump_obj_null, *jump_have_waiters, *jump_sync_null, *jump_not_owned;
        guint8 *jump_next;
        int tramp_size;
        int owner_offset, nest_offset, entry_count_offset;
@@ -752,28 +752,22 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
                x86_mov_reg_membase (buf, X86_ECX, X86_EAX, G_STRUCT_OFFSET (MonoObject, synchronisation), 4);
                /* is synchronization null? */
                x86_test_reg_reg (buf, X86_ECX, X86_ECX);
-               /* if not, jump to next case */
-               jump_next = buf;
-               x86_branch8 (buf, X86_CC_NZ, -1, 1);
-               /* if yes, just return */
-               x86_ret (buf);
+               /* if yes, jump to actual trampoline */
+               jump_sync_null = buf;
+               x86_branch8 (buf, X86_CC_Z, -1, 1);
 
                /* next case: synchronization is not null */
-               x86_patch (jump_next, buf);
                /* load MonoInternalThread* into EDX */
                buf = mono_x86_emit_tls_get (buf, X86_EDX, mono_thread_get_tls_offset ());
                /* load TID into EDX */
                x86_mov_reg_membase (buf, X86_EDX, X86_EDX, G_STRUCT_OFFSET (MonoInternalThread, tid), 4);
                /* is synchronization->owner == TID */
                x86_alu_membase_reg (buf, X86_CMP, X86_ECX, owner_offset, X86_EDX);
-               /* if yes, jump to next case */
-               jump_next = buf;
-               x86_branch8 (buf, X86_CC_Z, -1, 1);
-               /* if not, just return */
-               x86_ret (buf);
+               /* if no, jump to actual trampoline */
+               jump_not_owned = buf;
+               x86_branch8 (buf, X86_CC_NZ, -1, 1);
 
                /* next case: synchronization->owner == TID */
-               x86_patch (jump_next, buf);
                /* is synchronization->nest == 1 */
                x86_alu_membase_imm (buf, X86_CMP, X86_ECX, nest_offset, 1);
                /* if not, jump to next case */
@@ -797,6 +791,9 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
                /* push obj and jump to the actual trampoline */
                x86_patch (jump_obj_null, buf);
                x86_patch (jump_have_waiters, buf);
+               x86_patch (jump_not_owned, buf);
+               x86_patch (jump_sync_null, buf);
+
                x86_push_reg (buf, X86_EAX);
                x86_jump_code (buf, tramp);
        } else {