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][BZ #19490] Add unwind descriptors to pthread_spin_init, etc. on i386


On Mon, Jan 25, 2016 at 5:06 AM, Torvald Riegel <triegel@redhat.com> wrote:

> For the spinlocks, I'd really prefer if we could just remove the asm
> files.  The generic implementation should basically produce the same
> code; if not, we should try to fix that instead of keeping the asm
> files.

Using gcc-4.8.4 (4.8.4-2ubuntu1~14.04):

$ objdump -d nptl/pthread_spin_unlock.o

nptl/pthread_spin_unlock.o:     file format elf32-i386


Disassembly of section .text:

00000000 <pthread_spin_unlock>:
   0: f0 83 0c 24 00       lock orl $0x0,(%esp)
   5: 8b 44 24 04           mov    0x4(%esp),%eax
   9: c7 00 00 00 00 00     movl   $0x0,(%eax)
   f: 31 c0                 xor    %eax,%eax
  11: c3                   ret

This isn't quite the same as sysdeps/i386/nptl/pthread_spin_unlock.S
For pthread_spin_lock it's much worse:

$ objdump -d nptl/pthread_spin_lock.o

nptl/pthread_spin_lock.o:     file format elf32-i386


Disassembly of section .text:

00000000 <pthread_spin_lock>:
   0: 57                   push   %edi
   1: b8 01 00 00 00       mov    $0x1,%eax
   6: 56                   push   %esi
   7: 53                   push   %ebx
   8: 83 ec 10             sub    $0x10,%esp
   b: 8b 5c 24 20           mov    0x20(%esp),%ebx
   f: 87 03                 xchg   %eax,(%ebx)
  11: 89 44 24 0c           mov    %eax,0xc(%esp)
  15: 8b 44 24 0c           mov    0xc(%esp),%eax
  19: 31 ff                 xor    %edi,%edi
  1b: be 01 00 00 00       mov    $0x1,%esi
  20: 85 c0                 test   %eax,%eax
  22: 74 29                 je     4d <pthread_spin_lock+0x4d>
  24: 8d 74 26 00           lea    0x0(%esi,%eiz,1),%esi
  28: 8b 03                 mov    (%ebx),%eax
  2a: 85 c0                 test   %eax,%eax
  2c: 74 15                 je     43 <pthread_spin_lock+0x43>
  2e: ba e8 03 00 00       mov    $0x3e8,%edx
  33: eb 08                 jmp    3d <pthread_spin_lock+0x3d>
  35: 8d 76 00             lea    0x0(%esi),%esi
  38: 83 ea 01             sub    $0x1,%edx
  3b: 74 06                 je     43 <pthread_spin_lock+0x43>
  3d: 8b 0b                 mov    (%ebx),%ecx
  3f: 85 c9                 test   %ecx,%ecx
  41: 75 f5                 jne    38 <pthread_spin_lock+0x38>
  43: 89 f8                 mov    %edi,%eax
  45: f0 0f b1 33           lock cmpxchg %esi,(%ebx)
  49: 85 c0                 test   %eax,%eax
  4b: 75 db                 jne    28 <pthread_spin_lock+0x28>
  4d: 83 c4 10             add    $0x10,%esp
  50: 31 c0                 xor    %eax,%eax
  52: 5b                   pop    %ebx
  53: 5e                   pop    %esi
  54: 5f                   pop    %edi
  55: c3                   ret

So I am not sure we should be throwing ASM out just yet.

-- 
Paul Pluzhnikov


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