This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: One more register please
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Woops. I forgot that I'm dealing with an OO language here. There is an inplicit parameter in every call - the 'self' object!. So to shuffle everything up by one argument, we find that there is still only 0.82% of methods that will spill. If we have three free registers for arguments, then it's at 2.29%. If we have two free registers for arguments, then it's at 6.66%. It's not until we reach one free register for arguments that we start to really notice, at 22.18%.
To answer Patrick Logan's question about intermediates - there aren't that many and where they are required, assuming we don't leave any registers free from arguments in our method (ie: we're always calling methods that have 4 arguments), then we still have the continuation register that we can use effeciently, by pushing it in to the stack at the start of our method.
But given the numbers, I'd be happy to leave one register free the continuation register for intermediates - but only if the method needs it. Most methods will not be only calling methods with lots of arguments. Fascinating.
It gets better. If we have a method that requires register spills and we create an object to call with, then we can re-use the slots in that object from then on for intermediates, since those slots effectively, at that point, become fake registers (we've already spent the cost to make them, why not re-use them?). If possible, the next call may re-use that object too. In fact, I'd wager most calls modify one argument to the next call, meaning most methods would be very effecient in or not in registers.