comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <dewar@gnat.com>
Subject: Re: Why parameter passing by copy?
Date: 2000/05/27
Date: 2000-05-27T00:00:00+00:00	[thread overview]
Message-ID: <8gp70n$c6k$1@nnrp1.deja.com> (raw)
In-Reply-To: dale-277623.23001027052000@news.rmit.edu.au

In article <dale-277623.23001027052000@news.rmit.edu.au>,
  Dale Stanbrough <dale@cs.rmit.edu.au> wrote:
> Ada requires that scalars be passed by copy. I was under the
impression
> that this was chosen because it was faster, but i've never
seen a
> rational argument for this from the Ada83 perspective of
computer
> hardware, nor whether such arguments still hold true for
modern
> processors.


It needs very little "rational argument". Fortran compilers
have known for a long time that it is more efficient on all
common architectures to pass things by copy, and that is
why Fortran allows it. Ada insisted because we decided it
was not worth having implementation dependence at this point,
since it is so clear that call by copy is more efficient.

In a modern compiler you like to keep everything in registers
where possible, so forcing call by reference would force
things into memory, never mind the unnecessary overhead of
the indirect reference. Parameters are typically passed in
registers, so if you do things right, everything is in
registers where needed, or at worst a register-register move
is needed and memory references are avoided. The desire to
avoid memory references becomes more and more important, so
the decision to pass scalars by copy makes even MORE sense
these days!

The evil efficiency effects of call by reference for small
items can be seen clearly in the awful SPARC ABI, where
small records are required to be passed by reference. We
see a significant performance degradation from this requirement,
so much so that it is tempting to just ignore the ABI here.

Robert Dewar
Ada Core Technologies


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-05-27  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-27  0:00 Why parameter passing by copy? Dale Stanbrough
2000-05-27  0:00 ` Robert Dewar [this message]
2000-05-27  0:00 ` Pat Rogers
2000-05-28  0:00   ` Robert Dewar
2000-05-27  0:00 ` Thierry Lelegard
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox