This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: RFA: fix PR java/21722
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 02 Jun 2005 09:00:31 -0600
- Subject: Patch: RFA: fix PR java/21722
- Reply-to: tromey at redhat dot com
This patch fixes PR java/21722.
First, the bug only applies with -findirect-dispatch. The bug is that
if we see a constant when compiling a class, and the constant comes
from another class we are also compiling in the same invocation, then
we end up generating a "real" field reference, and not a reference via
the atable. This is wrong as all references must go via the atable.
This fix simply disables this approach when compiling from class files
and using indirect dispatch.
I didn't change the indirect-dispatch-but-compiling-from-.java case,
because in that case (when it works) we will still be required to
inline constant fields. (The language restrictions about inlining
constants don't apply in the .class file case, and one could argue
that inlining here would actually be wrong... as if inlining was
meant, the class file would have simply contained a constant pool
ref.)
BTW I don't understand why the "constant" case here returns the field
and not its DECL_INITIAL.
I tested this against our test suite on x86 FC2. I also rebuilt
Eclipse and ran a smoke test without problems. Ok?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/21722:
* class.c (build_static_field_ref): Don't fold constant fields if
current class is from a .class file and we're using indirect
dispatch.
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.230
diff -u -r1.230 class.c
--- class.c 25 May 2005 22:08:27 -0000 1.230
+++ class.c 2 Jun 2005 14:52:06 -0000
@@ -1068,19 +1068,18 @@
{
tree fclass = DECL_CONTEXT (fdecl);
int is_compiled = is_compiled_class (fclass);
+ int from_class = ! CLASS_FROM_SOURCE_P (current_class);
/* Allow static final fields to fold to a constant. When using
- -fno-assume-compiled, gcj will sometimes try to fold a field from
- an uncompiled class. This is required when the field in question
- meets the appropriate criteria for a compile-time constant.
- However, currently sometimes gcj is too eager and will end up
- returning the field itself, leading to an incorrect external
- reference being generated. */
- if ((is_compiled && !flag_indirect_dispatch)
- || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE
- && (JSTRING_TYPE_P (TREE_TYPE (fdecl))
- || JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
- && TREE_CONSTANT (DECL_INITIAL (fdecl))))
+ -findirect-dispatch, we simply never do this folding if compiling
+ from .class; in the .class file constants will be referred to via
+ the constant pool. */
+ if ((!flag_indirect_dispatch || !from_class)
+ && (is_compiled
+ || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE
+ && (JSTRING_TYPE_P (TREE_TYPE (fdecl))
+ || JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
+ && TREE_CONSTANT (DECL_INITIAL (fdecl)))))
{
if (is_compiled == 1)
DECL_EXTERNAL (fdecl) = 1;