diff --git a/src/lsp/mp.lsp b/src/lsp/mp.lsp index b4c4521..66dff01 100644 --- a/src/lsp/mp.lsp +++ b/src/lsp/mp.lsp @@ -116,16 +116,20 @@ by ALLOW-WITH-INTERRUPTS." ;; the get-lock statement, to ensure that the unlocking is done with ;; interrupts disabled. #+threads - (ext:with-unique-names (lock owner count) + (ext:with-unique-names (lock owner count process) `(let* ((,lock ,lock-form) (,owner (mp:lock-owner ,lock)) (,count (mp:lock-count ,lock))) + (declare (type fixnum ,count)) (without-interrupts (unwind-protect (with-restored-interrupts (mp::get-lock ,lock) (locally ,@body)) - (when (and (eq mp:*current-process* (mp:lock-owner ,lock)) - (or (not (eq ,owner mp:*current-process*)) - (> (mp:lock-count ,lock) ,count))) - (mp::giveup-lock ,lock))))))) + (let ((,process mp:*current-process*)) + (declare (optimize (speed 3) (safety 0) (debug 0))) + (when (and (eq ,process (mp:lock-owner ,lock)) + (or (not (eq ,owner ,process)) + (> (the fixnum (mp:lock-count ,lock)) + (the fixnum ,count)))) + (mp::giveup-lock ,lock))))))))