Patch: don't generate dead bytecode

Tom Tromey tromey@redhat.com
Thu Oct 11 20:16:00 GMT 2001


>>>>> "Per" == Per Bothner <per@bothner.com> writes:

Per> 2001-10-11  Per Bothner  <per@bothner.com>
Per>     * parse.y (patch_if_else_statement):  If the condition is constant,
Per>     optimize away the test.

This patch almost fixes all the problems.  One remains:

/x1/egcs/build/gcc/gcj -B/x1/egcs/build/i686-pc-linux-gnu/libjava/ -B/x1/egcs/build/gcc/ --encoding=UTF-8 --syntax-only ./java/io/ObjectInputStream.class
java/io/ObjectInputStream.java: In class `java.io.ObjectInputStream':
java/io/ObjectInputStream.java: In method `java.io.ObjectInputStream.dumpElement(java.lang.String)':
java/io/ObjectInputStream.java:1538: warning: Unreachable bytecode from 3 to before 16.
java/io/ObjectInputStream.java: In method `java.io.ObjectInputStream.dumpElementln(java.lang.String)':
java/io/ObjectInputStream.java:1544: warning: Unreachable bytecode from 3 to before 16.


Some of the code in question looks like this:

  private void dumpElement (String msg)
  {
    if (Configuration.DEBUG && dump)  
      System.out.print(msg);
  }

Here's the corresponding bytecode:

  0: goto 16
  3: getstatic #922=<Field java.io.ObjectInputStream.dump boolean>
  6: ifeq 16
  9: getstatic #926=<Field java.lang.System.out java.io.PrintStream>
 12: aload_1
 13: invokevirtual #931=<Method java.io.PrintStream.print (java.lang.String)void>
 16: return


It looks like `&&' isn't being short-circuited properly.

Tom



More information about the Gcc-patches mailing list