comp.lang.ada
 help / color / mirror / Atom feed
From: firth@sei.cmu.edu.UUCP
Subject: Re: Ada Generic Overhead Inquiry
Date: Thu, 9-Apr-87 08:59:31 EST	[thread overview]
Date: Thu Apr  9 08:59:31 1987
Message-ID: <906@aw.sei.cmu.edu.sei.cmu.edu> (raw)
In-Reply-To: 8704090138.AA12598@ucbvax.Berkeley.EDU

In article <8704090138.AA12598@ucbvax.Berkeley.EDU> "Paul Byrley" <adaisc@ntsc-74> writes:

>     Can anybody tell me if there is any significant, run-time
>     overhead associated with the use of Ada's Generics?
> 

With the current state of Ada compiler maturity, this very
much depends on the compiler.  However, here are a few
general comments that I hope are of use - at least they
might tell you what to look for!

One way of implementing generics is by replicating the code
at each instantiation.  This has no runtime overhead, since
the effect should be just as if you had written dozens of
non-generic bodies.  It can cause enormous code expansion,
for which reason you might prefer to look for compilers
that don't do that.

Code sharing may or may not cause overhead, depending on
the generic parameter types:

(a) Pure type parameters should cause no overhead - the
    shared body is exactly what would be used for a non
    generic.  However, watch for things like

	if FORMAL_TYPE'MANTISSA < 20 then ...

    which are compile-time evaluable in the non-generic
    case but may require major overhead in a shared body.

(b) Procedure parameters require a procedure descriptor to
    be passed.  The minimum is normally 2 values - code
    address and static environment chain pointer.  If there
    are more than 3 values passed then I think you should
    worry.

(c) Value parameters appear in the code body as initialised
    constants.  You possibly lose some value-tracking
    optimisation.

(d) Subtype parameters may have to pass constraint information.
    That costs, and you also may lose some optimisations.

If you want the specific detail for the compiler of your
choice, then ask

A: under precisely what circumstances is code shared between
   instantiations?

B: when code is shared, what is the runtime representation of

    . procedures
    . values and objects
    . subtype constraints
    . type attributes

   that might have to be passed to the body

C: what specific optimisations are inhibited as a result of
   code sharing.

Hope this helps.

  reply	other threads:[~1987-04-09 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1987-04-08 18:17 Ada Generic Overhead Inquiry adaisc
1987-04-09 13:59 ` firth [this message]
  -- strict thread matches above, loose matches on Subject: below --
1987-04-08 20:21 CPT Jacques C. Choiniere
1987-04-09 11:44 ` mdash
replies disabled

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