From: | dvdeug@x8b4e53cd.dhcp.okstate.edu (David Starner) |
Newsgroups: | comp.compilers |
Date: | 21 Apr 2000 23:02:34 -0400 |
Organization: | Oklahoma State University |
References: | 00-04-125 00-04-128 00-04-134 00-04-141 |
Keywords: | modula, errors |
On 20 Apr 2000 01:34:39 -0400,
Jonathan Barker <jandk@easynet.co.uk> wrote:
>Obviously, performance depends on how often exceptions occur. It takes
>time to unwind the stack, especially in a language like Java or
>C++. We can't simply perform a jump and set the stack pointer... Since
>the stack trace cannot possibly be known at compile-time (except in
>the simplest cases), the run-time library (or VM) must search each
>frame, executing "finally" clauses and finalising objects until it
>finds a handler for the exception.
>
>Thus, if you rely on exceptions for flow of control in a critical loop,
>it is clear that performance will suffer.
Yes. The Modula-3 people recommend to M3 implementors that exceptions can
be as slow as necessary to make the main code as fast as possible. OTOH,
doing it the C way and checking the return value of every function may
slow a critical loop down more than a rare exception would.
Basically, don't use exceptions to implement a heavily used path of control;
instead, use them for unusual ("exceptional") flow of control.
--
David Starner - dstarner98@aasaa.ofe.org
Finger dvdeug@x8b4e53cd.dhcp.okstate.edu for more information.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.