OSDN Git Service

* class.c (layout_class_method): Set DECL_EXTERNAL.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 May 2003 17:41:17 +0000 (17:41 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 May 2003 17:41:17 +0000 (17:41 +0000)
        * 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66768 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/decl.c
gcc/java/java-tree.h
gcc/java/jcf-parse.c
gcc/java/parse.y

index d8c23e4..b4e13f3 100644 (file)
@@ -1,3 +1,11 @@
+2003-05-13  Richard Henderson  <rth@redhat.com>
+
+       * 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.
+
 2003-05-04  Nathan Sidwell  <nathan@codesourcery.com>
 
        * Make-lang.in (java/parse.o, java/parse-scan.o): Depend on input.h.
index e51e799..a7fa454 100644 (file)
@@ -1892,6 +1892,9 @@ layout_class_method (tree this_class, tree super_class,
   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 a4b1c43..b06cf88 100644 (file)
@@ -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 62d2452..78bc924 100644 (file)
@@ -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 d642bdc..e3e60cb 100644 (file)
@@ -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 49fbc91..6dd9174 100644 (file)
@@ -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.  */