From: Taylor R Campbell Date: Fri, 16 Nov 2018 08:35:42 +0000 (+0000) Subject: Revert "Remove workaround for 9.2 compiler bug." X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~77 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=690adab07f3f98ccc53d38a75347f184e8811248;p=mit-scheme.git Revert "Remove workaround for 9.2 compiler bug." This reverts commit 7828111b77fb53e34b365abc775148f49eabe1d2. I haven't tracked this down because the stack trace is full of frames in the compiler for which we don't install debug data but the symptom is: ; Compiling file: "./floenv.bin" => "./floenv.com"... ;The object +inf.0, passed as the first argument to flonum-normalize, is not the correct type. First few frames suggest this is in flo:->rational called by something in RTL CSE. --- diff --git a/src/runtime/floenv.scm b/src/runtime/floenv.scm index 3c78ef5b5..d4d478ee3 100644 --- a/src/runtime/floenv.scm +++ b/src/runtime/floenv.scm @@ -362,27 +362,30 @@ USA. (define flo:nan.0) (define flo:+inf.0) (define flo:-inf.0) -(if (flo:have-trap-enable/disable?) - (begin - (set! flo:nan.0 - (named-lambda (flo:nan.0) - (flo:with-exceptions-untrapped (flo:exception:invalid-operation) - (lambda () - (flo:/ 0. 0.))))) - (set! flo:+inf.0 - (named-lambda (flo:+inf.0) - (flo:with-exceptions-untrapped (flo:exception:divide-by-zero) - (lambda () - (flo:/ +1. 0.))))) - (set! flo:-inf.0 - (named-lambda (flo:-inf.0) - (flo:with-exceptions-untrapped (flo:exception:divide-by-zero) - (lambda () - (flo:/ -1. 0.))))) - unspecific) - ;; This works on macOS. YMMV. - (begin - (set! flo:nan.0 (named-lambda (flo:nan.0) (flo:/ 0. 0.))) - (set! flo:+inf.0 (named-lambda (flo:+inf.0) (flo:/ +1. 0.))) - (set! flo:-inf.0 (named-lambda (flo:-inf.0) (flo:/ -1. 0.))) - unspecific)) \ No newline at end of file +;;; ZERO can be eliminated after 9.3 is released. It works around +;;; overly-aggressive constant folding in SF and LIAR. +(let ((zero (lambda () (identity-procedure 0.)))) + (if (flo:have-trap-enable/disable?) + (begin + (set! flo:nan.0 + (named-lambda (flo:nan.0) + (flo:with-exceptions-untrapped (flo:exception:invalid-operation) + (lambda () + (flo:/ 0. (zero)))))) + (set! flo:+inf.0 + (named-lambda (flo:+inf.0) + (flo:with-exceptions-untrapped (flo:exception:divide-by-zero) + (lambda () + (flo:/ +1. (zero)))))) + (set! flo:-inf.0 + (named-lambda (flo:-inf.0) + (flo:with-exceptions-untrapped (flo:exception:divide-by-zero) + (lambda () + (flo:/ -1. (zero)))))) + unspecific) + ;; This works on macOS. YMMV. + (begin + (set! flo:nan.0 (named-lambda (flo:nan.0) (flo:/ 0. (zero)))) + (set! flo:+inf.0 (named-lambda (flo:+inf.0) (flo:/ +1. (zero)))) + (set! flo:-inf.0 (named-lambda (flo:-inf.0) (flo:/ -1. (zero)))) + unspecific))) \ No newline at end of file