X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fassembly%2Fx86-64%2Falloc.lisp;h=e40d38051015cf6e785fed992c5da07e238b89ee;hb=ded09c061bb9cb4f6829c532c1c6f09637a46477;hp=2c113b0332734232e87cd5a75a21bdf38007e95b;hpb=b71ea3ac652d67b53d415378ed27da80cc90806f;p=sbcl.git diff --git a/src/assembly/x86-64/alloc.lisp b/src/assembly/x86-64/alloc.lisp index 2c113b0..e40d380 100644 --- a/src/assembly/x86-64/alloc.lisp +++ b/src/assembly/x86-64/alloc.lisp @@ -92,24 +92,30 @@ (inst push other) (inst push target) (emit-label get-tls-index-lock) - (inst mov target 1) - (zeroize rax-tn) - (inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*) target :lock) - (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 ;; set in the meantime. (loadw target other symbol-tls-index-slot other-pointer-lowtag) - (inst or target target) + (inst test target target) (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))) - (inst cmp target (fixnumize tls-size)) - (inst jmp :ge error)) + (let ((not-error (gen-label)) + (error (generate-error-code nil 'tls-exhausted-error))) + (inst cmp target (ash tls-size word-shift)) + (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)) + n-word-bytes) (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.