This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Fix libjava.compile/PR375.java
- From: Richard Henderson <rth at redhat dot com>
- To: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 2 Feb 2002 20:25:57 -0800
- Subject: Fix libjava.compile/PR375.java
Here's an attempt to fix the problem described here
http://gcc.gnu.org/ml/java-patches/2001-q4/msg00493.html
http://gcc.gnu.org/ml/java-patches/2001-q4/msg00501.html
The idea is to mark all static fields external until we decide
which of the classes we have read we are going to compile.
At that point we mark them local and compile the classes.
Tested on alphaev6-linux.
Ok?
r~
* class.c (add_field): Mark static fields external.
(build_class_ref): Remove redundant set.
* parse.y (java_expand_classes): Mark static fields of classes
to be compiled as local.
* jcf-parse.c (parse_class_file): Likewise.
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.124
diff -c -p -d -r1.124 class.c
*** class.c 2002/01/03 07:50:49 1.124
--- class.c 2002/02/03 04:16:30
*************** add_field (class, name, field_type, flag
*** 773,779 ****
--- 773,783 ----
/* Always make field externally visible. This is required so
that native methods can always access the field. */
TREE_PUBLIC (field) = 1;
+ /* Considered external until we know what classes are being
+ compiled into this object file. */
+ DECL_EXTERNAL (field) = 1;
}
+
return field;
}
*************** build_class_ref (type)
*** 1095,1102 ****
DECL_EXTERNAL (decl) = 1;
make_decl_rtl (decl, NULL);
pushdecl_top_level (decl);
- if (is_compiled == 1)
- DECL_EXTERNAL (decl) = 1;
}
}
--- 1099,1104 ----
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.103
diff -c -p -d -r1.103 jcf-parse.c
*** jcf-parse.c 2002/02/01 21:07:30 1.103
--- jcf-parse.c 2002/02/03 04:16:30
*************** init_outgoing_cpool ()
*** 793,799 ****
static void
parse_class_file ()
{
! tree method;
const char *save_input_filename = input_filename;
int save_lineno = lineno;
--- 793,799 ----
static void
parse_class_file ()
{
! tree method, field;
const char *save_input_filename = input_filename;
int save_lineno = lineno;
*************** parse_class_file ()
*** 808,815 ****
compiling from class files. */
always_initialize_class_p = 1;
! for ( method = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (current_class));
! method != NULL_TREE; method = TREE_CHAIN (method))
{
JCF *jcf = current_jcf;
--- 808,820 ----
compiling from class files. */
always_initialize_class_p = 1;
! for (field = TYPE_FIELDS (CLASS_TO_HANDLE_TYPE (current_class));
! field != NULL_TREE; field = TREE_CHAIN (field))
! if (FIELD_STATIC (field))
! DECL_EXTERNAL (field) = 0;
!
! for (method = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (current_class));
! method != NULL_TREE; method = TREE_CHAIN (method))
{
JCF *jcf = current_jcf;
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.348
diff -c -p -d -r1.348 parse.y
*** parse.y 2002/01/28 16:52:27 1.348
--- parse.y 2002/02/03 04:16:31
*************** java_expand_classes ()
*** 8963,8970 ****
java_layout_classes ();
java_parse_abort_on_error ();
! cur_ctxp = ctxp_for_generation;
! for (; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
ctxp = cur_ctxp;
input_filename = ctxp->filename;
--- 8963,8969 ----
java_layout_classes ();
java_parse_abort_on_error ();
! for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
ctxp = cur_ctxp;
input_filename = ctxp->filename;
*************** java_expand_classes ()
*** 8976,8982 ****
/* Find anonymous classes and expand their constructor, now they
have been fixed. */
! for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
tree current;
ctxp = cur_ctxp;
--- 8975,8981 ----
/* Find anonymous classes and expand their constructor, now they
have been fixed. */
! for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
tree current;
ctxp = cur_ctxp;
*************** java_expand_classes ()
*** 9009,9015 ****
return;
/* Now things are stable, go for generation of the class data. */
! for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
tree current;
ctxp = cur_ctxp;
--- 9008,9032 ----
return;
/* 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
! those that will be generated locally as not external. */
! for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
! {
! tree current;
! 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;
! }
! }
!
! /* Compile the classes. */
! for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
tree current;
ctxp = cur_ctxp;