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:


I'm checking this in on the gcjx branch.

This changes the compiler to correctly initialize the target class in
a couple of places.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* abi.cc (build_field_reference): Initialize class.
	* builtins.cc (build_class_init): New method.
	* builtins.hh (tree_builtins::build_class_init): Declare.
	* tree.cc (visit_method): Initialize class.

Index: abi.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.cc,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 abi.cc
--- abi.cc 8 Mar 2005 01:22:00 -0000 1.1.2.10
+++ abi.cc 8 Mar 2005 02:58:47 -0000
@@ -131,7 +131,11 @@
   if (field->static_p ())
     {
       assert (obj == NULL_TREE);
-      // FIXME: initialize class.
+
+      result
+	= build2 (COMPOUND_EXPR, TREE_TYPE (result),
+		  builtins->build_class_init (field->get_declaring_class ()),
+		  result);
     }
   else
     {
Index: builtins.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.cc,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 builtins.cc
--- builtins.cc 8 Mar 2005 01:22:00 -0000 1.1.2.15
+++ builtins.cc 8 Mar 2005 02:58:48 -0000
@@ -640,3 +640,22 @@
   ++symbol_count;
   return get_identifier (buf);
 }
+
+tree
+tree_builtins::build_class_init (model_class *klass)
+{
+  aot_class *wrapper = get_class (klass);
+  gcj_abi *abi = find_abi ();
+  tree ref = abi->build_class_reference (this, wrapper, klass);
+
+  tree result
+    = build3 (CALL_EXPR, void_type_node,
+	      builtin_Jv_InitClass,
+	      build_tree_list (NULL_TREE,
+			       // FIXME: why do we declare this
+			       // function with the wrong argument
+			       // type?
+			       build1 (NOP_EXPR, ptr_type_node, ref)),
+	      NULL_TREE);
+  return result;
+}
Index: builtins.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.hh,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 builtins.hh
--- builtins.hh 8 Mar 2005 01:22:00 -0000 1.1.2.10
+++ builtins.hh 8 Mar 2005 02:58:48 -0000
@@ -128,6 +128,9 @@
 
   /// Return the decl for a given class' constant pool.
   tree get_constant_pool_decl (model_class *);
+
+  /// Return some code to initialize a class.
+  tree build_class_init (model_class *);
 };
 
 #endif // GCC_TREE_BUILTINS_HH
Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 tree.cc
--- tree.cc 8 Mar 2005 01:22:00 -0000 1.1.2.12
+++ tree.cc 8 Mar 2005 02:58:48 -0000
@@ -112,7 +112,20 @@
       BLOCK_SUPERCONTEXT (current_block) = method_tree;
       DECL_INITIAL (method_tree) = current_block;
 
+      tree statements = alloc_stmt_list ();
+      tree_stmt_iterator out = tsi_start (statements);
+
+      if (meth->static_p ())
+	{
+	  tree init
+	    = gcc_builtins->build_class_init (meth->get_declaring_class ());
+	  tsi_link_after (&out, init, TSI_CONTINUE_LINKING);
+	}
+
       block->visit (this);
+      tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
+      current = statements;
+
       // Handle synchronized methods.  This isn't done for JNI
       // methods, since such synchronization is handled by the VM.
       if ((meth->get_modifiers () & ACC_SYNCHRONIZED) != 0)


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