This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC/RFT] Patch (java): Switch to new verifier


Ranjit Mathew writes:
 > On Mon, 7 Mar 2005 10:08:10 -0800, Richard Henderson <rth@redhat.com> wrote:
 > > On Sat, Mar 05, 2005 at 03:15:36PM +0000, Andrew Haley wrote:
 > > > The rule is that a fetch from an unused variable may be deleted by the
 > > > tree optimizers.  I could fix this fairly easily by making the target
 > > > of a load volatile.
 > > 
 > > Or the load itself via casts: *(volatile T *)addr.
 > 
 > Ignoramus am I, but still...
 > 
 > If the load has a possible side-effect (a NullPointerException in
 > this case), can the optimizers still rightly remove the load even
 > if the variable is unused?

Yeah.  That's a perfectly reasonable thing to do.  If an instruction
may trap but its result is unused, we can remove the instruction and
thereby avoid the possibility of a trap.

 > Marking it volatile seems like a workaround rather than the
 > solution, IMHO.

That's a very Java-esque point of view!  Marking it volatile seems to
me exactly the samentics we want.  The problem with volatile is that
we'll de-optimize things of the form

for (blah)
  baz += a.b;

because we'll fetch a.b from memory every time around the loop.  It
would be nice automagically to convert this to

tmp = a.b;
for (blah)
  baz += tmp;

but I'm having a hard time figuring out how to do so.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]