[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 03/09: Allow unchecked functions to have unboxed argumen
From: |
Andy Wingo |
Subject: |
[Guile-commits] 03/09: Allow unchecked functions to have unboxed arguments |
Date: |
Thu, 17 Jun 2021 15:59:03 -0400 (EDT) |
wingo pushed a commit to branch wip-tailify
in repository guile.
commit 54c52e81c9e41077ab8228219bb7343dc91b79fc
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Thu Jun 3 21:35:20 2021 +0200
Allow unchecked functions to have unboxed arguments
* module/language/cps/utils.scm (compute-var-representations): Use
'arg-representations from metadata for arg representations.
* module/language/tree-il/compile-cps.scm (sanitize-meta):
(convert): Make sure incoming terms have no arg representations.
---
module/language/cps/utils.scm | 13 ++++++++-----
module/language/tree-il/compile-cps.scm | 11 ++++++++++-
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/module/language/cps/utils.scm b/module/language/cps/utils.scm
index 8f36e4d..2b0c91c 100644
--- a/module/language/cps/utils.scm
+++ b/module/language/cps/utils.scm
@@ -429,12 +429,15 @@ by a label, respectively."
(($ $kargs _ _ (or ($ $branch) ($ $switch) ($ $prompt) ($ $throw)))
representations)
(($ $kfun src meta self tail entry)
- (let ((representations (if self
+ (let* ((representations (if self
(intmap-add representations self 'scm)
- representations)))
- (fold1 (lambda (var representations)
- (intmap-add representations var 'scm))
- (get-defs entry) representations)))
+ representations))
+ (defs (get-defs entry))
+ (reprs (or (assq-ref meta 'arg-representations)
+ (map (lambda (_) 'scm) defs))))
+ (fold (lambda (var repr representations)
+ (intmap-add representations var repr))
+ representations defs reprs)))
(($ $kclause arity body alt)
(fold1 (lambda (var representations)
(intmap-add representations var 'scm))
diff --git a/module/language/tree-il/compile-cps.scm
b/module/language/tree-il/compile-cps.scm
index ffc8308..918e904 100644
--- a/module/language/tree-il/compile-cps.scm
+++ b/module/language/tree-il/compile-cps.scm
@@ -1581,6 +1581,15 @@ use as the proc slot."
(letk ktail ($kargs ('tail) (tail) ,head))
($ (build-list ktail src vals))))))
+(define (sanitize-meta meta)
+ (match meta
+ (() '())
+ (((k . v) . meta)
+ (let ((meta (sanitize-meta meta)))
+ (case k
+ ((arg-representations) meta)
+ (else (acons k v meta)))))))
+
;;; The conversion from Tree-IL to CPS essentially wraps every
;;; expression in a $kreceive, which models the Tree-IL semantics that
;;; extra values are simply truncated. In CPS, this means that the
@@ -1865,7 +1874,7 @@ use as the proc slot."
(letv self)
(letk ktail ($ktail))
(let$ kclause (convert-clauses body ktail))
- (letk kfun ($kfun fun-src meta self ktail kclause))
+ (letk kfun ($kfun fun-src (sanitize-meta meta) self ktail
kclause))
(let$ k (adapt-arity k fun-src 1))
(build-term ($continue k fun-src ($fun kfun))))
(let ((scope-id (fresh-scope-id)))
- [Guile-commits] branch wip-tailify updated (5bb0ffb -> d4bec05), Andy Wingo, 2021/06/17
- [Guile-commits] 02/09: Move live variable computation routines to utils and graphs., Andy Wingo, 2021/06/17
- [Guile-commits] 04/09: Add indirect-tail-call VM instruction, Andy Wingo, 2021/06/17
- [Guile-commits] 03/09: Allow unchecked functions to have unboxed arguments,
Andy Wingo <=
- [Guile-commits] 01/09: Add frame-local-ref / frame-local-set! support for type 'ptr, Andy Wingo, 2021/06/17
- [Guile-commits] 05/09: Add new $calli expression type., Andy Wingo, 2021/06/17
- [Guile-commits] 08/09: Hotfix to unify (x ...) patterns in match, Andy Wingo, 2021/06/17
- [Guile-commits] 09/09: Add ,optimize-cps REPL meta-command, Andy Wingo, 2021/06/17
- [Guile-commits] 06/09: Add tailify pass, Andy Wingo, 2021/06/17
- [Guile-commits] 07/09: Add CPS pretty-printer, Andy Wingo, 2021/06/17