Fix constant character comparisons for SPARC/sb-unicode
authorPaul Khuong <pvk@pvk.ca>
Sun, 30 Oct 2011 06:42:15 +0000 (02:42 -0400)
committerPaul Khuong <pvk@pvk.ca>
Sun, 30 Oct 2011 06:42:15 +0000 (02:42 -0400)
SPARC only supports (SIGNED-BYTE 13) for literal values.  Only emit
comparison with literal characters up to (CODE-CHAR 4095).

Reported by Eric Marsden on sbcl-devel.

Fixes lp#883519.

NEWS
src/compiler/sparc/char.lisp
tests/compiler.pure.lisp

diff --git a/NEWS b/NEWS
index d9a4ff9..bdc57a6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ changes relative to sbcl-1.0.52:
   * bug fix: low-level control flow optimisations could result in bogus
     code in functions with tail and non-tail calls to local functions on
     x86oids. (lp#883500)
+  * bug fix: on SPARC/:sb-unicode, avoid crashing the assembler by trying
+    to emit literal characters > (code-char 4095), for comparisons with
+    constant characters.
 
 changes in sbcl-1.0.52 relative to sbcl-1.0.51:
   * enhancement: ASDF has been updated to version 2.017.
index b3c6408..1f6a146 100644 (file)
 
 (define-vop (character-compare/c)
   (:args (x :scs (character-reg)))
-  (:arg-types character (:constant character))
+  (:arg-types character (:constant (character-set ((0 . 4095)))))
   (:conditional)
   (:info target not-p y)
   (:policy :fast-safe)
index f13a4a1..73cc33d 100644 (file)
                            (declare (optimize (speed 0)))
                            (mod (mod a (min -5 a)) 5)))
            1))
+
+;; Test for literals too large for the ISA (e.g. (SIGNED-BYTE 13) on SPARC).
+#+sb-unicode
+(with-test (:name :bug-883519)
+  (compile nil `(lambda (x)
+                  (declare (type character x))
+                  (eql x #\U0010FFFF))))