Recognize more procedures in scheme_optimize_apply_values
scheme_optimize_apply_values reduces (call-with-values gen proc) to (#%apply-values proc gen) when recognizes proc as a procedure. This extends the expressions that are recognized as procedures.
This commit is contained in:
parent
0c5944d64a
commit
4b8517b27c
|
@ -3444,6 +3444,28 @@
|
|||
(err/rt-test (cwv-2-5-f (lambda () 1) (lambda (y z) (+ y 2))) exn:fail:contract:arity?)
|
||||
(err/rt-test (cwv-2-5-f (lambda () (values 1 2 3)) (lambda (y z) (+ y 2))) exn:fail:contract:arity?)
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Transform call-with-values to direct aplication:
|
||||
(test-comp '(lambda (f) (f 7))
|
||||
'(lambda (f) (call-with-values (lambda () 7) (lambda (x) (f x)))))
|
||||
(test-comp '(lambda () (car 7))
|
||||
'(lambda () (call-with-values (lambda () 7) car)))
|
||||
(test-comp '(lambda () ('not-a-procedure 7))
|
||||
'(lambda () (call-with-values (lambda () 7) 'not-a-procedure))
|
||||
#f)
|
||||
(test-comp '(module ? racket/base
|
||||
(define f (lambda (x) (list x 0)))
|
||||
(lambda () (display f) (f 7)))
|
||||
'(module ? racket/base
|
||||
(define f (lambda (x) (list x 0)))
|
||||
(lambda () (display f) (call-with-values (lambda () 7) f))))
|
||||
(test-comp '(module ? racket/base
|
||||
(define f (let ([tmp (list 0)]) (lambda (x) (list x tmp))))
|
||||
(lambda () (f 7)))
|
||||
'(module ? racket/base
|
||||
(define f (let ([tmp (list 0)]) (lambda (x) (list x tmp))))
|
||||
(lambda () (call-with-values (lambda () 7) f))))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Inlining with higher-order functions:
|
||||
|
||||
|
@ -4520,7 +4542,7 @@
|
|||
(report-answer-all 8)))))))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Check that cross-module inlining decmopiles a function
|
||||
;; Check that cross-module inlining decompiles a function
|
||||
;; with correct use counts on arguments (specifically: B is used
|
||||
;; twice, so the argument expression can't be inlined for two uses)
|
||||
|
||||
|
|
|
@ -3626,7 +3626,10 @@ Scheme_Object *scheme_optimize_apply_values(Scheme_Object *f, Scheme_Object *e,
|
|||
if (rev) {
|
||||
int rator2_flags;
|
||||
Scheme_Object *o_f;
|
||||
o_f = optimize_for_inline(info, rev, 1, NULL, NULL, NULL, &rator2_flags, context, 0, 0);
|
||||
o_f = lookup_constant_proc(info, rev, 0);
|
||||
if (!o_f)
|
||||
o_f = optimize_for_inline(info, rev, 1, NULL, NULL, NULL, &rator2_flags, context, 0, 0);
|
||||
|
||||
if (o_f) {
|
||||
f_is_proc = rev;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user