1.0.28.54: more principled approach to complex dumping in the xc
authorNikodemus Siivola <nikodemus@random-state.net>
Sun, 17 May 2009 17:11:59 +0000 (17:11 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Sun, 17 May 2009 17:11:59 +0000 (17:11 +0000)
  Christophe points out that (UPGRADED-COMPLEX-PART-TYPE 'DOUBLE-FLOAT)
  can be REAL on some hosts, in which case the host will happily
  agree that (TYPEP #C(2 2) '(COMPLEX DOUBLE-FLOAT)) is true... etc.

  So in the cross compiler look at the type of the parts of the
  complex, and refuse to dump it if it doesn't look like something we
  can handle correctly.

src/compiler/dump.lisp
version.lisp-expr

index 8b7f9b0..04f6be7 100644 (file)
      (dump-fop 'fop-long-float file)
      (dump-long-float x file))))
 
+(defun dump-complex-single-float (re im file)
+  (declare (single-float re im))
+  (dump-fop 'fop-complex-single-float file)
+  (dump-integer-as-n-bytes (single-float-bits re) 4 file)
+  (dump-integer-as-n-bytes (single-float-bits im) 4 file))
+
+(defun dump-complex-double-float (re im file)
+  (declare (double-float re im))
+  (dump-fop 'fop-complex-double-float file)
+  (dump-integer-as-n-bytes (double-float-low-bits re) 4 file)
+  (dump-integer-as-n-bytes (double-float-high-bits re) 4 file)
+  (dump-integer-as-n-bytes (double-float-low-bits im) 4 file)
+  (dump-integer-as-n-bytes (double-float-high-bits im) 4 file))
+
+(defun dump-complex-rational (re im file)
+  (sub-dump-object re file)
+  (sub-dump-object im file)
+  (dump-fop 'fop-complex file))
+
+#+sb-xc-host
+(defun dump-complex (x file)
+  (let ((re (realpart x))
+        (im (imagpart x)))
+    (cond ((and (typep re 'single-float)
+                (typep im 'single-float))
+           (dump-complex-single-float re im file))
+          ((and (typep re 'double-float)
+                (typep im 'double-float))
+           (dump-complex-double-float re im file))
+          ((and (typep re 'rational)
+                (typep im 'rational))
+           (dump-complex-rational re im file))
+          (t
+           (bug "Complex number too complex: ~S" x)))))
+
+#-sb-xc-host
 (defun dump-complex (x file)
   (typecase x
     ((complex single-float)
-     (dump-fop 'fop-complex-single-float file)
-     (dump-integer-as-n-bytes (single-float-bits (realpart x)) 4 file)
-     (dump-integer-as-n-bytes (single-float-bits (imagpart x)) 4 file))
+     (dump-complex-single-float (realpart x) (imagpart x) file))
     ((complex double-float)
-     (dump-fop 'fop-complex-double-float file)
-     (let ((re (realpart x)))
-       (declare (double-float re))
-       (dump-integer-as-n-bytes (double-float-low-bits re) 4 file)
-       (dump-integer-as-n-bytes (double-float-high-bits re) 4 file))
-     (let ((im (imagpart x)))
-       (declare (double-float im))
-       (dump-integer-as-n-bytes (double-float-low-bits im) 4 file)
-       (dump-integer-as-n-bytes (double-float-high-bits im) 4 file)))
+     (dump-complex-double-float (realpart x) (imagpart x) file))
     #!+long-float
     ((complex long-float)
      ;; (There's no easy way to mix #!+LONG-FLOAT and #-SB-XC-HOST
      (dump-long-float (realpart x) file)
      (dump-long-float (imagpart x) file))
     (t
-     (sub-dump-object (realpart x) file)
-     (sub-dump-object (imagpart x) file)
-     (dump-fop 'fop-complex file))))
+     (dump-complex-rational (realpart x) (imagpart x) file))))
 \f
 ;;;; symbol dumping
 
index 62e1b93..3a4c649 100644 (file)
@@ -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".)
-"1.0.28.53"
+"1.0.28.54"