octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does mx-inlines.cc use throw ()?


From: Rik
Subject: Re: Why does mx-inlines.cc use throw ()?
Date: Tue, 3 May 2016 10:09:39 -0700

On 05/02/2016 10:44 PM, address@hidden wrote:
Subject:
Why does mx-inlines.cc use throw ()?
From:
LachlanA <address@hidden>
Date:
05/02/2016 10:09 PM
To:
address@hidden
List-Post:
<mailto:address@hidden>
Content-Transfer-Encoding:
7bit
Precedence:
list
MIME-Version:
1.0
Message-ID:
<address@hidden>
Content-Type:
text/plain; charset=us-ascii
Message:
5

Greetings all,

I'm trying to implement "dbstop if naninf" like Matlab has, which involves
turning on floating point exception signals.

Currently, I catch the signals, and then throw an
octave_execution_exception.  However, functions like  max  and  min  call
code in mx-inlines.cc that has "throw ()" declarations prohibiting them from
throwing exceptions.

Are these really needed?  Is it just to allow optimization or is it also
required to ensure functional correctness?

My guess is that it is there for the compiler to help with optimization.  With a name like mx-inlines.cc, I think the hope is that the compiler recognizes that these don't need to be full blown functions and can be inlined.  See http://www.gotw.ca/publications/mill22.htm, where there is this comment, "Besides the overhead for generating the try/catch blocks shown above, which might be minor on efficient compilers, there are at least two other ways that exception specifications can commonly cost you in runtime performance. First, some compilers will automatically refuse to inline a function having an exception specification, just as they can apply other heuristics such as refusing to inline functions that have more than a certain number of nested statements or that contain any kind of loop construct. Second, some compilers don’t optimize exception-related knowledge well at all, and will add the above-shown try/catch blocks even when the function body provably can’t throw."  This is about exception specifications, rather than saying the routine won't throw, but seems related.

--Rik


reply via email to

[Prev in Thread] Current Thread [Next in Thread]