[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 12/16: CPS conversion avoids residualizing unknown primc
From: |
Andy Wingo |
Subject: |
[Guile-commits] 12/16: CPS conversion avoids residualizing unknown primcalls |
Date: |
Wed, 27 Dec 2017 10:02:48 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit c9efff30de4cf3faf1124e5e3b79d17f961f59e9
Author: Andy Wingo <address@hidden>
Date: Wed Dec 27 11:06:25 2017 +0100
CPS conversion avoids residualizing unknown primcalls
* module/language/tree-il/compile-cps.scm: Avoid residualizing "apply"
or "abort-to-prompt" primcalls; instead, these are just calls to
$prim.
---
module/language/tree-il/compile-cps.scm | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/module/language/tree-il/compile-cps.scm
b/module/language/tree-il/compile-cps.scm
index 843c9e3..e690a40 100644
--- a/module/language/tree-il/compile-cps.scm
+++ b/module/language/tree-il/compile-cps.scm
@@ -864,13 +864,15 @@
(build-term ($continue kbody (tree-il-src body)
($prompt #f tag khargs))))))))
(with-cps cps
- (letv prim vals)
+ (letv prim vals apply)
(let$ hbody (convert hbody k subst))
(let$ hbody (box-bound-vars hnames hsyms hbody))
(letk khbody ($kargs hnames bound-vars ,hbody))
(letk khargs ($kreceive hreq hrest khbody))
+ (letk kapp ($kargs ('apply) (apply)
+ ($continue k src ($call apply (prim vals)))))
(letk kprim ($kargs ('prim) (prim)
- ($continue k src ($primcall 'apply #f (prim
vals)))))
+ ($continue kapp src ($prim 'apply))))
(letk kret ($kargs () ()
($continue kprim src ($prim 'values))))
(letk kpop ($kargs ('rest) (vals)
@@ -883,17 +885,24 @@
(convert-args cps (cons tag args)
(lambda (cps args*)
(with-cps cps
+ (letv abort)
+ (letk kabort ($kargs ('abort) (abort)
+ ($continue k src ($call abort args*))))
(build-term
- ($continue k src ($primcall 'abort-to-prompt #f args*)))))))
+ ($continue kabort src ($prim 'abort-to-prompt)))))))
(($ <abort> src tag args tail)
(convert-args cps
- (append (list (make-primitive-ref #f 'abort-to-prompt) tag)
+ (append (list (make-primitive-ref #f 'apply)
+ (make-primitive-ref #f 'abort-to-prompt)
+ tag)
args
(list tail))
(lambda (cps args*)
- (with-cps cps
- (build-term ($continue k src ($primcall 'apply #f args*)))))))
+ (match args*
+ ((apply . apply-args)
+ (with-cps cps
+ (build-term ($continue k src ($call apply apply-args)))))))))
(($ <conditional> src test consequent alternate)
(define (convert-test cps test kt kf)
- [Guile-commits] branch master updated (da7144d -> 108ade6), Andy Wingo, 2017/12/27
- [Guile-commits] 01/16: Fix stack effect/clobber parsing for calls, Andy Wingo, 2017/12/27
- [Guile-commits] 04/16: Reify-primitives removes "/unlikely" ephemeral instructions, Andy Wingo, 2017/12/27
- [Guile-commits] 07/16: Refactor list->seq to make return arity apparent, Andy Wingo, 2017/12/27
- [Guile-commits] 05/16: Remove compile-bytecode cases for ephemeral primitives, Andy Wingo, 2017/12/27
- [Guile-commits] 12/16: CPS conversion avoids residualizing unknown primcalls,
Andy Wingo <=
- [Guile-commits] 06/16: Refactor reify-primitives pass, Andy Wingo, 2017/12/27
- [Guile-commits] 08/16: Flesh out compile-bytecode for all heap objects, Andy Wingo, 2017/12/27
- [Guile-commits] 15/16: Unknown primcalls convert as calls, Andy Wingo, 2017/12/27
- [Guile-commits] 13/16: Contification also inlines "elide-values" pass, Andy Wingo, 2017/12/27
- [Guile-commits] 10/16: CPS conversion expands "list", Andy Wingo, 2017/12/27
- [Guile-commits] 11/16: Inline "elide-values" optimization into CPS conversion, Andy Wingo, 2017/12/27
- [Guile-commits] 09/16: Refactor lowering of Tree-IL primcalls to CPS, Andy Wingo, 2017/12/27
- [Guile-commits] 16/16: Re-add support for logbit?, Andy Wingo, 2017/12/27
- [Guile-commits] 03/16: Refactor boxing/unboxing primcall args/results, Andy Wingo, 2017/12/27
- [Guile-commits] 02/16: Fix mismatch between CPS and Scheme "complex?" predicate, Andy Wingo, 2017/12/27