From 93f87ac4c38188a3ac6c6e2d6f3bac74a2680d56 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 4 May 2017 08:22:01 +0000 Subject: [PATCH] Allow inlines if a var is passed to a continuation --- scheme/cyclone/cps-optimizations.sld | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scheme/cyclone/cps-optimizations.sld b/scheme/cyclone/cps-optimizations.sld index dbd2d8c0..8c9fb409 100644 --- a/scheme/cyclone/cps-optimizations.sld +++ b/scheme/cyclone/cps-optimizations.sld @@ -1081,6 +1081,7 @@ ((and (not (prim? (car exp))) (ref? (car exp))) (define pure-fnc #f) + (define calling-cont #f) (define ref-formals '()) ;; Does ref refer to a pure function (no side effects)? (let ((var (adb:get/default (car exp) #f))) @@ -1096,6 +1097,10 @@ (with-fnc! (ast:lambda-id assigned-val) (lambda (fnc) (if (not (adbf:side-effects fnc)) (set! pure-fnc #t))))) + ;; Experimental - if a cont, execution will leave fnc anyway, + ;; so inlines there should be safe + ((adbv:cont? var) + (set! calling-cont #t)) )))) ;; (with-var (car exp) (lambda (var) @@ -1110,7 +1115,7 @@ )))) ;(trace:error `(DEBUG ref app ,(car exp) ,(cdr exp) ,ref-formals)) (cond - (pure-fnc + ((or pure-fnc calling-cont) (for-each (lambda (e) ;; Skip refs since fnc is pure and cannot change them