[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 05/08: Letrectify links module defs with uses
From: |
Andy Wingo |
Subject: |
[Guile-commits] 05/08: Letrectify links module defs with uses |
Date: |
Mon, 26 Apr 2021 11:04:11 -0400 (EDT) |
wingo pushed a commit to branch wip-inlinable-exports
in repository guile.
commit 15024d59b8971ddb6997ba5de8ccb16b6c722664
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Fri Apr 2 10:07:07 2021 +0200
Letrectify links module defs with uses
* module/language/tree-il/letrectify.scm (letrectify): Inline "let"
bindings inside residualized "letrec*" forms, to allow the dominator
relationship to be reflected in the scope tree. Also, detect
"define-module*" invocations, and add these to the mod-vars set, so that
residualized "module-ensure-local-variable!" primcalls can clearly
denote their module without having to use "current-module".
---
module/language/tree-il/letrectify.scm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/module/language/tree-il/letrectify.scm
b/module/language/tree-il/letrectify.scm
index c27e75e..60d057f 100644
--- a/module/language/tree-il/letrectify.scm
+++ b/module/language/tree-il/letrectify.scm
@@ -1,6 +1,6 @@
;;; transformation of top-level bindings into letrec*
-;; Copyright (C) 2019-2020 Free Software Foundation, Inc.
+;; Copyright (C) 2019-2021 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -252,6 +252,24 @@
(add-statement src init (make-void src))))
mod-vars)))))))
+ (($ <let> src names vars vals body)
+ (let lp ((names names) (vars vars) (vals vals) (mod-vars mod-vars))
+ (match (vector names vars vals)
+ (#(() () ())
+ (values (visit-expr body) mod-vars))
+ (#((name . names) (var . vars) (val . vals))
+ (let* ((val (visit-expr val))
+ (mod-vars
+ (match val
+ (($ <call> _
+ ($ <module-ref> _ '(guile) 'define-module* #f)
+ (($ <const> _ mod) . args))
+ (acons mod var mod-vars))
+ (_ mod-vars))))
+ (let-values (((exp mod-vars) (lp names vars vals mod-vars)))
+ (values (add-binding name var val exp)
+ mod-vars)))))))
+
(($ <seq> src head tail)
(let*-values (((head mod-vars) (visit-top-level head mod-vars))
((tail mod-vars) (visit-top-level tail mod-vars)))
- [Guile-commits] branch wip-inlinable-exports updated (163e1f5 -> b07b2b7), Andy Wingo, 2021/04/26
- [Guile-commits] 02/08: Fix CPS optimizations to allow callk in front half, Andy Wingo, 2021/04/26
- [Guile-commits] 04/08: Allow contification for $callk, Andy Wingo, 2021/04/26
- [Guile-commits] 07/08: Add support for recording inlinable module exports, Andy Wingo, 2021/04/26
- [Guile-commits] 05/08: Letrectify links module defs with uses,
Andy Wingo <=
- [Guile-commits] 06/08: Add pass to resolve free toplevel references in declarative modules, Andy Wingo, 2021/04/26
- [Guile-commits] 08/08: Implement cross-module inlining, Andy Wingo, 2021/04/26
- [Guile-commits] 01/08: Fix error when argument to < not a real, Andy Wingo, 2021/04/26
- [Guile-commits] 03/08: CPS conversion calls module variables through trampolines, Andy Wingo, 2021/04/26