1.0.48.25: automatic &rest to &more conversion
authorNikodemus Siivola <nikodemus@random-state.net>
Wed, 25 May 2011 23:02:28 +0000 (23:02 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Wed, 25 May 2011 23:02:28 +0000 (23:02 +0000)
commite8011f7c83587a9dc1b13281d0cc974bb0b054be
treeaa9da6b0eaa5d5a0fb5705eca60ea1dcfffec91c
parentb16362cd2ab5d268ff161a805837aa271ef2fec2
1.0.48.25: automatic &rest to &more conversion

 lp#504575

 Automatically convert

   (values-list rest-arg)
 to
   (%more-arg-values more-context 0 more-count)

 when possible, making functions such as

   (defun foo (f1 f2 &rest args)
     (apply f1 args)
     (apply f2 args))

 non-consing.

 The conversion is done iff:

   * The rest arg is never assigned to.

   * The rest arg only appears in VALUES-LIST (incl. APPLY)
     calls.

   * Those calls are all in either the same lambda that
     allocates the rest-list, or one that has been declared
     dynamic extent. (Conservative guess re. escaping.)

 The way this works is as follows:

   1. When we convert a lambda with a non-ignored &rest argument, as add
      more-context and more-count arguments to the function, and
      stick their lambda-vars into arg-info-default of the &rest arg.

   2. When we source-transform a values-list form, we check if its argument is
      a &rest argument for which context and count are available. If so, we
      source-transform into

        (%values-list-or-context list context count)

   3. When we are optimizing, a deftransform fires for the form above. It
      checks if all the necessary conditions hold and converts into either
      %more-arg-values or values-list.

 The reason for this roundabout way of doing things lies in locall analysis:
 unless the extra context and count argument are used nontrivially when it
 runs, they get deleted -- and we don't know if we want them or not until the
 entire function has been converted. Absent a convenient pass between
 conversion and locall analysis, we must therefore do things in two stages.
13 files changed:
NEWS
doc/manual/efficiency.texinfo
src/code/debug-int.lisp
src/code/debug.lisp
src/compiler/debug-dump.lisp
src/compiler/fndb.lisp
src/compiler/ir1tran-lambda.lisp
src/compiler/locall.lisp
src/compiler/node.lisp
src/compiler/srctran.lisp
tests/debug.impure.lisp
tests/dynamic-extent.impure.lisp
version.lisp-expr