call-with-values can make fewer closures
authorAndy Wingo <wingo@pobox.com>
Sun, 7 Jun 2009 22:38:49 +0000 (00:38 +0200)
committerAndy Wingo <wingo@pobox.com>
Sun, 7 Jun 2009 22:38:49 +0000 (00:38 +0200)
commitf4aa8d53a07168d15f737164c37da02056948d2b
tree58d669f0cff1288342fef454fdf12d69c8077368
parentc0ee32452f4babfc99526ed35d1f80d128d8658b
call-with-values can make fewer closures

* module/language/tree-il.scm: Rename let-exp and letrec-exp to let-body
  and letrec-body. Add <let-values>, a one-expression let-values that
  should avoid the needless creation of two closures in many common
  multiple-value cases. We'll need to add an optimization pass to the
  compiler to produce this form, though, as well as rewriting lambdas
  into lets, etc.

  I added this form instead of adding more special cases to the
  call-with-values compile code because it's a useful intermediate form
  -- it will allow the optimizer to perform constant folding across more
  code.

* module/language/tree-il.scm (parse-tree-il, unparse-tree-il)
  (tree-il->scheme, post-order!, pre-order!): Adapt to let/letrec body
  renaming, and let-values.

* module/language/tree-il/analyze.scm (analyze-lexicals): Adapt for
  renaming, and add cases for let-values.

* module/language/tree-il/compile-glil.scm (flatten): Add a new context,
  `vals', used by let-values code for the values producer. Code that
  produces multiple values can then jump to the let-values MV return
  address directly, instead of trampolining into a procedure. Add code to
  compile let-values.
module/language/tree-il.scm
module/language/tree-il/analyze.scm
module/language/tree-il/compile-glil.scm