Emit more efficient calls for compiled continuations

This commit is contained in:
Justin Ethier 2021-05-31 16:18:44 -04:00
parent cc7a2a5027
commit 881ce5fb7f

View file

@ -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