This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Libjava failures status
- From: Chris Lattner <sabre at nondot dot org>
- To: <gcc at gnu dot org>
- Date: Tue, 12 Mar 2002 14:43:17 -0600 (CST)
- Subject: Re: Libjava failures status
> > 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