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]

[gcjx] Patch: FYI: array initializer fixes


I'm checking this in on the gcjx branch.

With this we create array initializers more correctly.  I think there
may still be bad GENERIC created by visit_array_initializer; I wrote
this last week and I forget the state.  (Most of these patches, btw,
come out of trying to compile java.* to assembly code and then fixing
whatever crashes.  A GENERIC verification pass sure would help this
process.)

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* tree.cc (visit_new_array): Handle array initializers properly.
	(visit_array_initializer): Create new array here.
	(build_new_object_array): Lay out array class.  Use
	build_class_reference.

Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.17
diff -u -r1.1.2.17 tree.cc
--- tree.cc 24 Mar 2005 02:20:35 -0000 1.1.2.17
+++ tree.cc 24 Mar 2005 02:23:07 -0000
@@ -913,12 +913,18 @@
 
 
 void
-tree_generator::visit_array_initializer (model_array_initializer *,
+tree_generator::visit_array_initializer (model_array_initializer *initx,
 					 const ref_forwarding_type &elt_type,
 					 const std::list<ref_expression> &exprs)
 {
   // FIXME: constant array initialization optimization... ?
 
+  tree ind_tree = build_int_cst (type_jint, exprs.size ());
+  if (elt_type->type ()->primitive_p ())
+    current = build_new_array (elt_type->type (), ind_tree, initx);
+  else
+    current = build_new_object_array (elt_type->type (), ind_tree);
+
   // At this point, 'current' is the 'new' expression for the array.
   tree new_expr = save_expr (current);
 
@@ -947,8 +953,8 @@
     }
 
   // Yield 'new_expr'.
-  tsi_link_after (&out, new_expr, TSI_CONTINUE_LINKING);
-  current = result;
+  current = build2 (COMPOUND_EXPR, TREE_TYPE (new_expr),
+		    result, new_expr);
 }
 
 void
@@ -1758,7 +1764,7 @@
       else
 	current = build_new_object_array (elt_type->type (), ind_tree);
     }
-  else
+  else if (indices.size () != 0)
     {
       tree args = NULL_TREE;
       for (std::list<ref_expression>::const_iterator i = indices.begin ();
@@ -1774,9 +1780,11 @@
 			builtin_Jv_NewMultiArray,
 			nreverse (args), NULL_TREE);
     }
-
-  if (init)
-    init->visit (this);
+  else
+    {
+      assert (init);
+      init->visit (this);
+    }
 }
 
 void
@@ -1921,10 +1929,12 @@
 tree
 tree_generator::build_new_object_array (model_type *elt_type, tree size)
 {
-  model_type *array_type = elt_type->array ();
+  model_class *array_type = assert_cast<model_class *> (elt_type->array ());
 
-  tree elt_type_tree = gcc_builtins->map_type (elt_type);
-  tree array_type_tree = gcc_builtins->map_type (array_type);
+  gcj_abi *abi = gcc_builtins->find_abi ();
+  tree elt_type_tree
+    = abi->build_class_reference (gcc_builtins, class_wrapper, elt_type);
+  tree array_type_tree = gcc_builtins->lay_out_class (array_type);
 
   tree args = tree_cons (NULL_TREE, size,
 			 tree_cons (NULL_TREE, elt_type_tree,


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