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]

[BC] Patch: FYI: remove erroneous array store check optimization


I'm checking this in on the BC branch.

While working on integrating the new verifier, I ran across some
suspect code in gcj.  Today I wrote a test case and, sure enough, we
were incorrectly failing to generate a required array store check.

Tom

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* expr.c (build_java_arraystore_check): Still generate check if
	element type is itself an array.

Index: gcc/java/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.185.2.20
diff -u -r1.185.2.20 expr.c
--- gcc/java/expr.c 5 Nov 2004 19:30:05 -0000 1.185.2.20
+++ gcc/java/expr.c 9 Nov 2004 23:05:41 -0000
@@ -969,14 +969,14 @@
   if (!flag_store_check)
     return build1 (NOP_EXPR, array_type_p, array);
 
-  /* No check is needed if the element type is final or is itself an array.  
-     Also check that element_type matches object_type, since in the bytecode 
-     compilation case element_type may be the actual element type of the array
-     rather than its declared type.  However, if we're doing indirect
-     dispatch, we can't do the `final' optimization.  */
+  /* No check is needed if the element type is final.  Also check that
+     element_type matches object_type, since in the bytecode
+     compilation case element_type may be the actual element type of
+     the array rather than its declared type.  However, if we're doing
+     indirect dispatch, we can't do the `final' optimization.  */
   if (element_type == object_type
-      && (TYPE_ARRAY_P (TREE_TYPE (element_type))
-	  || (! flag_indirect_dispatch && CLASS_FINAL (element_type))))
+      && ! flag_indirect_dispatch
+      && CLASS_FINAL (element_type))
     return build1 (NOP_EXPR, array_type_p, array);
   
   /* OBJECT might be wrapped by a SAVE_EXPR. */
Index: libjava/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* testsuite/libjava.lang/assign2.out: New file.
	* testsuite/libjava.lang/assign2.java: New file.

Index: libjava/testsuite/libjava.lang/assign2.java
===================================================================
RCS file: libjava/testsuite/libjava.lang/assign2.java
diff -N libjava/testsuite/libjava.lang/assign2.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.lang/assign2.java 9 Nov 2004 23:05:47 -0000
@@ -0,0 +1,21 @@
+// Test for an array assignment bug we've had.
+
+public class assign2
+{
+  public static Object[][] c () { return new Long[5][5]; }
+
+  public static Object[] d () { return new Integer[3]; }
+
+  public static void main(String[] args)
+  {
+    try
+      {
+	Object[][] x = c();
+	x[0] = d();
+      }
+    catch (ArrayStoreException _)
+      {
+	System.out.println("good");
+      }
+  }
+}
Index: libjava/testsuite/libjava.lang/assign2.out
===================================================================
RCS file: libjava/testsuite/libjava.lang/assign2.out
diff -N libjava/testsuite/libjava.lang/assign2.out
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.lang/assign2.out 9 Nov 2004 23:05:47 -0000
@@ -0,0 +1 @@
+good


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