X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fdynamic-extent.impure.lisp;h=99d925acfd794dfd6c7087cceae43ef3955ce573;hb=9837343101c3da7b3a8f94609ec116ec5025436a;hp=9aba2db66889dd7a1df2d707202b23e6aab76456;hpb=b77ebf21b137cd0debcb7a2a1f52b093ce28ee02;p=sbcl.git diff --git a/tests/dynamic-extent.impure.lisp b/tests/dynamic-extent.impure.lisp index 9aba2db..99d925a 100644 --- a/tests/dynamic-extent.impure.lisp +++ b/tests/dynamic-extent.impure.lisp @@ -129,7 +129,7 @@ (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 () @@ -153,6 +153,13 @@ (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)) @@ -463,7 +470,7 @@ (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)) @@ -477,6 +484,7 @@ (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 @@ -634,4 +642,57 @@ (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)))))