1.0.28.34: convert once-used DEFMACROs to EVAL-WHEN'd SB!XC:DEFMACROs
[sbcl.git] / tests / dynamic-extent.impure.lisp
index 6740a28..ae9a31c 100644 (file)
 
 (defun-with-dx dx-value-cell (x)
   ;; Not implemented everywhere, yet.
-  #+(or x86 x86-64 mips)
+  #+(or x86 x86-64 mips hppa)
   (let ((cell x))
     (declare (sb-int:truly-dynamic-extent cell))
     (flet ((f ()
     (true v)
     nil))
 
+(defun force-make-array-on-stack (n)
+  (declare (optimize safety))
+  (let ((v (make-array (min n 1))))
+    (declare (sb-int:truly-dynamic-extent v))
+    (true v)
+    nil))
+
 ;;; MAKE-STRUCTURE
 
 (declaim (inline make-fp-struct-1))
 
 (defvar *a-cons* (cons nil nil))
 
-#+(or x86 x86-64 alpha ppc sparc mips)
+#+(or x86 x86-64 alpha ppc sparc mips hppa)
 (progn
   (assert-no-consing (dxclosure 42))
   (assert-no-consing (dxlength 1 2 3))
   (assert-no-consing (dx-value-cell 13))
   (assert-no-consing (cons-on-stack 42))
   (assert-no-consing (make-array-on-stack))
+  (assert-no-consing (force-make-array-on-stack 128))
   (assert-no-consing (make-foo1-on-stack 123))
   (assert-no-consing (nested-good 42))
   (#+raw-instance-init-vops assert-no-consing
                14)
          ))))
 (assert (equal '((0 4) (3 ((1 2 3 5) 14))) (test-update-uvl-live-sets #() 4 5)))
+
+(with-test (:name :regression-1.0.23.38)
+  (compile nil '(lambda ()
+                 (flet ((make (x y)
+                          (let ((res (cons x x)))
+                            (setf (cdr res) y)
+                            res)))
+                   (declaim (inline make))
+                   (let ((z (make 1 2)))
+                     (declare (dynamic-extent z))
+                     (print z)
+                     t))))
+  (compile nil '(lambda ()
+                 (flet ((make (x y)
+                          (let ((res (cons x x)))
+                            (setf (cdr res) y)
+                            (if x res y))))
+                   (declaim (inline make))
+                   (let ((z (make 1 2)))
+                     (declare (dynamic-extent z))
+                     (print z)
+                     t)))))
+
+;;; On x86 and x86-64 upto 1.0.28.16 LENGTH and WORDS argument
+;;; tns to ALLOCATE-VECTOR-ON-STACK could be packed in the same
+;;; location, leading to all manner of badness. ...reproducing this
+;;; reliably is hard, but this it at least used to break on x86-64.
+(defun length-and-words-packed-in-same-tn (m)
+  (declare (optimize speed (safety 0) (debug 0) (space 0)))
+  (let ((array (make-array (max 1 m) :element-type 'fixnum)))
+    (declare (dynamic-extent array))
+    (array-total-size array)))
+(with-test (:name :length-and-words-packed-in-same-tn)
+  (assert (= 1 (length-and-words-packed-in-same-tn -3))))
 \f