master: arm64: don't check types in the length/list VOP with zero safety

stassats via Sbcl-commits <[email protected]> Thu, 07 May 2026 00:04:28 +0000
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  c8aefbf5fe27fcc1bc0d8794a26b95aca472acfa (commit)
      from  5598c57d2552b44d956c9ad849d46eb3bce4872f (commit)

- Log -----------------------------------------------------------------
commit c8aefbf5fe27fcc1bc0d8794a26b95aca472acfa
Author: Stas Boukarev <[email protected]>
Date:   Thu May 7 03:02:45 2026 +0300

    arm64: don't check types in the length/list VOP with zero safety
---
 src/compiler/arm64/subprim.lisp | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/compiler/arm64/subprim.lisp b/src/compiler/arm64/subprim.lisp
index 77e5a840c..fa687b00c 100644
--- a/src/compiler/arm64/subprim.lisp
+++ b/src/compiler/arm64/subprim.lisp
@@ -23,25 +23,29 @@
   (:results (result :scs (any-reg descriptor-reg)))
   (:policy :fast-safe)
   (:vop-var vop)
+  (:node-var node)
   (:save-p :compute-only)
   (:generator 50
-      (move ptr object)
-      (inst mov count 0)
+    (let ((safe (policy node (> sb-c::type-check 0))))
+      (assemble ()
+        (move ptr object)
+        (inst mov count 0)
 
-      LOOP
+        LOOP
 
-      (inst cmp ptr null-tn)
-      (inst b :eq done)
+        (inst cmp ptr null-tn)
+        (inst b :eq done)
 
-      (test-type ptr temp not-list t (list-pointer-lowtag))
+        (when safe
+          (test-type ptr temp not-list t (list-pointer-lowtag)))
 
-      (loadw ptr ptr cons-cdr-slot list-pointer-lowtag)
-      (inst add count count (fixnumize 1))
-      (inst b loop)
+        (loadw ptr ptr cons-cdr-slot list-pointer-lowtag)
+        (inst add count count (fixnumize 1))
+        (inst b loop)
 
-      NOT-LIST
+        NOT-LIST
+        (when safe
+          (error-call vop 'object-not-list-error ptr))
 
-      (error-call vop 'object-not-list-error ptr)
-
-      DONE
-      (move result count)))
+        DONE
+        (move result count)))))

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


hooks/post-receive
-- 
SBCL