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,63ceef1cf4561e32 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Customer balks at Ada -- any hope?--Warning Significant Thread Drift Ahead Date: 2000/07/28 Message-ID: <3980FF12.98A990A6@earthlink.net>#1/1 X-Deja-AN: 651670620 Content-Transfer-Encoding: 7bit References: <8l01s4$gnr$1@nnrp1.deja.com> <8l2pqo$im7$1@nnrp1.deja.com> <5dtGPVPqfHh5@eisner.decus.org> <39755FB0.81586D45@baesystems.com> <8l5lhf$nem$1@pyrite.mv.net> <3976C1D0.5A3CECEB@baesystems.com> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 964755195 63.24.60.185 (Thu, 27 Jul 2000 20:33:15 PDT) Organization: The MITRE Corporation MIME-Version: 1.0 NNTP-Posting-Date: Thu, 27 Jul 2000 20:33:15 PDT Newsgroups: comp.lang.ada Date: 2000-07-28T00:00:00+00:00 List-Id: Kieran Mckey wrote: > Ok, a quick reword gives : > > run-time checks are required for Ada exception handling, excluding > explicitly raised exceptions. Not right yet. You really have to read and understand RM 11.6, Exceptions and Optimization, to have some clue as to what is required. (And probably read Ada 83 AI-315 or have Brother Dewar or Brother Hilfinger preach on reasoning from erroneousness.) But the reality can best be summed up in three principles: Ada checks are really on stored VALUES (or on subtype conversions) not on operations. Ada compilers can and do STATICALLY eliminate most required checks. If your program runs efficiently with checks enabled, it will probably run slower if you disable them. (Translation, only turn off checks where you know the compiler is generating "junk" checking code for some particular computation. And it is often much better to "turn checking off" by doing a complex computation in type'Base, then converting the result.) And yes, I have seen code run slower when compiled with checks disabled. (Note that earlier version of GNAT did have significant overhead for integer constraint checks, so by default they were turned off. They are still disabled by default for compatibility reasons, but the code generated now is much more efficient than before.) Of course, in any discussion of supressing checks it is assumed that the exception cannot or will not occur. If a check for a particular exception is suppressed and an exception occurs that results in externally visible effects, then program speed is irrelevant. I have used the compiler to validate my understanding of a section of code by compiling with checks on and then checking the generated code to see if it contains a call to raise an exception. (This only works if the hardware sets condition codes which have to be checked. If the hardware traps on overflow, or if there are calls to run-time routines which actually do the test, the method doesn't work.) But on most modern hardware, look at the generated code. Then make minor changes to see how the checking code is affected. Often moving a bound from a parameter to a variable or vice-versa, or even putting it in both places, will have a significant effect on compiler overhead.