This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Patch: assume-compiled fix


This is another -fassume-compiled bug fix.

Suppose some ancestor of the current class is in a no-assume-compiled
package.  When generating the vtable for the current class, we
shouldn't generate a reference to any symbol in that ancestor class.

This patch fixes the problem by not generating a vtable if any
ancestor is not compiled.  Instead the vtable is built at runtime.  We
could be a bit more precise and only avoid vtable generation if this
class actually inherits a method from an uncompiled ancestor, but that
seemed like more work than was useful to me.

Tested on x86 Red Hat Linux 7.3.  Ok for the trunk?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* class.c (supers_all_compiled): New function.
	(make_class_data): Use it.

Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.148
diff -u -r1.148 class.c
--- class.c 18 Jan 2003 22:15:50 -0000 1.148
+++ class.c 21 Jan 2003 18:39:21 -0000
@@ -54,6 +54,7 @@
 static tree make_field_value (tree);
 static tree get_dispatch_vector (tree);
 static tree get_dispatch_table (tree, tree);
+static int supers_all_compiled (tree type);
 static void add_interface_do (tree, tree, int);
 static tree maybe_layout_super_class (tree, tree);
 static int assume_compiled (const char *);
@@ -1265,7 +1162,8 @@
 get_dispatch_vector (tree type)
 {
   tree vtable = TYPE_VTABLE (type);
-  if (vtable == NULL)
+
+  if (vtable == NULL_TREE)
     {
       HOST_WIDE_INT i;
       tree method;
@@ -1367,6 +1265,18 @@
 		NULL_TREE, list);
 }
 
+static int
+supers_all_compiled (tree type)
+{
+  while (type != NULL_TREE)
+    {
+      if (!assume_compiled (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)))))
+	return 0;
+      type = CLASSTYPE_SUPER (type);
+    }
+  return 1;
+}
+
 void
 make_class_data (tree type)
 {
@@ -1468,8 +1378,8 @@
   DECL_IGNORED_P (methods_decl) = 1;
   rest_of_decl_compilation (methods_decl, (char*) 0, 1, 0);
 
-  if (assume_compiled (IDENTIFIER_POINTER (DECL_NAME (type_decl)))
-      && ! CLASS_INTERFACE (type_decl) && !flag_indirect_dispatch)
+  if (supers_all_compiled (type) && ! CLASS_INTERFACE (type_decl)
+      && !flag_indirect_dispatch)
     {
       tree dtable = get_dispatch_table (type, this_class_addr);
       dtable_decl = build_dtable_decl (type);
@@ -1956,9 +1866,6 @@
   TYPE_NVIRTUALS (this_class) = dtable_count;
 }
 
-/* Return 0 if NAME is equal to STR, -1 if STR is "less" than NAME,
-   and 1 if STR is "greater" than NAME.  */
-
 /* Lay METHOD_DECL out, returning a possibly new value of
    DTABLE_COUNT. Also mangle the method's name. */
 
@@ -1995,7 +1902,7 @@
     }
   else if (! METHOD_STATIC (method_decl) && !DECL_ARTIFICIAL (method_decl))
     {
-      tree method_sig = 
+      tree method_sig =
 	build_java_argument_signature (TREE_TYPE (method_decl));
       tree super_method = lookup_argument_method (super_class, method_name,
 						  method_sig);


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