chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] inline calls to variables bound to extended bi


From: Felix
Subject: [Chicken-hackers] [PATCH] inline calls to variables bound to extended binding
Date: Mon, 23 Jan 2012 06:07:36 +0100 (CET)

Hello!

The attached patch add a special case of inlining by transforming
calls like "(<variable> ...)" to "(<standard-or-extended binding>
...)", where <variable> is known to refer to some of the builtin
procedures known as "standard/extended bindings" (listed in the FAQ).
Previously only direct calls to such bindings where specifically
handled).


cheers,
felix
>From c23f0cb70db2ff6b050824a62b4140580f048386 Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Fri, 30 Dec 2011 12:40:12 +0100
Subject: [PATCH] inline calls to variables known to be bound to intrinsic

---
 optimizer.scm |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/optimizer.scm b/optimizer.scm
index 3d917ff..72fbb20 100644
--- a/optimizer.scm
+++ b/optimizer.scm
@@ -304,6 +304,7 @@
                                      (test var 'local-value)))]
                       [args (cdr subs)] )
                  (cond ((test var 'contractable)
+                        ;; only called once
                         (let* ([lparams (node-parameters lval)]
                                [llist (third lparams)] )
                           (check-signature var args llist)
@@ -316,6 +317,7 @@
                             void)
                            fids gae) ) )
                        ((variable-mark var '##compiler#pure)
+                        ;; callee is side-effect free
                         (or (and-let* ((k (car args))
                                        ((eq? '##core#variable (node-class k)))
                                        (kvar (first (node-parameters k)))
@@ -339,6 +341,7 @@
                             (walk-generic n class params subs fids gae #f)) )
                        ((and lval
                              (eq? '##core#lambda (node-class lval)))
+                        ;; callee is a lambda
                         (let* ([lparams (node-parameters lval)]
                                [llist (third lparams)] )
                           (decompose-lambda-list
@@ -433,6 +436,18 @@
                                                   (invalidate-gae! gae)
                                                   n2) ) ) ) ) )
                                      (else (walk-generic n class params subs 
fids gae #t)) ) ) ) ) ) )
+                       ((and lval
+                             (eq? '##core#variable (node-class lval))
+                             (intrinsic? (first (node-parameters lval))))
+                        ;; callee is intrinsic
+                        (debugging 'i "inlining call to intrinsic alias" 
+                                   var (first (node-parameters lval)))
+                        (walk
+                         (make-node
+                          '##core#call
+                          params
+                          (cons lval (cdr subs)))
+                         fids gae))
                        (else (walk-generic n class params subs fids gae #t)) ) 
) ]
               [(##core#lambda)
                (if (first params)
-- 
1.6.0.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]