diff options
-rw-r--r-- | gcc/java/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/java/class.c | 3 | ||||
-rw-r--r-- | gcc/java/decl.c | 29 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 2 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 7 | ||||
-rw-r--r-- | gcc/java/parse.y | 12 |
6 files changed, 47 insertions, 14 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index d8c23e4..b4e13f3 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -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. diff --git a/gcc/java/class.c b/gcc/java/class.c index e51e7999..a7fa454 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -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, diff --git a/gcc/java/decl.c b/gcc/java/decl.c index a4b1c43..b06cf88 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -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" diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 62d2452..78bc924 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -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 diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index d642bdc..e3e60cb 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -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)) diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 49fbc91..6dd9174 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -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. */ |