(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))
(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
(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))))
+
+(with-test (:name :handler-case-bogus-compiler-note)
+ (handler-bind ((compiler-note #'error))
+ ;; Taken from SWANK, used to signal a bogus stack allocation
+ ;; failure note.
+ (compile nil
+ `(lambda (files fasl-dir load)
+ (let ((needs-recompile nil))
+ (dolist (src files)
+ (let ((dest (binary-pathname src fasl-dir)))
+ (handler-case
+ (progn
+ (when (or needs-recompile
+ (not (probe-file dest))
+ (file-newer-p src dest))
+ (setq needs-recompile t)
+ (ensure-directories-exist dest)
+ (compile-file src :output-file dest :print nil :verbose t))
+ (when load
+ (load dest :verbose t)))
+ (serious-condition (c)
+ (handle-loadtime-error c dest))))))))))
+
+(with-test (:name :dx-compiler-notes)
+ (let ((n 0))
+ (handler-bind ((compiler-note (lambda (c)
+ (declare (ignore cc))
+ (incf n))))
+ (compile nil `(lambda (x)
+ (let ((v (make-array x)))
+ (declare (dynamic-extent v))
+ (length v))))
+ (assert (= 1 n))
+ (compile nil `(lambda (x)
+ (let ((y (if (plusp x)
+ (true x)
+ (true (- x)))))
+ (declare (dynamic-extent y))
+ (print y)
+ nil)))
+ (assert (= 3 n)))))
\f