From 0ca6dbccbefc4eddf62a0c7c96a823977b0c798b Mon Sep 17 00:00:00 2001 From: Juanjo Garcia-Ripoll Date: Mon, 28 Oct 2013 00:00:38 +0100 Subject: [PATCH] Optimizations in with-lock: save reference to current process and use some fixnum comparisons. --- src/lsp/mp.lsp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lsp/mp.lsp b/src/lsp/mp.lsp index b4c4521df..66dff01c9 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))))))))