X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fdynamic-extent.impure.lisp;h=685ff6d5b926fe814b928ab78adff92f46b0028b;hb=5d5894082c39ca44da75d38859d669c7b2108f6a;hp=4eb2db36be90dbd5cb6abbbcad6a83b58dd1caca;hpb=f2f24807c969eeab86a4daa7f1fc611e7bd27594;p=sbcl.git diff --git a/tests/dynamic-extent.impure.lisp b/tests/dynamic-extent.impure.lisp index 4eb2db3..685ff6d 100644 --- a/tests/dynamic-extent.impure.lisp +++ b/tests/dynamic-extent.impure.lisp @@ -14,13 +14,12 @@ (when (eq sb-ext:*evaluator-mode* :interpret) (sb-ext:quit :unix-status 104)) -(setq sb-c::*check-consistency* t) +(setq sb-c::*check-consistency* t + sb-ext:*stack-allocate-dynamic-extent* t) (defmacro defun-with-dx (name arglist &body body) - `(locally - (declare (optimize sb-c::stack-allocate-dynamic-extent)) - (defun ,name ,arglist - ,@body))) + `(defun ,name ,arglist + ,@body)) (declaim (notinline opaque-identity)) (defun opaque-identity (x) @@ -129,11 +128,10 @@ ;;; value-cells (defun-with-dx dx-value-cell (x) - (declare (optimize sb-c::stack-allocate-value-cells)) ;; Not implemented everywhere, yet. #+(or x86 x86-64 mips) (let ((cell x)) - (declare (dynamic-extent cell)) + (declare (sb-int:truly-dynamic-extent cell)) (flet ((f () (incf cell))) (declare (dynamic-extent #'f)) @@ -385,7 +383,8 @@ ;;; handler-case and handler-bind should use DX internally (defun dx-handler-bind (x) - (handler-bind ((error (lambda (c) (break "OOPS: ~S caused ~S" x c))) + (handler-bind ((error + (lambda (c) (break "OOPS: ~S caused ~S" x c))) ((and serious-condition (not error)) #'(lambda (c) (break "OOPS2: ~S did ~S" x c)))) (/ 2 x))) @@ -397,7 +396,7 @@ (:no-error (res) (1- res)))))) -;;; with-spinlock should use DX and not cons +;;; with-spinlock and with-mutex should use DX and not cons (defvar *slock* (sb-thread::make-spinlock :name "slocklock")) @@ -405,6 +404,12 @@ (sb-thread::with-spinlock (*slock*) (true *slock*))) +(defvar *mutex* (sb-thread::make-mutex :name "mutexlock")) + +(defun test-mutex () + (sb-thread:with-mutex (*mutex*) + (true *mutex*))) + ;;; not really DX, but GETHASH and (SETF GETHASH) should not cons (defvar *table* (make-hash-table)) @@ -466,7 +471,9 @@ ;; Not strictly DX.. (assert-no-consing (test-hash-table)) #+sb-thread - (assert-no-consing (test-spinlock))) + (progn + (assert-no-consing (test-spinlock)) + (assert-no-consing (test-mutex)))) ;;; Bugs found by Paul F. Dietz @@ -563,4 +570,21 @@ (def 0 (list :one) (list :two) (list :three)) (def 1 (make-array 128) (list 1 2 3 4 5 6 7 8) (list 'list)) (def 2 (list 1) (list 2 3) (list 4 5 6 7))) + +;;; Test that unknown-values coming after a DX value won't mess up the stack analysis +(defun test-update-uvl-live-sets (x y z) + (declare (optimize speed (safety 0))) + (flet ((bar (a b) + (declare (dynamic-extent a)) + (eval `(list (length ',a) ',b)))) + (list (bar x y) + (bar (list x y z) ; dx push + (list + (multiple-value-call 'list + (eval '(values 1 2 3)) ; uv push + (max y z) + ) ; uv pop + 14) + )))) +(assert (equal '((0 4) (3 ((1 2 3 5) 14))) (test-update-uvl-live-sets #() 4 5)))