[java] Re: analysis #2: alpha bootstrap failure on mainline

Richard Henderson rth@redhat.com
Thu May 8 23:53:00 GMT 2003


On Thu, May 08, 2003 at 02:22:27PM -0700, Richard Henderson wrote:
> On Wed, May 07, 2003 at 12:13:46PM -0600, Roger Sayle wrote:
> > .libs/libgcj.la-4.o: branch relocation out-of-range, bad object file
> > produced, can't branch from 0x3ffbfd1b518 to 0xfffffffffffffffc
> 
> I'm tracking this down.  It appears that the Java front end lies
> to the backend about whether a particular routine is present in
> the current translation unit.
> 
> On Linux this appears as 
> 
> relocation truncated to fit: BRSGP java::lang::Object::Object[in-charge]()
> 
> at link time, rather than at run time as on Tru64.

Indeed, DECL_EXTERNAL was not set for methods that are
separately compiled.  Fixed (for Linux anyway) thus.

Ok?


r~


	* class.c (layout_class_method): Set DECL_EXTERNAL.
	* decl.c (java_mark_decl_local, java_mark_class_local): New.
	* java-tree.h (java_mark_class_local): Declare.
	* jcf-parse.c (parse_class_file): Use it.
	* parse.y (java_expand_classes): Likewise.

Index: java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.156
diff -c -p -d -u -r1.156 class.c
--- java/class.c	1 May 2003 16:13:35 -0000	1.156
+++ java/class.c	8 May 2003 23:46:25 -0000
@@ -1892,6 +1892,9 @@ layout_class_method (tree this_class, tr
   tree method_name = DECL_NAME (method_decl);
 
   TREE_PUBLIC (method_decl) = 1;
+  /* Considered external until we know what classes are being
+     compiled into this object file.  */
+  DECL_EXTERNAL (method_decl) = 1;
 
   /* This is a good occasion to mangle the method's name */
   SET_DECL_ASSEMBLER_NAME (method_decl,
Index: java/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.152
diff -c -p -d -u -r1.152 decl.c
--- java/decl.c	1 May 2003 16:13:36 -0000	1.152
+++ java/decl.c	8 May 2003 23:46:25 -0000
@@ -1845,4 +1845,33 @@ void java_optimize_inline (tree fndecl)
     }
 }
 
+/* We pessimistically marked all methods and fields external until we
+   knew what set of classes we were planning to compile.  Now mark those
+   associated with CLASS to be generated locally as not external.  */
+
+static void
+java_mark_decl_local (tree decl)
+{
+  DECL_EXTERNAL (decl) = 0;
+
+  /* If we've already constructed DECL_RTL, give encode_section_info
+     a second chance, now that we've changed the flags.  */
+  if (DECL_RTL_SET_P (decl))
+    make_decl_rtl (decl, NULL);
+}
+
+void
+java_mark_class_local (tree class)
+{
+  tree t;
+
+  for (t = TYPE_FIELDS (class); t ; t = TREE_CHAIN (t))
+    if (FIELD_STATIC (t))
+      java_mark_decl_local (t);
+
+  for (t = TYPE_METHODS (class); t ; t = TREE_CHAIN (t))
+    if (!METHOD_ABSTRACT (t) && (!METHOD_NATIVE (t) || flag_jni))
+      java_mark_decl_local (t);
+}
+
 #include "gt-java-decl.h"
Index: java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.173
diff -c -p -d -u -r1.173 java-tree.h
--- java/java-tree.h	13 Apr 2003 01:45:34 -0000	1.173
+++ java/java-tree.h	8 May 2003 23:46:25 -0000
@@ -1296,6 +1296,8 @@ extern int predefined_filename_p (tree);
 extern void java_optimize_inline (tree);
 extern tree decl_constant_value (tree);
 
+extern void java_mark_class_local (tree);
+
 #if defined(RTX_CODE) && defined (HAVE_MACHINE_MODES)
 struct rtx_def * java_expand_expr (tree, rtx, enum machine_mode, int); 
 #endif
Index: java/jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.139
diff -c -p -d -u -r1.139 jcf-parse.c
--- java/jcf-parse.c	1 May 2003 16:13:36 -0000	1.139
+++ java/jcf-parse.c	8 May 2003 23:46:25 -0000
@@ -701,7 +701,7 @@ init_outgoing_cpool (void)
 static void
 parse_class_file (void)
 {
-  tree method, field;
+  tree method;
   const char *save_input_filename = input_filename;
   int save_lineno = input_line;
 
@@ -716,10 +716,7 @@ parse_class_file (void)
      compiling from class files.  */
   always_initialize_class_p = 1;
 
-  for (field = TYPE_FIELDS (current_class);
-       field != NULL_TREE; field = TREE_CHAIN (field))
-    if (FIELD_STATIC (field))
-      DECL_EXTERNAL (field) = 0;
+  java_mark_class_local (current_class);
 
   for (method = TYPE_METHODS (current_class);
        method != NULL_TREE; method = TREE_CHAIN (method))
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.431
diff -c -p -d -u -r1.431 parse.y
--- java/parse.y	3 May 2003 00:35:06 -0000	1.431
+++ java/parse.y	8 May 2003 23:46:26 -0000
@@ -8977,21 +8977,15 @@ java_expand_classes (void)
 
   /* Now things are stable, go for generation of the class data. */
 
-  /* We pessimistically marked all fields external until we knew
-     what set of classes we were planning to compile.  Now mark
+  /* We pessimistically marked all methods and fields external until
+     we knew what set of classes we were planning to compile.  Now mark
      those that will be generated locally as not external.  */
   for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
       tree current;
       ctxp = cur_ctxp;
       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
-	{
-	  tree class = TREE_TYPE (current);
-	  tree field;
-	  for (field = TYPE_FIELDS (class); field ; field = TREE_CHAIN (field))
-	    if (FIELD_STATIC (field))
-	      DECL_EXTERNAL (field) = 0;
-	}
+	java_mark_class_local (TREE_TYPE (current));
     }
 
   /* Compile the classes.  */



More information about the Java-patches mailing list