Re: Try Finally...
From: Rob Kennedy (me3_at_privacy.net)
Date: 10/28/04
- Next message: Bruce Roberts: "Re: Record"
- Previous message: SamH: "Delphi code - Disable Windows XP Firewall."
- In reply to: VBDis: "Re: Try Finally..."
- Next in thread: Martin Harvey (Demon account): "Re: Try Finally..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 28 Oct 2004 11:44:36 -0500
VBDis wrote:
> Im Artikel <2u8158F2706ubU1@uni-berlin.de>, Rob Kennedy <me3@privacy.net>
> schreibt:
>> (Delphi's try-finally blocks still execute, though.)
>
> In my tests (D4) no Finally code was executed, the call to @Assert actually
> never returned and ended up in Halt instead, without triggering any Finally
> code. I.e. SEH is not working at all when the various exception conditions do
> not trigger the Delphi exception handling.
No no. You misunderstood. In your non-SysUtils code, there were *no*
exceptions at all. No system exceptions, and no Delphi exceptions.
Execution proceeded directly to Halt. Since there were no exceptions, no
finally block could execute.
When I said that try-finally blocks still execute, I was talking about
the case when a system exception occurs, such as division by 0 or access
violation. Assertion failures aren't system exceptions. (And they aren't
Delphi exceptions, either, unless SysUtils is included.)
> P.S.: @Assert shows another calling convention encoding, in addition to the
> (stdcall? cdecl?) convention with _GetMem.
Delphi's procedure names don't suggest a calling convention. Neither do
C's, for that matter. In C, it's the other way around: The calling
convention suggests the name. The compiler won't guess the calling
convention based on the name, but it will mangle a name based on the
calling convention.
Many procedures in System.pas are declared without parameters and are
declared using the default register calling convention. They lack
parameters because when recompiling that unit, the compiler may add
automatic prologue and epilogue code that is inappropriate for those
methods. Delphi never adds that extra code to register procedures that
have no parameters. The parameters don't need to be mentioned in the
source, though, because the compiler doesn't need to read them from the
source file when it compiles other units. Instead, the procedure syntax
is built in to the compiler, and so the compiler always knows how to
generate calls to them with the right parameters.
Many of System.pas's internal procedures don't use any predefined
calling convention. Instead, other code might use JMP insetad of CALL to
go directly to the internal routine. Or it might bend the rules on
saving and restoring registers so it can return values in, say, EBX
instead of EAX.
-- Rob
- Next message: Bruce Roberts: "Re: Record"
- Previous message: SamH: "Delphi code - Disable Windows XP Firewall."
- In reply to: VBDis: "Re: Try Finally..."
- Next in thread: Martin Harvey (Demon account): "Re: Try Finally..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|