guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 07/99: Simple inlining of immediate calls


From: Christopher Allan Webber
Subject: [Guile-commits] 07/99: Simple inlining of immediate calls
Date: Sun, 10 Oct 2021 21:50:42 -0400 (EDT)

cwebber pushed a commit to branch compile-to-js-merge
in repository guile.

commit 3b32d180b16c08bfd861879efbc90a7e9d323884
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Sun Jun 7 16:58:41 2015 +0100

    Simple inlining of immediate calls
---
 module/language/js-il/compile-javascript.scm |  2 ++
 module/language/js-il/direct.scm             | 36 ++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/module/language/js-il/compile-javascript.scm 
b/module/language/js-il/compile-javascript.scm
index fb5ed5e..a0427cc 100644
--- a/module/language/js-il/compile-javascript.scm
+++ b/module/language/js-il/compile-javascript.scm
@@ -2,9 +2,11 @@
   #:use-module (ice-9 match)
   #:use-module ((language js-il) #:renamer (symbol-prefix-proc 'il:))
   #:use-module (language javascript)
+  #:use-module (language js-il direct)
   #:export (compile-javascript))
 
 (define (compile-javascript exp env opts)
+  (set! exp (remove-immediate-calls exp))
   (values (compile-exp exp) env env))
 
 (define *scheme* (make-id "scheme"))
diff --git a/module/language/js-il/direct.scm b/module/language/js-il/direct.scm
new file mode 100644
index 0000000..6e97e3e
--- /dev/null
+++ b/module/language/js-il/direct.scm
@@ -0,0 +1,36 @@
+(define-module (language js-il direct)
+  #:use-module (ice-9 match)
+  #:use-module (language js-il)
+  #:export (remove-immediate-calls))
+
+(define (remove-immediate-calls exp)
+  (match exp
+    (($ program entry body)
+     (make-program (remove-immediate-calls entry)
+                   (map remove-immediate-calls body)))
+
+    (($ continuation params body)
+     (make-continuation params (remove-immediate-calls body)))
+
+    (($ function name params body)
+     (make-function name params (remove-immediate-calls body)))
+
+    (($ local
+        (($ var id ($ continuation () body)))
+        ($ continue id ()))
+     (remove-immediate-calls body))
+
+    (($ local
+        (($ var id ($ continuation (arg) body)))
+        ($ continue id (val)))
+     (make-local (list (make-var arg val))
+                 (remove-immediate-calls body)))
+
+    (($ local bindings body)
+     (make-local (map remove-immediate-calls bindings)
+                 (remove-immediate-calls body)))
+
+    (($ var id exp)
+     (make-var id (remove-immediate-calls exp)))
+
+    (exp exp)))



reply via email to

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