Show irritant for the currently detected close calls.

original commit: 95bf94577c7c9d3c2c41075b3ba5d0b2ce2c1155
This commit is contained in:
Vincent St-Amour 2011-05-12 15:26:54 -04:00
parent ede348d487
commit a0de25443c
2 changed files with 11 additions and 4 deletions

View File

@ -1,9 +1,11 @@
#;
(
real-in-float-expr.rkt 10:0 (#%app * (quote 3) (quote 2.3)) -- binary, args all float-arg-expr, return type not Float
real-in-float-expr.rkt 12:0 (#%app * (quote 3) (quote 2.3)) -- binary, args all float-arg-expr, return type not Float -- caused by: 10:8 (quote 3)
real-in-float-expr.rkt 18:0 (#%app * (quote 2) (quote 2.0)) -- binary, args all float-arg-expr, return type not Float -- caused by: 17:8 (quote 2)
6.8999999999999995
6
5
4.0
)
#lang typed/racket
@ -12,3 +14,5 @@
(* (ann 2 Integer) (ann 3 Integer)) ; but these have nothing to do with floats, should not be logged
(+ (ann 2 Integer) (ann 3 Integer))
(* (ann 2 Natural) 2.0) ; close calls that result in Nonnegative-Real and co (i.e. not directly Real) should be reported too

View File

@ -89,12 +89,15 @@
#:when (let ([safe-to-opt? (subtypeof? this-syntax -Flonum)])
;; if we don't have a return type of float, we missed an optimization
;; opportunity, report it
;; ignore operations that stay within integers or rationals, since
;; these have nothing to do with float optimizations
(when (and (not safe-to-opt?)
(isoftype? this-syntax -Real))
(in-real-layer? this-syntax))
(log-close-call "binary, args all float-arg-expr, return type not Float"
this-syntax
(for/first ([x (in-list (syntax->list #'(f1 f2 fs ...)))])
(not (subtypeof? x -Flonum)))))
(for/first ([x (in-list (syntax->list #'(f1 f2 fs ...)))]
#:when (not (subtypeof? x -Flonum)))
x)))
safe-to-opt?)
#:with opt
(begin (log-optimization "binary float" #'op)