From: Gabor M. <me...@us...> - 2009-04-13 20:00:33
|
Update of /cvsroot/sbcl/sbcl/src/runtime In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15072/src/runtime Modified Files: pseudo-atomic.h Log Message: 1.0.27.8: slightly faster x86oid pseudo atomic with {e,r}bp Trusting that within SBCL ebp is even and that it doesn't change within a pseudo atomic section it's possible to use it to set and clear pseudo atomic bits. It is ever so slightly faster (about 0.5% overall on cl-bench on a P4). Index: pseudo-atomic.h =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/pseudo-atomic.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pseudo-atomic.h 16 Feb 2009 21:38:43 -0000 1.3 +++ pseudo-atomic.h 13 Apr 2009 20:00:21 -0000 1.4 @@ -34,18 +34,19 @@ static inline int get_pseudo_atomic_atomic(struct thread *thread) { - return fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) & - make_fixnum(1)); + return SymbolValue(PSEUDO_ATOMIC_BITS, thread) & (~1); } static inline void set_pseudo_atomic_atomic(struct thread *thread) { lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread); + if (*p) + lose("set_pseudo_atomic_atomic: pseudo atomic bits is %d.", *p); __asm__ __volatile__ ("or" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (make_fixnum(1)), "m" (*p) + : "g" (~1), "m" (*p) : "memory"); } @@ -56,36 +57,39 @@ __asm__ __volatile__ ("and" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (~make_fixnum(1)), "m" (*p) + : "g" (1), "m" (*p) : "memory"); } static inline int get_pseudo_atomic_interrupted(struct thread *thread) { - return fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) & - make_fixnum(2)); + return SymbolValue(PSEUDO_ATOMIC_BITS, thread) & 1; } static inline void set_pseudo_atomic_interrupted(struct thread *thread) { + if (!get_pseudo_atomic_atomic(thread)) + lose("set_pseudo_atomic_interrupted not in pseudo atomic"); lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread); __asm__ __volatile__ ("or" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (make_fixnum(2)), "m" (*p) + : "g" (1), "m" (*p) : "memory"); } static inline void clear_pseudo_atomic_interrupted(struct thread *thread) { + if (get_pseudo_atomic_atomic(thread)) + lose("clear_pseudo_atomic_interrupted in pseudo atomic"); lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread); __asm__ __volatile__ ("and" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (~make_fixnum(2)), "m" (*p) + : "g" (~1), "m" (*p) : "memory"); } |