This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: Fix MIPS wrong code regression for java front-end.
- From: David Daney <ddaney at avtrex dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, Java Patch List <java-patches at gcc dot gnu dot org>, 'Andrew Haley' <aph at redhat dot com>
- Date: Thu, 01 Feb 2007 12:40:09 -0800
- Subject: Re: Patch: Fix MIPS wrong code regression for java front-end.
- References: <45C24F80.1020608@avtrex.com>
Drat! I forgot the actual patch.
Here it is.
David Daney wrote:
The java front-end is setting DECL_EXTERNAL properly for some
symbols. This causes the MIPS back-end to generate incorrect function
call code for the effected symbols. According to the comments in:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30606
It seems that hpux is experiancing the same problem.
As noted in: http://gcc.gnu.org/ml/gcc/2007-02/msg00016.html
<quote>
The bad code was in class.c when green committed it over 8 years ago.
Several months ago Tromey removed it and then added it back a few days
later.
The problem is that in is_compiled_class() we were erroneously saying
that a candidate class was being emitted to the object file *if* it
was the current_class being parsed. This does not hold because many
classes are parsed that are not emitted so that jc1 can calculate the
class layout and load the symbol tables.
The real fix,I think, is the one I made to is_compiled_class(). I
left the change to layout_class_method() where we don't re-check for
DECL_EXTERNAL if it is already set as a micro-optimization. I tested
both with and without this and obtained correct results, so it is not
really needed.
</quote>
This fixes at least some of the MIPS regressions caused by the
gcj-eclipse merge, also tested with a bootstrap of c,c++,java on
x86_64-pc-linux-gnu with no regressions.
OK for the trunk?
gcc/java:
2007-02-01 David Daney <ddaney@avtrex.com>
* class.c (is_compiled_class): Move check to avoid reloading
current class.
(layout_class_method): Don't calculate DECL_EXTERNAL if it is
already set.
Index: gcc/java/class.c
===================================================================
--- gcc/java/class.c (revision 121441)
+++ gcc/java/class.c (working copy)
@@ -2134,10 +2134,6 @@ is_compiled_class (tree class)
return 1;
if (TYPE_ARRAY_P (class))
return 0;
- /* We have to check this explicitly to avoid trying to load a class
- that we're currently parsing. */
- if (class == current_class)
- return 2;
seen_in_zip = (TYPE_JCF (class) && JCF_SEEN_IN_ZIP (TYPE_JCF (class)));
if (CLASS_FROM_CURRENTLY_COMPILED_P (class))
@@ -2147,7 +2143,7 @@ is_compiled_class (tree class)
been loaded already. Load it if necessary. This prevent
build_class_ref () from crashing. */
- if (seen_in_zip && !CLASS_LOADED_P (class))
+ if (seen_in_zip && !CLASS_LOADED_P (class) && (class != current_class))
load_class (class, 1);
/* We return 2 for class seen in ZIP and class from files
@@ -2161,7 +2157,7 @@ is_compiled_class (tree class)
{
if (CLASS_FROM_SOURCE_P (class))
safe_layout_class (class);
- else
+ else if (class != current_class)
load_class (class, 1);
}
return 1;
@@ -2510,10 +2506,12 @@ layout_class_method (tree this_class, tr
tree method_name = DECL_NAME (method_decl);
TREE_PUBLIC (method_decl) = 1;
+
/* Considered external unless it is being compiled into this object
- file. */
- DECL_EXTERNAL (method_decl) = ((is_compiled_class (this_class) != 2)
- || METHOD_NATIVE (method_decl));
+ file, or it was already flagged as external. */
+ if (!DECL_EXTERNAL (method_decl))
+ DECL_EXTERNAL (method_decl) = ((is_compiled_class (this_class) != 2)
+ || METHOD_NATIVE (method_decl));
if (ID_INIT_P (method_name))
{