Do not inline if there is an indirect mutation

This commit is contained in:
Justin Ethier 2016-11-17 18:52:00 -05:00
parent 11cf558ba8
commit 88e54286bb

View file

@ -687,7 +687,8 @@
;; Helper for the next function
(define (inline-prim-call? exp ivars args)
(let ((fast-inline #t))
(let ((fast-inline #t)
(cannot-inline #f))
;; faster and safer but (at least for now) misses some
;; opportunities for optimization because it takes a global
;; approach rather than considering the specific variables
@ -695,18 +696,23 @@
(for-each
(lambda (v)
(with-var v (lambda (var)
(if (adbv:mutated-indirectly? var)
(set! cannot-inline #t))
(if (not (adbv:inlinable var))
(set! fast-inline #f)))))
ivars)
(if fast-inline
;; Fast path, no need for more analysis
fast-inline
;; Fast path failed, see if we can inline anyway
(call/cc
(lambda (return)
;(trace:error `(inline-ok? ,exp ,ivars ,args))
(inline-ok? exp ivars args (list #f) return)
(return #t))))))
(cond
(cannot-inline #f)
(else
(if fast-inline
;; Fast path, no need for more analysis
fast-inline
;; Fast path failed, see if we can inline anyway
(call/cc
(lambda (return)
;(trace:error `(inline-ok? ,exp ,ivars ,args))
(inline-ok? exp ivars args (list #f) return)
(return #t))))))))
;; Make sure inlining a primitive call will not cause out-of-order execution
;; exp - expression to search