Optimizations in with-lock: save reference to current process and use some fixnum...
authorJuanjo Garcia-Ripoll <jjgarcia@users.sf.net>
Sun, 27 Oct 2013 23:00:38 +0000 (00:00 +0100)
committerJuanjo Garcia-Ripoll <jjgarcia@users.sf.net>
Sun, 27 Oct 2013 23:00:38 +0000 (00:00 +0100)
src/lsp/mp.lsp

index b4c4521..66dff01 100644 (file)
@@ -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))))))))