[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/9] Add arity-adapting module
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH 6/9] Add arity-adapting module |
Date: |
Thu, 29 Aug 2013 23:08:11 +0200 |
User-agent: |
Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) |
Andy Wingo <address@hidden> skribis:
> +;;; Commentary:
> +;;;
> +;;; A pass to adapt expressions to the arities of their continuations,
> +;;; and to rewrite some tail expressions as primcalls to "return".
> +;;;
> +;;; Code:
[...]
> + (define (adapt-exp nvals k exp)
> + (match nvals
> + (0
> + (rewrite-cps-term (lookup-cont k conts)
> + (($ $ktail)
> + ,(let-gensyms (kvoid kunspec unspec)
> + (build-cps-term
> + ($letk* ((kunspec #f ($kargs (unspec) (unspec)
> + ($continue k
> + ($primcall 'return (unspec)))))
> + (kvoid #f ($kargs () ()
> + ($continue kunspec ($void)))))
> + ($continue kvoid ,exp)))))
[...]
> + (let ((drop-result
> + (lambda (kseq)
> + (let-gensyms (k* drop)
> + (build-cps-term
> + ($letk ((k* #f ($kargs ('drop) (drop)
> + ($continue kseq ($values ())))))
> + ($continue k* ,exp)))))))
Are ($void) and ($values ()) both equivalent to *unspecified*?
> + (rewrite-cps-term (lookup-cont k conts)
> + (($ $ktail)
> + ,(rewrite-cps-term exp
> + (($var sym)
> + ($continue ktail ($primcall 'return (sym))))
> + (_
> + ,(let-gensyms (k* v)
> + (build-cps-term
> + ($letk ((k* #f ($kargs (v) (v)
> + ($continue k
> + ($primcall 'return (v))))))
> + ($continue k* ,exp)))))))
> + (($ $ktrunc ($ $arity () () #f () #f) kseq)
> + ,(drop-result kseq))
> + (($ $kargs () () _)
> + ,(drop-result k))
> + (_
> + ($continue k ,exp)))))))
Perhaps that happens in the Tree-IL->CPS pass, but is there/could there
be an effect analysis when truncating multiple-value returns?
Such that (f (values 1 2 3)) reduces to (f 1).
Ludo’.
- CPS language and Tree-IL->CPS->RTL compiler, Andy Wingo, 2013/08/29
- [PATCH 1/9] Add CPS language, Andy Wingo, 2013/08/29
- [PATCH 2/9] (compile foo #:to 'cps), Andy Wingo, 2013/08/29
- [PATCH 4/9] RTL language, Andy Wingo, 2013/08/29
- [PATCH 5/9] Add CPS primitives info module, Andy Wingo, 2013/08/29
- [PATCH 6/9] Add arity-adapting module, Andy Wingo, 2013/08/29
- Re: [PATCH 6/9] Add arity-adapting module,
Ludovic Courtès <=
- [PATCH 3/9] Add closure conversion, Andy Wingo, 2013/08/29
- [PATCH 7/9] Add pass to reify primcalls without corresponding VM ops, Andy Wingo, 2013/08/29
- [PATCH 8/9] Add CPS -> RTL compiler, Andy Wingo, 2013/08/29
- [PATCH 9/9] Add contification pass, Andy Wingo, 2013/08/29
- Re: CPS language and Tree-IL->CPS->RTL compiler, Ludovic Courtès, 2013/08/29
- Re: CPS language and Tree-IL->CPS->RTL compiler, Noah Lavine, 2013/08/29