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

Bug #504575 reported by Nathan Froyd
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Wishlist
Unassigned

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.

Tags: optimization
Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

In 1.0.48.25.

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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.