CFG and libcall conflict for java
Joe Buck
jbuck@synopsys.COM
Wed Sep 26 09:27:00 GMT 2001
> >Does Java standard require the trap to happen?
Jim Wilson writes:
> Alex answered that one. I knew about the divide by zero, but wasn't aware
> that this only mattered for integer divides, and that this was the only case.
(presumably Java defines floating point divide by zero to produce a
non-signalling NaN?)
Perhaps I'm tempted to go for a simple solution because I'm not as smart
as you. :-)
Since integer divide is the only case where a trap has to turn into a
throw, one solution would be to avoid the problem entirely:
generate code for the Java
result = num / den;
(where num and den are integral)
as the equivalent of C++
if (den) throw DivideByZero();
result = num / den;
Yes, it slows down integer division, but it's easy to get right on
all platforms. If the trap-into-throw mechanism works reliably on
some ports, then for those ports you could omit the test.
More information about the Gcc
mailing list