avoid consing &REST args when they just get passed to APPLY

Bug #504575 reported by Nathan Froyd on 2010-01-08
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

I remember reading about this optimization in a post on c.l.l by Duane Rettig, though I cannot find it now. What the optimization does is recognize the idiom:

(defun func (a b &rest args)
  ... ; doesn't use ARGS
  (apply newfunc a b c args))

and avoids consing a list for ARGS, either on the heap or the stack. Instead, you shuffle ARGS around on the stack to ensure it's in the proper place for the call to NEWFUNC.

I think this would be reasonably straightforward as an IR2 optimization (recognize presence of %LISTIFY-REST-ARGS, verify that its argument is not used except as arg to VALUES-LIST, etc.), though there might be some trickiness doing the argument shuffling properly and efficiently.

Nikodemus Siivola (nikodemus) wrote :


Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers