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 04 Mar 2005 10:13:29 -0700, Tom Tromey <tromey@redhat.com> wrote:
 > > Ranjit> If I compile this to a class file and then use
 > > Ranjit> "-O3 -findirect-dispatch" (to trigger the new verifier
 > > Ranjit> without this patch), I get to see the bug.
 > > 
 > > I can't reproduce this here:
 > 
 > Which is weird, since I still can:
 > -------------------------------- 8< --------------------------------
 > ~/tmp > cat Foo.java
 > public class Foo
 > {
 >   static int bar( )
 >   {
 >     int[] x = (int[] )null;
 >     int y = x.length;
 >     return 666;
 >   }
 > 
 >   public static void main( String[] args)
 >   {
 >     try
 >     {
 >       int n = bar( );
 >       System.err.println( "ERROR");
 >     }
 >     catch( NullPointerException npe) { /* EXPECTED */ }
 >   }
 > }
 > ~/tmp > mygcj --version
 > gcj (GCC) 4.1.0 20050305 (experimental)
 > Copyright (C) 2005 Free Software Foundation, Inc.
 > This is free software; see the source for copying conditions.  There is NO
 > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 > 
 > ~/tmp > mygcj -C Foo.java
 > ~/tmp > mygcj --main=Foo Foo.class
 > ~/tmp > ./a.out
 > ~/tmp > mygcj --main=Foo -O3 Foo.class
 > ~/tmp > ./a.out
 > ~/tmp > mygcj --main=Foo -findirect-dispatch Foo.class
 > ~/tmp > ./a.out
 > ~/tmp > mygcj --main=Foo -findirect-dispatch -O3 Foo.class
 > ~/tmp > ./a.out
 > ERROR

This is expected.  I had a discussion with rth about this a little
while ago.

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.

Andrew.


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