Libjava failures status
Chris Lattner
sabre@nondot.org
Tue Mar 12 12:42:00 GMT 2002
> > So, this method must throw an ArithmeticException, even though i2 is
> > never used (for that matter, i1 is only used in generating the throw),
> > because every reachable expression along a control flow path must be
> > evaluated:
Consider the code with explicit checks put into it:
void m() {
int i1 = 0;
int i2 = i1 / i1;
}
becomes:
void m() {
int i1 = 0;
if (i1 == 0) throw ...divide by zero...;
int i2 = i1 / i1;
}
In this case, yes the division can be removed, and furthermore, the
function should be compiled to a simple:
void m() {
throw ...divide by zero...;
}
Making the checks explicit decouples the divide from the check implicit in
the instruction.
> Every _reachable_? Insane, I'm sure Sun specified this to make really
> sure, that no highly optimizing compiler for java is implementable :/
No, it would be perfectly reasonable to represent this (safely) with
explicit checks, which would not break any optimizations... Why does GCC
have the notion of a trapping and nontrapping instruction? Perhaps it is
not the best approach for GCJ?
-Chris
More information about the Gcc
mailing list