This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Mirror i386 change on sparc: 'Avoid "anonymous" code in pthread_spin_lock'


Paul Pluzhnikov <ppluzhnikov@google.com> writes:

> On Wed, May 2, 2012 at 7:46 PM, Chris Metcalf <cmetcalf@tilera.com> wrote:
>
>> Wouldn't you get the same result as the assembly code just by removing the
>> .subsection and .previous directives? ÂIn that case the code would all be
>> under the C function label, which is the point of the change.
>
> FWIW, I tried that approach with i386,x86_64 code.
>
> The result with .subsection removed was:
>
>   0:   f0 ff 0f                lock decl (%rdi)
>   3:   75 0b                   jne    10 <pthread_spin_lock+0x10>
>
>  10:   f3 90                   pause
>  12:   83 3f 00                cmpl   $0x0,(%rdi)
>  15:   7f e9                   jg     0 <pthread_spin_lock>
>  17:   eb f7                   jmp    10 <pthread_spin_lock+0x10>
>  19:   31 c0                   xor    %eax,%eax
>  1b:   c3                      retq
>
> If I am reading this correctly, this will spin forever.

The point of the subsection is so that you don't need the jump around.
It's simulating the compiler putting an unlikely BB out of line.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]