VirtualBox

Changeset 25665 in vbox


Ignore:
Timestamp:
Jan 6, 2010 4:19:49 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56380
Message:

iprt/asm.h,ASMAtomic*.asm: the darwin x86 gcc also has trouble with our cmpxchg8b usage, do like we did for gcc 4.3.x/x86 a while back. Did it for *all* cmpxchg8b users (we missed(?) 3 last time).

Location:
trunk
Files:
3 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm.h

    r25645 r25665  
    117117#endif
    118118
    119 /** @def RT_INLINE_ASM_GCC_4_3_X_X86
    120  * Used to work around some 4.3.x register allocation issues in this version of
    121  * the compiler. */
    122 #ifdef __GNUC__
    123 # define RT_INLINE_ASM_GCC_4_3_X_X86 (__GNUC__ == 4 && __GNUC_MINOR__ == 3 && defined(__i386__))
    124 #endif
    125 #ifndef RT_INLINE_ASM_GCC_4_3_X_X86
    126 # define RT_INLINE_ASM_GCC_4_3_X_X86 0
    127 #endif
    128 
    129 
    130119
    131120/** @defgroup grp_asm       ASM - Assembly Routines
     
    167156 * @{
    168157 */
     158
     159/** @def RT_INLINE_ASM_GCC_4_3_X_X86
     160 * Used to work around some 4.3.x register allocation issues in this version of
     161 * the compiler. */
     162#ifdef __GNUC__
     163# define RT_INLINE_ASM_GCC_4_3_X_X86 (__GNUC__ == 4 && __GNUC_MINOR__ == 3 && defined(__i386__))
     164#endif
     165#ifndef RT_INLINE_ASM_GCC_4_3_X_X86
     166# define RT_INLINE_ASM_GCC_4_3_X_X86 0
     167#endif
     168
     169/** @def RT_INLINE_DONT_USE_CMPXCHG8B
     170 * i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493) screws up
     171 * RTSemRWRequestWrite semsemrw-lockless-generic.cpp in release builds. PIC
     172 * mode, x86.
     173 *
     174 * Some gcc 4.3.x versions may have register allocation issues with cmpxchg8b
     175 * when in PIC mode on x86.
     176 */
     177#ifndef RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC
     178# define RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC \
     179    (   (defined(PIC) || defined(__PIC__)) \
     180     && defined(RT_ARCH_X86) \
     181     && (   RT_INLINE_ASM_GCC_4_3_X_X86 \
     182         || defined(RT_OS_DARWIN)) )
     183#endif
    169184
    170185/** @def RT_INLINE_ASM_EXTERNAL
     
    28082823 * @param   u64     The 64-bit value to assign to *pu64.
    28092824 */
    2810 #if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     2825#if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \
     2826 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC
    28112827DECLASM(uint64_t) ASMAtomicXchgU64(volatile uint64_t *pu64, uint64_t u64);
    28122828#else
     
    31753191 */
    31763192#if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \
    3177  || (RT_INLINE_ASM_GCC_4_3_X_X86 && defined(IN_RING3) && defined(__PIC__))
     3193 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC
    31783194DECLASM(bool) ASMAtomicCmpXchgU64(volatile uint64_t *pu64, const uint64_t u64New, const uint64_t u64Old);
    31793195#else
    3180 DECLINLINE(bool) ASMAtomicCmpXchgU64(volatile uint64_t *pu64, const uint64_t u64New, uint64_t u64Old)
     3196DECLINLINE(bool) ASMAtomicCmpXchgU64(volatile uint64_t *pu64, uint64_t u64New, uint64_t u64Old)
    31813197{
    31823198# if RT_INLINE_ASM_USES_INTRIN
     
    34433459 * @param   pu64Old     Pointer store the old value at.
    34443460 */
    3445 #if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
     3461#if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \
     3462 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC
    34463463DECLASM(bool) ASMAtomicCmpXchgExU64(volatile uint64_t *pu64, const uint64_t u64New, const uint64_t u64Old, uint64_t *pu64Old);
    34473464#else
     
    42224239 */
    42234240#if (RT_INLINE_ASM_EXTERNAL && !defined(RT_ARCH_AMD64)) \
    4224  || (RT_INLINE_ASM_GCC_4_3_X_X86 && defined(IN_RING3) && defined(__PIC__))
     4241 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC
    42254242DECLASM(uint64_t) ASMAtomicReadU64(volatile uint64_t *pu64);
    42264243#else
     
    43004317 * @remark  This will fault if the memory is read-only!
    43014318 */
    4302 #if RT_INLINE_ASM_EXTERNAL && !defined(RT_ARCH_AMD64)
     4319#if #if (RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN) \
     4320 || RT_INLINE_DONT_MIX_CMPXCHG8B_AND_PIC
    43034321DECLASM(uint64_t) ASMAtomicUoReadU64(volatile uint64_t *pu64);
    43044322#else
  • trunk/src/VBox/Runtime/Makefile.kmk

    r25645 r25665  
    374374# Some versions of GCC might require this.
    375375RuntimeR3_SOURCES.x86 += \
     376        common/asm/ASMAtomicXchgU64.asm \
    376377        common/asm/ASMAtomicCmpXchgU64.asm \
    377         common/asm/ASMAtomicReadU64.asm
     378        common/asm/ASMAtomicCmpXchgExU64.asm \
     379        common/asm/ASMAtomicReadU64.asm \
     380        common/asm/ASMAtomicUoReadU64.asm
    378381
    379382ifdef IPRT_WITH_KSTUFF
  • trunk/src/VBox/Runtime/common/asm/ASMAtomicCmpXchgExU64.asm

    r25664 r25665  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMAtomicCmpXchgU64().
     3; IPRT - ASMAtomicCmpXchgExU64().
    44;
    55
    66;
    7 ; Copyright (C) 2006-2009 Sun Microsystems, Inc.
     7; Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    3737
    3838;;
    39 ; Atomically compares and exchanges an unsigned 64-bit int.
     39; Atomically Exchange an unsigned 64-bit value, ordered.
    4040;
    4141; @param    pu64     x86:ebp+8   gcc:rdi  msc:rcx
    4242; @param    u64New   x86:ebp+c   gcc:rsi  msc:rdx
    4343; @param    u64Old   x86:ebp+14  gcc:rcx  msc:r8
     44; @param    u64Old   x86:ebp+1c  gcc:rdx  msc:r9
    4445;
    4546; @returns  bool result: true if succesfully exchanged, false if not.
    4647;           x86:al
    4748;
    48 BEGINPROC_EXPORTED ASMAtomicCmpXchgU64
     49BEGINPROC_EXPORTED ASMAtomicCmpXchgExU64
    4950%ifdef RT_ARCH_AMD64
    5051 %ifdef ASM_CALL64_MSC
    5152        mov     rax, r8
    5253        lock cmpxchg [rcx], rdx
     54        mov     [r9], rax
    5355 %else
    5456        mov     rax, rcx
    5557        lock cmpxchg [rdi], rsi
     58        mov     [rdx], rax
    5659 %endif
    5760        setz    al
     
    7174        mov     edx, dword [ebp+14h + 4]
    7275        lock cmpxchg8b [edi]
     76        mov     edi, [ebp + 1ch]
     77        mov     [edi],     eax
     78        mov     [edi + 4], edx
    7379        setz    al
    7480        movzx   eax, al
     
    7985        ret
    8086%endif
    81 ENDPROC ASMAtomicCmpXchgU64
     87ENDPROC ASMAtomicCmpXchgExU64
    8288
  • trunk/src/VBox/Runtime/common/asm/ASMAtomicCmpXchgU64.asm

    r25664 r25665  
    55
    66;
    7 ; Copyright (C) 2006-2009 Sun Microsystems, Inc.
     7; Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/Runtime/common/asm/ASMAtomicUoReadU64.asm

    r25664 r25665  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMAtomicReadU64().
     3; IPRT - ASMAtomicUoReadU64().
    44;
    55
    66;
    7 ; Copyright (C) 2006-2009 Sun Microsystems, Inc.
     7; Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444;
    4545;
    46 BEGINPROC_EXPORTED ASMAtomicReadU64
     46BEGINPROC_EXPORTED ASMAtomicUoReadU64
    4747%ifdef RT_ARCH_AMD64
    48         mfence                          ; ASSUME its present.
    4948 %ifdef ASM_CALL64_MSC
    5049        mov     rax, [rcx]
     
    6564        xor     ecx, ecx
    6665        xor     ebx, ebx
    67         lock cmpxchg8b [edi]
     66        cmpxchg8b [edi]
    6867
    6968        pop     edi
     
    7271        ret
    7372%endif
    74 ENDPROC ASMAtomicReadU64
     73ENDPROC ASMAtomicUoReadU64
    7574
  • trunk/src/VBox/Runtime/common/asm/ASMAtomicXchgU64.asm

    r25664 r25665  
    11; $Id$
    22;; @file
    3 ; IPRT - ASMAtomicCmpXchgU64().
     3; IPRT - ASMAtomicXchgU64().
    44;
    55
    66;
    7 ; Copyright (C) 2006-2009 Sun Microsystems, Inc.
     7; Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    3737
    3838;;
    39 ; Atomically compares and exchanges an unsigned 64-bit int.
     39; Atomically Exchange an unsigned 64-bit value, ordered.
    4040;
    4141; @param    pu64     x86:ebp+8   gcc:rdi  msc:rcx
    4242; @param    u64New   x86:ebp+c   gcc:rsi  msc:rdx
    43 ; @param    u64Old   x86:ebp+14  gcc:rcx  msc:r8
    4443;
    4544; @returns  bool result: true if succesfully exchanged, false if not.
    4645;           x86:al
    4746;
    48 BEGINPROC_EXPORTED ASMAtomicCmpXchgU64
     47BEGINPROC_EXPORTED ASMAtomicXchgU64
    4948%ifdef RT_ARCH_AMD64
    5049 %ifdef ASM_CALL64_MSC
    5150        mov     rax, r8
     51.try_again:
    5252        lock cmpxchg [rcx], rdx
    5353 %else
     54.try_again:
    5455        mov     rax, rcx
    5556        lock cmpxchg [rdi], rsi
    5657 %endif
    57         setz    al
    58         movzx   eax, al
     58        jnz     .try_again
    5959        ret
    6060%endif
     
    6565        push    edi
    6666
     67.try_again:
    6768        mov     ebx, dword [ebp+0ch]
    6869        mov     ecx, dword [ebp+0ch + 4]
    6970        mov     edi, [ebp+08h]
    70         mov     eax, dword [ebp+14h]
    71         mov     edx, dword [ebp+14h + 4]
    7271        lock cmpxchg8b [edi]
    73         setz    al
    74         movzx   eax, al
     72        jnz     .try_again
    7573
    7674        pop     edi
     
    7977        ret
    8078%endif
    81 ENDPROC ASMAtomicCmpXchgU64
     79ENDPROC ASMAtomicXchgU64
    8280
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette