Generalized CPS optimization fix

This commit is contained in:
Justin Ethier 2016-07-15 02:55:53 -04:00
parent ccf8329ffb
commit 9311ee5f83

View file

@ -26,6 +26,7 @@
adb:set! adb:set!
adb:get-db adb:get-db
simple-lambda? simple-lambda?
one-instance-of-new-mutable-obj?
;; Analyze variables ;; Analyze variables
adb:make-var adb:make-var
%adb:make-var %adb:make-var
@ -472,16 +473,14 @@
(every (every
(lambda (arg) (lambda (arg)
(and (prim-call? arg) (and (prim-call? arg)
(not (prim:cont? (car arg))) (not (prim:cont? (car arg)))))
(cdr exp))
;; Disallow primitives that allocate a new obj, ;; Disallow primitives that allocate a new obj,
;; because if the object is mutated all copies ;; because if the object is mutated all copies
;; must be modified. ;; must be modified.
;; (one-instance-of-new-mutable-obj?
;; TODO: Technically this could be allowed if (cdr exp)
;; there is only one reference of the variable (ast:lambda-formals->list (car exp)))
;(not (prim-creates-mutable-obj? (car arg)))
))
(cdr exp))
(inline-prim-call? (inline-prim-call?
(ast:lambda-body (car exp)) (ast:lambda-body (car exp))
(prim-calls->arg-variables (cdr exp)) (prim-calls->arg-variables (cdr exp))
@ -546,7 +545,9 @@
;; only one of the instances will be affected. ;; only one of the instances will be affected.
(if (and (prim-call? call) (if (and (prim-call? call)
(prim-creates-mutable-obj? (car call)) (prim-creates-mutable-obj? (car call))
;; TODO: arg used more than once ;; Make sure arg is not used more than once
(with-var arg (lambda (var)
(> (adbv:app-arg-count var) 1)))
) )
(return #f)))) (return #f))))
calls/args) calls/args)