Re: Exception Handling...
From: Rob Kennedy (me3_at_privacy.net)
Date: 06/29/04
- Next message: Rob Kennedy: "Re: Exception Handling..."
- Previous message: Rob Kennedy: "Re: Form resizing problem"
- In reply to: Maarten Wiltink: "Re: Exception Handling..."
- Next in thread: David Reeve: "Re: Exception Handling..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Jun 2004 10:58:03 -0500
Maarten Wiltink wrote:
> I had actually expected the two cases to look more like each other.
> It occurred to me a couple of days ago that try-except and try-finally
> need not be implemented very differently. Both need to jump to a
> section of code that executes, perhaps checking if it should, then
> either cleans up the exception status or doesn't, and continues.
They're really more similar than the code lets on. The try-except code
generates a jump to HandleAnyException or HandleOnException. The
try-finally code generates a jump to HandleFinally. Those three routines
all do very similar things.
The major difference (at least in the compiler-generated code) is in
where the "try" statement tells the OS to jump to in the event of an
exception. Try-except jumps to the top of the "except" block;
try-finally jumps to the bottom of the "finally" block (both
destinations correspond to the location of the jump to HandleXXXX). The
"up-side down" try-finally handling, presumably, is to allow normal,
non-exception, execution to proceed as smoothly as possible.
The problem, for someone looking to rewrite Delphi's exception-handling
routines, is not so much in understanding the compiler-generated code
but in understanding what's going on inside System.pas and SysUtils.pas.
Two things making it difficult to read are that it's in assembler and
that there are several places that use JMP to go to another subroutine
instead of using CALL -- it's like following goto-laden code.
> Perhaps it's a little too idealistic for real compiler writers. I know
> that it always bugged me that only one of two different things may
> happen after a try statement.
Well, how many other things did you want?
-- Rob
- Next message: Rob Kennedy: "Re: Exception Handling..."
- Previous message: Rob Kennedy: "Re: Form resizing problem"
- In reply to: Maarten Wiltink: "Re: Exception Handling..."
- Next in thread: David Reeve: "Re: Exception Handling..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|