This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using exception specifications to help compiler


On Wed, 2003-06-04 at 12:25, Wolfgang Bangerth wrote:
> 
> Inspired by an article by Nathan Sidwell in the proceedings of the GCC 
> summit, I experimented a little with adding throw() specifications to some 
> 500 functions in our library. I estimate that this might cover about a 
> third of all small or often called functions for which I would expect this 
> to be significant.
> 
> The results are the following: file sizes are slightly reduced on average, 
> but run-time increases by about 1.5 per cent (details below).

The compiler can optimize successfully only if all functions called by
the "throw ()" function also have "throw ()" -- or can be inlined, and
do do not throw exceptions.

I suspect that in your case, you have something like:

  void f();

  void g() throw () { f(); }

In that case, the "throw ()" on "g" will actually make it bigger -- it
must now catch any exception thrown by "f" and call "unexpected".  That
would possibly also account for the slowdown, if you got worse cache
performance.

The other possibility is that the additional "throw ()" specifications
are causing the compiler to do more inlining, which is causing worse
performance in your particular case.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]