From eb2ab6b74a03e7a250fd7572693254f703c4f6c7 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 22 Oct 2018 13:35:04 -0400 Subject: [PATCH] Added (self-closure-call? ast self) --- scheme/cyclone/cps-optimizations.sld | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scheme/cyclone/cps-optimizations.sld b/scheme/cyclone/cps-optimizations.sld index 9214f1b1..d307a0ef 100644 --- a/scheme/cyclone/cps-optimizations.sld +++ b/scheme/cyclone/cps-optimizations.sld @@ -90,6 +90,8 @@ adbf:calls-self? adbf:set-calls-self! with-fnc with-fnc! + ;; Helpers + self-closure-call? ) (begin ;; The following two defines allow non-CPS functions to still be considered @@ -1782,6 +1784,20 @@ (list (convert exp #f '())) #f)) +;; Detect closure call of the form: +;; (%closure-ref +;; (cell-get (%closure-ref self$249 1)) +;; 0) +(define (self-closure-call? ast self) + (and-let* (((tagged-list? '%closure-ref ast)) + ((tagged-list? 'cell-get (cadr ast))) + (inner-cref (cadadr ast)) + ((tagged-list? '%closure-ref inner-cref)) + (equal? self (cadr inner-cref)) + ((equal? 0 (caddr ast))) + ) + #t)) + (define (analyze:find-named-lets exp) (define (scan exp lp) (cond