master: Cons nothing for alien linkage entries that exist

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

- Log -----------------------------------------------------------------
commit aab1a9d230c5ed1cd09477e6176790a1b8f54053
Author: Douglas Katzman <[email protected]>
Date:   Thu Apr 9 11:11:40 2026 -0400

    Cons nothing for alien linkage entries that exist
---
 src/code/foreign.lisp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/code/foreign.lisp b/src/code/foreign.lisp
index 1a90bdde4..ab890d0a1 100644
--- a/src/code/foreign.lisp
+++ b/src/code/foreign.lisp
@@ -45,20 +45,21 @@
 
 ;;; Return the index of NAME+DATAP in the table, adding it if it doesn't exist.
 (defun ensure-alien-linkage-index (name datap)
-  (let* ((name (possibly-base-stringize name))
-         (key (if datap (list name) name))
+  (let* ((key (if datap (list name) name))
          (info *linkage-info*)
          (ht (car info)))
+    (declare (dynamic-extent key))
     (or (with-system-mutex ((hash-table-lock ht))
           (or (gethash key ht)
               (let* ((index (hash-table-count ht))
                      (capacity (floor sb-vm:alien-linkage-space-size
-                                      sb-vm:alien-linkage-table-entry-size)))
+                                      sb-vm:alien-linkage-table-entry-size))
+                     (name (logically-readonlyize (possibly-base-stringize name)))
+                     (key (if datap (list name) name)))
                 (when (< index capacity)
                   (multiple-value-bind (defined real-address) (dlsym-wrapper t)
                     (unless defined (push key (cdr info)))
                     (arch-write-linkage-table-entry index real-address (if datap 1 0))
-                    (logically-readonlyize name)
                     (setf (gethash key ht) index))))))
         (error "Linkage-table full (~D entries): cannot link ~S."
                (hash-table-count ht) name))))

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


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.