cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit e7712410207e4c6249460af161a66334b908c8fd
Author: Ian Price <[email protected]>
AuthorDate: Fri Jun 16 17:42:49 2017 +0100
JS-IL inliner has different count-calls for different clauses
* module/language/js-il/inlining.scm(inline-single-calls): Factor into
another function inline-clause, so that count-calls is only called on
the clause.
---
module/language/js-il/inlining.scm | 43 +++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/module/language/js-il/inlining.scm
b/module/language/js-il/inlining.scm
index 7d30dbe..1d31820 100644
--- a/module/language/js-il/inlining.scm
+++ b/module/language/js-il/inlining.scm
@@ -1,3 +1,9 @@
+;; FIXME: It is currently wrong to think of inlining as an optimisation
+;; since in the cps-soup world we need inlining to rebuild the scope
+;; tree for variables.
+;; FIXME: since *all* conts are passed to each clause, there can be
+;; "dead" conts thare are included in a clause
+
(define-module (language js-il inlining)
#:use-module ((srfi srfi-1) #:select (partition))
#:use-module (ice-9 match)
@@ -94,7 +100,26 @@
(lambda (prim)
(hashv-ref h prim))))
+
(define (inline-single-calls exp)
+ (define (handle-function fun)
+ (match fun
+ (($ function self tail ((ids params bodies) ...))
+ (make-function self
+ tail
+ (map (lambda (id param body)
+ (list id param (inline-clause body)))
+ ids
+ params
+ bodies)))))
+ (match exp
+ (($ program ((ids . funs) ...))
+ (make-program (map (lambda (id fun)
+ (cons id (handle-function fun)))
+ ids
+ funs)))))
+
+(define (inline-clause exp)
(define calls (count-calls exp))
@@ -179,20 +204,4 @@
(exp exp)))
- (define (handle-function fun)
- (match fun
- (($ function self tail ((ids params bodies) ...))
- (make-function self
- tail
- (map (lambda (id param body)
- (list id param (inline body '())))
- ids
- params
- bodies)))))
-
- (match exp
- (($ program ((ids . funs) ...))
- (make-program (map (lambda (id fun)
- (cons id (handle-function fun)))
- ids
- funs)))))
+ (inline exp '()))