Commit 3bec3c0c by Richard Henderson Committed by Richard Henderson

class.c (layout_class_method): Set DECL_EXTERNAL.

        * 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.

From-SVN: r66768
parent a65cddcf
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> 2003-05-04 Nathan Sidwell <nathan@codesourcery.com>
* Make-lang.in (java/parse.o, java/parse-scan.o): Depend on input.h. * Make-lang.in (java/parse.o, java/parse-scan.o): Depend on input.h.
......
...@@ -1892,6 +1892,9 @@ layout_class_method (tree this_class, tree super_class, ...@@ -1892,6 +1892,9 @@ layout_class_method (tree this_class, tree super_class,
tree method_name = DECL_NAME (method_decl); tree method_name = DECL_NAME (method_decl);
TREE_PUBLIC (method_decl) = 1; 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 */ /* This is a good occasion to mangle the method's name */
SET_DECL_ASSEMBLER_NAME (method_decl, SET_DECL_ASSEMBLER_NAME (method_decl,
......
...@@ -1845,4 +1845,33 @@ void java_optimize_inline (tree fndecl) ...@@ -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" #include "gt-java-decl.h"
...@@ -1296,6 +1296,8 @@ extern int predefined_filename_p (tree); ...@@ -1296,6 +1296,8 @@ extern int predefined_filename_p (tree);
extern void java_optimize_inline (tree); extern void java_optimize_inline (tree);
extern tree decl_constant_value (tree); extern tree decl_constant_value (tree);
extern void java_mark_class_local (tree);
#if defined(RTX_CODE) && defined (HAVE_MACHINE_MODES) #if defined(RTX_CODE) && defined (HAVE_MACHINE_MODES)
struct rtx_def * java_expand_expr (tree, rtx, enum machine_mode, int); struct rtx_def * java_expand_expr (tree, rtx, enum machine_mode, int);
#endif #endif
......
...@@ -701,7 +701,7 @@ init_outgoing_cpool (void) ...@@ -701,7 +701,7 @@ init_outgoing_cpool (void)
static void static void
parse_class_file (void) parse_class_file (void)
{ {
tree method, field; tree method;
const char *save_input_filename = input_filename; const char *save_input_filename = input_filename;
int save_lineno = input_line; int save_lineno = input_line;
...@@ -716,10 +716,7 @@ parse_class_file (void) ...@@ -716,10 +716,7 @@ parse_class_file (void)
compiling from class files. */ compiling from class files. */
always_initialize_class_p = 1; always_initialize_class_p = 1;
for (field = TYPE_FIELDS (current_class); java_mark_class_local (current_class);
field != NULL_TREE; field = TREE_CHAIN (field))
if (FIELD_STATIC (field))
DECL_EXTERNAL (field) = 0;
for (method = TYPE_METHODS (current_class); for (method = TYPE_METHODS (current_class);
method != NULL_TREE; method = TREE_CHAIN (method)) method != NULL_TREE; method = TREE_CHAIN (method))
......
...@@ -8977,21 +8977,15 @@ java_expand_classes (void) ...@@ -8977,21 +8977,15 @@ java_expand_classes (void)
/* Now things are stable, go for generation of the class data. */ /* Now things are stable, go for generation of the class data. */
/* We pessimistically marked all fields external until we knew /* We pessimistically marked all methods and fields external until
what set of classes we were planning to compile. Now mark we knew what set of classes we were planning to compile. Now mark
those that will be generated locally as not external. */ those that will be generated locally as not external. */
for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next) for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{ {
tree current; tree current;
ctxp = cur_ctxp; ctxp = cur_ctxp;
for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
{ java_mark_class_local (TREE_TYPE (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;
}
} }
/* Compile the classes. */ /* Compile the classes. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment