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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cf34599caf2fa938 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: GNAT function calling overhead Date: 1995/04/07 Message-ID: #1/1 X-Deja-AN: 100070373 references: <3m0nv1$pv2@nef.ens.fr> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1995-04-07T00:00:00+00:00 List-Id: Two issues here: first, in your example, you return unconstrained arrays. This always involves a fair amount of overhead. Some compilers will use the heap for this (GNAT used to, and I think Alsys still does in some of their compilers), and do two copies. Some other compilers will do two copies, using a secondary stack (that's what GNAT does now). Some compilers will use specialized calling sequences, and manage to do only one copy in some cases, but still two copies in many cases. Anyway, there will be at least one extra copy, so that probably accounts for the overhead of the call that you see. If you are concerned with maximum efficiency, try to avoid returning uncosntrained arrays (note that this facility does not exist at all in Fortran, C or C++). Second, the comparisons between GNAT and C are odd. Normally when you write equivalent code in Ada and C and compile both with GCC you will get identical object code. In almost all cases that we have examined, it turns out that such discrepancies are caused by using high level features in Ada that have no analog in C, thus rendering it an apples-vs-oranges comparison. Anyway, I can't comment further without details. Send me the sources at dewar@cs.nyu.edu, and I will analyze what is going on,a nd post a followup when I figure it out.