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