X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fassembly%2Fx86-64%2Falloc.lisp;h=7fd309b3c9a88cb277b87f2030a5deb1d244f557;hb=f17e3d27d7ff599f9443d011d17017a2a858c81a;hp=ba27b1b4aff45ce6b6e36bf2579b713a3fc04a93;hpb=dabefb02a8df444fbc3c38d7043e201ae450040e;p=sbcl.git diff --git a/src/assembly/x86-64/alloc.lisp b/src/assembly/x86-64/alloc.lisp index ba27b1b..7fd309b 100644 --- a/src/assembly/x86-64/alloc.lisp +++ b/src/assembly/x86-64/alloc.lisp @@ -92,11 +92,12 @@ (inst push other) (inst push target) (emit-label get-tls-index-lock) - (inst mov target 1) - (zeroize rax-tn) - (inst lock) - (inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*) target) - (inst jmp :ne get-tls-index-lock) + (let ((not-rax ,(if (eql 'rax reg) 'other 'target))) + (inst mov not-rax 1) + (zeroize rax-tn) + (inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*) + not-rax :lock) + (inst jmp :ne get-tls-index-lock)) ;; The symbol is now in OTHER. (inst pop other) ;; Now with the lock held, see if the symbol's tls index has been @@ -106,13 +107,18 @@ (inst jmp :ne release-tls-index-lock) ;; Allocate a new tls-index. (load-symbol-value target *free-tls-index*) - (let ((error (generate-error-code nil tls-exhausted-error))) + (let ((not-error (gen-label)) + (error (generate-error-code nil 'tls-exhausted-error))) (inst cmp target (fixnumize tls-size)) - (inst jmp :ge error)) + (inst jmp :l not-error) + (%clear-pseudo-atomic) + (inst jmp error) + (emit-label not-error)) (inst add (make-ea-for-symbol-value *free-tls-index*) (fixnumize 1)) (storew target other symbol-tls-index-slot other-pointer-lowtag) (emit-label release-tls-index-lock) + ;; No need for barriers on x86/x86-64 on unlock. (store-symbol-value 0 *tls-index-lock*) ;; Restore OTHER. (inst pop other))