[fpc-devel]raise's exceptaddr

Peter Vreman peter at freepascal.org
Fri May 17 07:17:44 CEST 2002


> 
> 
> 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.









More information about the fpc-devel mailing list