fix optimizer imprecision for values

Without this repair,

 #lang racket/base
 (require 2htdp/abstraction)
 (for/list ((dropping-which-one (in-naturals)))
   1)

fails to compile with a "optimizer clock tracking has gone wrong"
error. A variant of this test (that doesn't depend on `2htdp`)
is now in the "optimize.rktl"; a simpler and more direct test
should be possible, but I wasn't able to construct one.
This commit is contained in:
Matthew Flatt 2016-11-20 17:37:35 -07:00
parent 09c1174f7e
commit 7c22c42c72
2 changed files with 36 additions and 1 deletions

View File

@ -6390,6 +6390,37 @@
(set! f f)
((car f))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Regression test to check that `values` is
;; handled correctly for estimating clock advances
(module triggers-optimizer-clock-estimation racket/base
(require (for-syntax racket/base))
(define (in-naturals0 n)
(in-naturals n))
;; restrict for/xyz to simple form and name it for/xyz0
(define-syntax (define-for stx)
(syntax-case stx ()
[(_ for/xyz0 for/xyz cleanup)
#'(define-syntax (for/xyz0 stx)
(syntax-case stx ()
[(_ ((clause0.x clause0.range)) body)
#`(cleanup
(for/xyz ((clause0.x (string> clause0.range)))
;; the following line exists only so that coverage doesn't hilite x0 x ...
clause0.x
body))]))]))
(define-for for/list0 for/list values)
(define (string> s)
(if (string? s) (string->list s) s))
(void
(for/list0 ((dropping-which-one (in-naturals0))) 1)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -2815,6 +2815,8 @@ static int is_noncapturing_primitive(Scheme_Object *rator, int n)
t = (((Scheme_Primitive_Proc *)rator)->pp.flags & SCHEME_PRIM_OTHER_TYPE_MASK);
if (!n && (t == SCHEME_PRIM_TYPE_PARAMETER))
return 1;
if (SAME_TYPE(rator, scheme_values_proc))
return 1;
}
return 0;
@ -2827,6 +2829,8 @@ static int is_nonsaving_primitive(Scheme_Object *rator, int n)
opt = ((Scheme_Prim_Proc_Header *)rator)->flags & SCHEME_PRIM_OPT_MASK;
if (opt >= SCHEME_PRIM_OPT_IMMEDIATE)
return 1;
if (SAME_TYPE(rator, scheme_values_proc))
return 1;
}
return 0;
@ -6893,7 +6897,7 @@ void advance_clocks_for_optimized(Scheme_Object *o,
Optimize_Info *info,
int fuel)
/* It's ok for this function to advance clocks *less* than
acurrately, but not more than acurrately */
accurately, but not more than accurately */
{
Scheme_Object *rator = NULL;
int argc = 0;