From 881ce5fb7ff34f742601fcfb75a045b3172b8556 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 31 May 2021 16:18:44 -0400 Subject: [PATCH] Emit more efficient calls for compiled continuations --- scheme/cyclone/cgen.sld | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index fac30607..0aff6deb 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -1097,7 +1097,10 @@ (this-cont (c:body cfun)) (cargs (c-compile-args (cdr args) append-preamble " " this-cont ast-id trace cps?)) (raw-cargs (cdddr cargs)) ; Same as above but with lists instead of appended strings - (num-cargs (c:num-args cargs))) + (num-cargs (c:num-args cargs)) + (is-cont (and (equal? (length fun) 4) + (cadddr fun)))) +;(trace:error `(JAE DEBUG ,is-cont ,fun)) (cond ((not cps?) (c:code @@ -1214,6 +1217,18 @@ (if (> num-cargs 0) "," "") (c:body cargs) ");")))) + (is-cont ;; Compiled continuation, can make a more efficient call + (c:code + (string-append + (c:allocs->str (c:allocs cfun) "\n") + (c:allocs->str (c:allocs cargs) "\n") + "return_direct_with_clo" (number->string (c:num-args cargs)) + "(data," + this-cont + ", (((closure)" this-cont ")->fn)" + (if (> (c:num-args cargs) 0) "," "") + (c:body cargs) + ");"))) (else (c:code (string-append