This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: recent regression
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: Ranjit Mathew <rmathew at gmail dot com>
- Cc: Andrew Haley <aph at redhat dot com>, java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 25 Jun 2004 17:37:58 -0400
- Subject: Re: recent regression
- References: <87y8mcol88.fsf@fleche.redhat.com> <40DBC43C.10903@gmail.com> <16603.56888.230716.359472@cuddles.cambridge.redhat.com> <39399b9d04062502026cf7bba2@mail.gmail.com> <16603.60059.360817.29284@cuddles.cambridge.redhat.com> <40DC475C.7060608@redhat.com> <39399b9d04062509517c41324@mail.gmail.com>
Ranjit Mathew wrote:
Would it not it be better to simply avoid calling read_class in the
CLASS_FROM_SOURCE_P case? If you have a type decl for a class and
CLASS_FROM_SOURCE_P is true, then (afaik) it must by definition be
already loaded and been/being parsed. How about the following patch instead:
[...]
This would also allow us to get rid of many of the CLASS_FROM_SOURCE_P
checks scattered around parse.y.
Yes, this is much better. As I mention elsewhere though, we ought
to really clarify what we mean by a "loaded" class. (i.e. load_class()
v/s CLASS_LOADED_P().)
Will you be fleshing this out a bit more to remove the redundant
checks you mention?
Also, if this is the way forward, then you should remove the
comment at the top of load_class() where the author intends
to ask clients to call read_class() directly.
Agreed. Here's a complete patch with redundant CLASS_FROM_SOURCE_P's
removed. I've run this through the testsuite (no regressions), and also
built parts of RHUG against it. It seems to fix PR 16768 as well.
OK to commit?
Bryce
2004-06-25 Bryce McKinlay <mckinlay@redhat.com>
Ranjit Mathew <rmathew@hotmail.com>
PR java/1207
* jcf-parse.c (load_class): Return immediately if passed a type decl
where CLASS_FROM_SOURCE_P is set. Remove FIXME.
* parse.y (do_resolve_class): Remove checks for CLASS_FROM_SOURCE_P
before calling load_class.
(qualify_and_find): Likewise.
(find_in_imports_on_demand): Likewise.
(find_applicable_accessible_methods_list): Likewise.
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.160
diff -u -r1.160 jcf-parse.c
--- jcf-parse.c 17 Jun 2004 13:45:23 -0000 1.160
+++ jcf-parse.c 25 Jun 2004 21:33:35 -0000
@@ -562,10 +562,6 @@
/* Load CLASS_OR_NAME. CLASS_OR_NAME can be a mere identifier if
called from the parser, otherwise it's a RECORD_TYPE node. If
VERBOSE is 1, print error message on failure to load a class. */
-
-/* Replace calls to load_class by having callers call read_class directly
- - and then perhaps rename read_class to load_class. FIXME */
-
void
load_class (tree class_or_name, int verbose)
{
@@ -581,7 +577,12 @@
name = TYPE_NAME (TREE_PURPOSE (class_or_name));
/* Or it's a type in the making */
else
- name = DECL_NAME (TYPE_NAME (class_or_name));
+ {
+ /* If the class is from source code, then it must already be loaded. */
+ if (CLASS_FROM_SOURCE_P (class_or_name))
+ return;
+ name = DECL_NAME (TYPE_NAME (class_or_name));
+ }
saved = name;
while (1)
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.484
diff -u -r1.484 parse.y
--- parse.y 24 Jun 2004 15:56:54 -0000 1.484
+++ parse.y 25 Jun 2004 21:33:40 -0000
@@ -5796,8 +5796,7 @@
/* 2- And check for the type in the current compilation unit */
if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
{
- if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
- !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
+ if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)))
load_class (TYPE_NAME (class_type), 0);
return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
}
@@ -5891,8 +5890,7 @@
load_class (new_qualified, 0);
if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_qualified)))
{
- if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
- !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
+ if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)))
load_class (new_qualified, 0);
TYPE_NAME (class_type) = new_qualified;
return IDENTIFIER_CLASS_VALUE (new_qualified);
@@ -7044,8 +7042,7 @@
access_check = -1;
/* If there is no DECL set for the class or if the class isn't
loaded and not seen in source yet, then load */
- if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
- && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
+ if (!decl || ! CLASS_LOADED_P (TREE_TYPE (decl)))
{
load_class (node, 0);
decl = IDENTIFIER_CLASS_VALUE (node);
@@ -11014,7 +11011,7 @@
search_not_done++;
*htab_find_slot (searched_classes, class, INSERT) = class;
- if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
+ if (!CLASS_LOADED_P (class))
{
load_class (class, 1);
safe_layout_class (class);