From 1c15a39341688bbca470c9187717d6370316b5c0 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sun, 17 May 2009 17:11:59 +0000 Subject: [PATCH] 1.0.28.54: more principled approach to complex dumping in the xc 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 | 54 ++++++++++++++++++++++++++++++++++-------------- version.lisp-expr | 2 +- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/compiler/dump.lisp b/src/compiler/dump.lisp index 8b7f9b0..04f6be7 100644 --- a/src/compiler/dump.lisp +++ b/src/compiler/dump.lisp @@ -566,22 +566,48 @@ (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 @@ -592,9 +618,7 @@ (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)))) ;;;; symbol dumping diff --git a/version.lisp-expr b/version.lisp-expr index 62e1b93..3a4c649 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".) -"1.0.28.53" +"1.0.28.54" -- 1.7.10.4