From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!seismo!rochester!pt.cs.cmu.edu!sei.cmu.edu!firth From: firth@sei.cmu.edu.UUCP Newsgroups: comp.lang.ada Subject: Re: Ada Generic Overhead Inquiry Message-ID: <906@aw.sei.cmu.edu.sei.cmu.edu> Date: Thu, 9-Apr-87 08:59:31 EST Article-I.D.: aw.906 Posted: Thu Apr 9 08:59:31 1987 Date-Received: Sat, 18-Apr-87 02:35:33 EST References: <8704090138.AA12598@ucbvax.Berkeley.EDU> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (PUT YOUR NAME HERE) Distribution: world Organization: Carnegie-Mellon University, SEI, Pgh, Pa List-Id: In article <8704090138.AA12598@ucbvax.Berkeley.EDU> "Paul Byrley" 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.