Path: utzoo!utgpu!cunews!cognos!jimp From: jimp@cognos.UUCP (Jim Patterson) Newsgroups: comp.lang.eiffel Subject: Re: Exceptions and Assertions Keywords: eiffel exceptions assertions preconditions Message-ID: <8835@cognos.UUCP> Date: 24 Sep 90 17:25:46 GMT References: <1990Sep7.032121.6456@bony1.uucp> <14831@yunexus.YorkU.CA> <731@tetrauk.UUCP> <410@eiffel.UUCP> Reply-To: jimp@cognos.UUCP (Jim Patterson) Organization: Cognos Inc., Ottawa, Canada Lines: 41 In article <410@eiffel.UUCP> kimr@eiffel.UUCP (Kim Rochat) writes: >In article <731@tetrauk.UUCP>, rick@tetrauk.UUCP (Rick Jones) writes: >> >| [paraphrased]: should Eiffel programs generally be run with pre-condition >> >| checking on? - yes! yes! yes! >> >> >> The most effective run-time (i.e. C compile-time) option would be to >> check pre-conditions, void references, "check" clauses (my preference), >> but omit history tracing. This means that spurious setjmp() calls are >> avoided, and a longjmp() in the case of an exception will go direct to >> the currently effective rescue handler. This all seems possible with a >> little re-arrangement of the _eiffel.h file; any comments from ISE, >> please? > >I'd like to thank Rick for this suggestion. We've been trying to >figure out a way to reduce the cost of assertion monitoring, but had >been assuming that a full exception history trace was a requirement. >If you are willing to do without the full history trace, this message >contains a work-around which reduces the time to execute a program >which monitors assertions by a factor of 10. There's no reason that setjmp() has to be used to implement an exception history trace. A small amount of inline setup code in each function is sufficient to provide a trace history, and gives a significant performance boost over setjmp (which is a very expensive library call as such things go). The basic technique is to allocate an Eiffel "call frame" in each function which contains the class and routine numbers and a back link to the previous function. The setup logic initializes the call frame and links it to the previous frame; exit code unlinks (pops off) the call frame. This does require changing the Eiffel compiler and runtime, however, so isn't as simple as just modifying the _eiffel.h header. -- Jim Patterson Cognos Incorporated UUCP:uunet!mitel!cunews!cognos!jimp P.O. BOX 9707 PHONE:(613)738-1440 3755 Riverside Drive Ottawa, Ont K1G 3Z4