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". :-)

More seriously, this is the opposite extreme, and IMO it's also not
a good idea.

OO code is full of subs which a) are called very often and b) look
like this:

        sub code
        {
          my $self = shift;
          return $self->{CODE};
        }

        sub body
        {
          my $self = shift;
          if (@_) {
            $self->{BODY} = shift;
          }

          return $self->{BODY};
        }

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.  Now admittedly we have a single op for this, so at least in the
interpreter it may not cost as much as a whole bunch of individual
register saves.  For other targets (JIT), unnecessary caller saves will
almost certainly cause a measurable performance hit on OO-like code.

Cheers,
Andrew Bromage

Reply via email to