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: vtable indices


I'm checking this in on the gcjx branch.

This fixes computation of the method index in the method table.
It also makes it abi-specific.

Tom

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* classobj.cc (create_one_method_record): Correctly compute
	"index" field.
	* abi.cc (get_vtable_index): New method.
	* abi.hh (gcj_abi::get_vtable_index): New method.
	(cxx_abi::get_vtable_index): Declare.
	(bc_abi::get_vtable_index): New method.

Index: gcc/java/abi.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.cc,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 abi.cc
--- gcc/java/abi.cc 8 Mar 2005 00:22:45 -0000 1.1.2.6
+++ gcc/java/abi.cc 8 Mar 2005 00:28:08 -0000
@@ -201,6 +201,15 @@
   return build_address_of (builtins->get_vtable_decl (klass, lay_out));
 }
 
+tree
+cxx_abi::get_vtable_index (aot_class *klass, model_method *method)
+{
+  assert (method->get_declaring_class () == klass->get ());
+  if (method->static_p () || method->constructor_p ())
+    return integer_minus_one_node;
+  return build_int_cst (type_jint, klass->find_in_vtable (method));
+}
+
 
 
 tree
Index: gcc/java/abi.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.hh,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 abi.hh
--- gcc/java/abi.hh 8 Mar 2005 00:22:45 -0000 1.1.2.4
+++ gcc/java/abi.hh 8 Mar 2005 00:28:08 -0000
@@ -113,6 +113,10 @@
   /// KLASS and need a fully-filled-in vtable, not just a decl.
   virtual tree get_vtable (tree_builtins *builtins, model_class *klass,
 			   bool lay_out = false) = 0;
+
+  /// Return tree representing index into vtable where this method can
+  /// be found.  Should return -1 for a static method or constructor.
+  virtual tree get_vtable_index (aot_class *klass, model_method *method) = 0;
 };
 
 /// This class handles C++ ABI code.
@@ -151,6 +155,8 @@
   }
 
   tree get_vtable (tree_builtins *, model_class *, bool);
+
+  tree get_vtable_index (aot_class *klass, model_method *method);
 };
 
 /// This class handles the binary compatibility ABI.
@@ -193,6 +199,11 @@
     // The BC ABI lays out all vtables at runtime.
     return null_pointer_node;
   }
+
+  tree get_vtable_index (aot_class *, model_method *)
+  {
+    return integer_minus_one_node;
+  }
 };
 
 #endif // GCC_TREE_ABI_HH
Index: gcc/java/classobj.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/classobj.cc,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 classobj.cc
--- gcc/java/classobj.cc 8 Mar 2005 00:22:45 -0000 1.1.2.12
+++ gcc/java/classobj.cc 8 Mar 2005 00:28:08 -0000
@@ -198,7 +198,8 @@
 		  builtins->map_utf8const (method->get_descriptor ()));
   inst.set_field ("accflags",
 		  build_int_cst (type_jushort, method->get_modifiers ()));
-  inst.set_field ("index", integer_minus_one_node); // FIXME
+  gcj_abi *abi = builtins->find_abi ();
+  inst.set_field ("index", abi->get_vtable_index (klass, method));
   inst.set_field ("ncode", build_address_of (mdecl));
   inst.set_field ("throws", create_method_throws (method));
   return inst.finish_record ();


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