From 00ac8aa57864e614e832e1908e4b8775a3957648 Mon Sep 17 00:00:00 2001 From: Alexey Dejneka Date: Mon, 13 Jun 2005 11:05:44 +0000 Subject: [PATCH] 0.9.1.40: * COERCE for objects other than numbers and characters is not foldable (fix a bug reported by Nikodemus Siivola). * Set LC_ALL to "C" when building SBCL. * Set locale to "C" in run-tests.sh. --- make.sh | 2 ++ src/compiler/fndb.lisp | 20 ++------------------ src/compiler/typetran.lisp | 10 ++++++++++ tests/compiler.impure-cload.lisp | 12 ++++++++++++ tests/run-tests.sh | 5 +++++ version.lisp-expr | 2 +- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/make.sh b/make.sh index 8f8d703..3a81875 100755 --- a/make.sh +++ b/make.sh @@ -53,7 +53,9 @@ # UPGRADED-ARRAY-ELEMENT-TYPE?) LANG=C +LC_ALL=C export LANG +export LC_ALL build_started=`date` echo "//starting build: $build_started" diff --git a/src/compiler/fndb.lisp b/src/compiler/fndb.lisp index 404e4ef..5225b60 100644 --- a/src/compiler/fndb.lisp +++ b/src/compiler/fndb.lisp @@ -17,24 +17,8 @@ (defknown coerce (t type-specifier) t ;; Note: - ;; (1) This is not FLUSHABLE because it's defined to signal errors. - ;; (2) It's not worth trying to make this FOLDABLE in the - ;; cross-compiler,because - ;; (a) it would probably be really hard to make all the - ;; tricky issues (e.g. which specialized array types are - ;; supported) match between cross-compiler and target - ;; compiler, and besides - ;; (b) leaving it not FOLDABLE lets us use the idiom - ;; (COERCE FOO 'SOME-SPECIALIZED-ARRAY-TYPE-OR-ANOTHER) - ;; as a way of delaying the generation of specialized - ;; array types until runtime, which helps us keep the - ;; cross-compiler's dumper relatively simple and which - ;; lets us preserve distinctions which might not even exist - ;; on the cross-compilation host (because ANSI doesn't - ;; guarantee that specialized array types exist there). - ;; FIXME: It's actually not clear that COERCE on non-NUMBER types - ;; is FOLDABLE at all. Check this. - (movable #-sb-xc-host foldable) + ;; This is not FLUSHABLE because it's defined to signal errors. + (movable) ;; :DERIVE-TYPE RESULT-TYPE-SPEC-NTH-ARG 2 ? Nope... (COERCE 1 'COMPLEX) ;; returns REAL/INTEGER, not COMPLEX. ) diff --git a/src/compiler/typetran.lisp b/src/compiler/typetran.lisp index 5d0fa9d..612d2bc 100644 --- a/src/compiler/typetran.lisp +++ b/src/compiler/typetran.lisp @@ -537,6 +537,16 @@ ;;;; coercion +;;; Constant-folding. +;;; +#-sb-xc-host +(defoptimizer (coerce optimizer) ((x type) node) + (when (and (constant-lvar-p x) (constant-lvar-p type)) + (let ((value (lvar-value x))) + (when (or (numberp value) (characterp value)) + (constant-fold-call node) + t)))) + (deftransform coerce ((x type) (* *) * :node node) (unless (constant-lvar-p type) (give-up-ir1-transform)) diff --git a/tests/compiler.impure-cload.lisp b/tests/compiler.impure-cload.lisp index 39c4d18..c82bef3 100644 --- a/tests/compiler.impure-cload.lisp +++ b/tests/compiler.impure-cload.lisp @@ -408,5 +408,17 @@ (assert (= (isieve 46349) 4792)) +;;; COERCE should not be constant-folded (reported by Nikodemus +;;; Siivola) +(let ((f (gensym))) + (setf (fdefinition f) (lambda (x) x)) + (let ((g (compile nil `(lambda () (coerce ',f 'function))))) + (setf (fdefinition f) (lambda (x) (1+ x))) + (assert (eq (funcall g) (fdefinition f))))) + +(let ((x (coerce '(1 11) 'vector))) + (incf (aref x 0)) + (assert (equalp x #(2 11)))) + (sb-ext:quit :unix-status 104) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 674b965..4060d14 100644 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -35,6 +35,11 @@ SBCL_ALLOWING_CORE=${1:-$sbclstem} export SBCL_ALLOWING_CORE echo /with SBCL_ALLOWING_CORE=\'$SBCL_ALLOWING_CORE\' +LANG=C +LC_ALL=C +export LANG +export LC_ALL + # "Ten four" is the closest numerical slang I can find to "OK", so # it's the Unix status value that we expect from a successful test. # (Of course, zero is the usual success value, but we don't want to diff --git a/version.lisp-expr b/version.lisp-expr index 9d965c1..3e087f9 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.9.1.39" +"0.9.1.40" -- 1.7.10.4