Skip to content

Commit

Permalink
Minor optimizations of last x86-64 condvar changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Jul 20, 2009
1 parent 42e69bc commit c3db953
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
6 changes: 6 additions & 0 deletions nptl/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2009-07-20 Ulrich Drepper <drepper@redhat.com>

* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Minor
optimizations of last changes.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.

2009-07-19 Ulrich Drepper <drepper@redhat.com>

* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Define
Expand Down
8 changes: 3 additions & 5 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,14 @@ __pthread_cond_timedwait:
movq 8(%rsp), %rdi

movq %r13, %r10
movl $FUTEX_WAIT_BITSET, %esi
cmpq $-1, dep_mutex(%rdi)
movl $FUTEX_WAIT_BITSET, %eax
movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi
cmove %eax, %esi
je 60f

movq dep_mutex(%rdi), %r8
/* Requeue to a PI mutex if the PI bit is set. */
testl $PI_BIT, MUTEX_KIND(%r8)
je 60f
je 61f

movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
xorl %eax, %eax
Expand All @@ -191,10 +189,10 @@ __pthread_cond_timedwait:
cmpq $-4095, %rax
jnae 62f

movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi
subq $cond_futex, %rdi
#endif

61: movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi
60: xorl %r15d, %r15d
xorl %eax, %eax
/* The following only works like this because we only support
Expand Down
31 changes: 13 additions & 18 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,15 @@ __pthread_cond_wait:
movq 8(%rsp), %rdi
xorq %r10, %r10
movq %r12, %rdx
// XXX reverse + lea
addq $cond_futex, %rdi
cmpq $-1, dep_mutex-cond_futex(%rdi)
#ifdef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_WAIT, %eax
movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
cmove %eax, %esi
#else
movl $0, %eax
movl %fs:PRIVATE_FUTEX, %esi
cmove %eax, %esi
# if FUTEX_WAIT != 0
# error "cc destroyed by following orl"
orl $FUTEX_WAIT, %esi
# endif
#endif
cmpq $-1, dep_mutex(%rdi)
leaq cond_futex(%rdi), %rdi
movl $FUTEX_WAIT, %esi
je 60f

movq dep_mutex-cond_futex(%rdi), %r8
/* Requeue to a PI mutex if the PI bit is set. */
testl $PI_BIT, MUTEX_KIND(%r8)
je 60f
je 61f

movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
movl $SYS_futex, %eax
Expand All @@ -162,9 +149,17 @@ __pthread_cond_wait:
cmpq $-4095, %rax
jnae 62f

movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
# ifndef __ASSUME_PRIVATE_FUTEX
movl $FUTEX_WAIT, %esi
# endif
#endif

61:
#ifdef __ASSUME_PRIVATE_FUTEX
movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
#else
orl %fs:PRIVATE_FUTEX, %esi
#endif
60: xorl %r13d, %r13d
movl $SYS_futex, %eax
syscall
Expand Down

0 comments on commit c3db953

Please sign in to comment.