[Cfp-interest] rationale for immediate/nondeterministic exception handling

David Hough CFP pcfp at oakapple.net
Fri May 30 14:46:22 PDT 2014


How fast you can drive your car depends a lot on how fast you can stop it.

Just in case it's not clear, the immediate exception handling mandate
in 754-2008 is not for the purpose of making the exceptional code run
faster.      It's for the purpose of making the normal code run faster
by eliminating the need for adding explicit tests for operand, results,
or flags, that hardly ever find anything,
when the same information is already available in the hardware
at no additional cost in the logic that determines whether an exception
arose.    Making that logic manifest in a transfer of control is not
a cost-free operation - setting up and tearing down trap handlers
is going to cost something - and probably entails a system call on many
existing systems.     

Probably the way this should work is that at the program outset, IEEE
trap handlers are set up to go to a user-mode program that does whatever
the current catch_fe structure entails, and by default just generates
SIGFPE if an IEEE trap is enabled, which is what usually happens I think
on most Unix systems.     That would allow for the possibility that somebody
else besides the try/catch mechanism is fiddling with the hardware trap
enables - most likely a debugging environment that wants to catch unexpected
exceptions. 



More information about the Cfp-interest mailing list