[fpc-devel]raise's exceptaddr
Florian Klaempfl
Florian.Klaempfl at gmx.de
Fri May 17 12:19:33 CEST 2002
At 05:17 17.05.02 +0000, you wrote:
> >
> >
> > On Thu, 16 May 2002, Aleksey V. Vaneev wrote:
> >
> > > Hello,
> > >
> > > > The frame will always be created. As soon as ansistrings is used
> > > > in a procedure, an exception frame is created in a procedure -
> > > > always. Even is no raise statement is present (an exception could
> > > > e.g. be raised in a called procedure).
> > > >
> > > > Michael.
> > >
> > > I think you have not got the idea.
> > >
> > > I mean, if I write something like this:
> > >
> > > resourcestring
> > > ErrMsg = 'aaabbbccc';
> > >
> > > procedure Test123;
> > > begin
> > > if (not Success) then
> > > raise Exception.create (ErrMsg);
> > >
> > > ...do something a little...
> > > end;
> > >
> > > Stackframe will be created for the whole Test123 and its overhead will be
> > > applied to "...do something a little..." in all the cases.
> > >
> > > But if I write in this way:
> > >
> > > procedure Test123;
> > >
> > > procedure doraise;
> > > begin
> > > raise Exception.create (ErrMsg);
> > > end;
> > >
> > > begin
> > > if (not Success) then
> > > doraise;
> > >
> > > ...do something a little...
> > > end;
> > >
> > > Overhead is issued ONLY if Success = False. In all other cases "...do
> > > something a little..." executes without ANY unnecessary overhead.
> >
> > OK, I see what you mean now, yes, in this case the code will be faster.
> > I'm not sure whether this is possible, this is something for Florian
> > Klaempfl to decide :/
>
>But what when you have:
>
>case value of
> 1 :
> ansistring operation
> 2 :
> ansistring operation
> 3 :
> ansistring operation
> else
> shortstring operation
>end;
>
>Then with having the exceptionframe around the smallest possible
>ansistring operation it
>will generate the code 3 times.
It would need some addtional information:
When compiled with -OG it would be worth the effort in this case.
Nevertheless, it would require heavy changes in temp. ansistring generation
and raise
code generation, so Aleksey's workround seems to me the only solution.
More information about the fpc-devel
mailing list