[ I'm playing devils advocate for a while longer as I'm not 100% convinced ]

On Mon, Apr 29, 2002 at 10:53:40AM -0400, Dan Sugalski wrote:
> At 9:50 AM +1000 4/29/02, Andrew J Bromage wrote:
> >G'day all.
> >
> >On Sun, Apr 28, 2002 at 11:44:04AM -0400, Dan Sugalski wrote:
> >
> >>  We're going caller-save. I think I made this declaration before,  but
> >>  now it's backed up with pure PDD goodness. :)
> >
> >The first thing to realise is that this violates the principle of
> >"callee does everything important to it". :-)
> 
> Sure, but saving registers isn't something the callee finds 
> important. The saved registers aren't important to it.

I don't think that's a good argument. It should be a good citizen.
Not write on memory it shouldn't and not mess with a (non scratchpad)
register without saving it.


> Yup, caller save doesn't necessarily favor code like this. On the 
> other hand, it does favor recursive code

I don't think that's a good argument. Not enough recursive code to matter.

> and code with heavier-weight bodies.

.... that don't make lots of calls to leaf code (little methods etc).

As the 'weight' of the code body increases the register saving
becomes insignificant anyway - unless the code is making lots of calls.

> It's always a toss-up. Nothing's free, and all decisions have 
> consequences of some sort.

Sure.

> >Maybe half a dozen registers used in each one at the most.  A caller is
> >obliged to save _all_ its registers in order to call these trivial
> >subs.
> 
> Nope, just the registers it needs preserved across calls. It needs to 
> save the data that *is* relevant, where on callee save the data that 
> *might* be relevant needs saving.

If the caller knows what registers it's using and thus need saving,
why can't the callee also know what registers it is going to use
and thus need saving?

Isn't compiler convienience a (the?) major issue here?


> The question, of course, is whether 
> there's as much potentially relevant data as actually relevant data.
> 
> Assuming that the caller and callee spend about the same amount of 
> time saving data (An assumption that's a bit dodgy there, as it's 
> based on the coding style the language encourages) caller-save is 
> ultimately a bit less expensive, as making tail calls avoids a 
> push/pop pair, which callee-save can't avoid.

How common do you expect tail calls to be? (Got practical examples?)

Seems to me like compiler convienience and tail call efficiency
are the main issues.

Tim.

Reply via email to