From 004fa655d5cf38cc0cdde01819a997a71a08daad Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 10 Nov 2016 20:59:38 +0000 Subject: [PATCH] Experimental inline change At least for now, use both inlinable analysis (fast path) and inline-ok (slow path, but finds more optimizations). --- scheme/cyclone/cps-optimizations.sld | 34 ++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/scheme/cyclone/cps-optimizations.sld b/scheme/cyclone/cps-optimizations.sld index 4dcc0aed..afcafcff 100644 --- a/scheme/cyclone/cps-optimizations.sld +++ b/scheme/cyclone/cps-optimizations.sld @@ -642,20 +642,26 @@ ;; Helper for the next function (define (inline-prim-call? exp ivars args) - (call/cc - (lambda (return) -;; TODO: -;; experimenting with switching inline-ok? with code using data from analysis DB - ;(trace:error `(inline-ok? ,exp ,ivars ,args)) - ;(inline-ok? exp ivars args (list #f) return) - (for-each - (lambda (v) - (with-var v (lambda (var) - (if (not (adbv:inlinable var)) - (return #f))))) - ivars) -;; End experimental code - (return #t)))) + (let ((fast-inline #t)) + ;; 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 + ;; involved for any given optimization. + (for-each + (lambda (v) + (with-var v (lambda (var) + (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)))))) ;; Make sure inlining a primitive call will not cause out-of-order execution ;; exp - expression to search