master: Slightly more compact debug register encoding

stassats via Sbcl-commits <[email protected]>
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  4891fda939bb5a1d56d60864d679aea3e1f2fa75 (commit)
      from  9e3da6bd41ec22d462b583daf866edb2edb4eb6d (commit)

- Log -----------------------------------------------------------------
commit 4891fda939bb5a1d56d60864d679aea3e1f2fa75
Author: Stas Boukarev <[email protected]>
Date:   Sat Aug 29 01:06:52 2026 +0300

    Slightly more compact debug register encoding
    
    Assign any-reg and descriptor-reg the same id.
    Both any-reg and descriptor-reg are tagged and are accessed in the
    same way.
    Saves 95K on a 35MB core.
---
 src/code/debug-info.lisp          | 10 ++++++++++
 src/code/sc-offset.lisp           |  5 -----
 src/compiler/generic/vm-macs.lisp |  5 +++--
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/code/debug-info.lisp b/src/code/debug-info.lisp
index f4a331231..39eb650ad 100644
--- a/src/code/debug-info.lisp
+++ b/src/code/debug-info.lisp
@@ -438,3 +438,13 @@
   ;; The compiler really needs to be made more aware of
   ;; some issues involving recursive structures.
   (parent nil :type (or null source-info) :read-only t))
+
+(defun make-sc+offset (sc-number offset)
+  ;; Both any-reg and descriptor-reg are tagged and are accessed in
+  ;; the same way, combine them to reduce debug info size.
+  (when (eq sc-number sb-vm:any-reg-sc-number)
+    (setf sc-number sb-vm:descriptor-reg-sc-number))
+  (dpb (ash sc-number (- (byte-size (car +sc+offset-scn-bytes+))))
+       (cadr +sc+offset-scn-bytes+)
+       (logior (ash offset (byte-position (car +sc+offset-offset-bytes+)))
+               (logand sc-number (ldb (car +sc+offset-scn-bytes+) -1)))))
diff --git a/src/code/sc-offset.lisp b/src/code/sc-offset.lisp
index 3315b461c..9813b02e2 100644
--- a/src/code/sc-offset.lisp
+++ b/src/code/sc-offset.lisp
@@ -41,11 +41,6 @@
 (assert (and (= (length +sc+offset-offset-bytes+) 1)
              (= (length +sc+offset-scn-bytes+) 2)
              (= (byte-position (car +sc+offset-scn-bytes+)) 0)))
-(defun make-sc+offset (sc-number offset)
-  (dpb (ash sc-number (- (byte-size (car +sc+offset-scn-bytes+))))
-       (cadr +sc+offset-scn-bytes+)
-       (logior (ash offset (byte-position (car +sc+offset-offset-bytes+)))
-               (logand sc-number (ldb (car +sc+offset-scn-bytes+) -1)))))
 
 (declaim (ftype (sfunction (sc+offset) sc-number)
                 sc+offset-scn)
diff --git a/src/compiler/generic/vm-macs.lisp b/src/compiler/generic/vm-macs.lisp
index b580d95c9..cd7900248 100644
--- a/src/compiler/generic/vm-macs.lisp
+++ b/src/compiler/generic/vm-macs.lisp
@@ -197,9 +197,10 @@
 ;;; determined) and assign the rest sequentially.
 (defmacro !define-storage-classes (&rest classes)
   (let* ((fixed-numbers '((descriptor-reg . 0)
-                          (any-reg        . 1)
+                          (control-stack  . 1)
                           (signed-reg     . 2)
-                          (constant       . 3)))
+                          (constant       . 3)
+                          (any-reg        . 4))) ;; any-reg will be merged with descriptor-reg by make-sc+offset
          (index (length fixed-numbers)))
     (flet ((process-class (class-spec)
              (destructuring-bind (sc-name sb-name &rest args) class-spec

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.