This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch: FYI: qualifying type in bytecode output
- 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: 15 Mar 2006 16:59:59 -0700
- Subject: Patch: FYI: qualifying type in bytecode output
- Reply-to: tromey at redhat dot com
I'm checking this in on the trunk.
While looking into PR 26390, I noticed that we weren't emitting the
proper qualifying type for a method call in our bytecode output. The
rule is that we must use the real qualifying type (not the method's
declaring type), unless the method is declared in Object.
This patch implements this behavior. This yields one jacks
improvement.
Tom
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
* jcf-write.c (generate_bytecode_insns): Use qualifying type for
non-static method calls.
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
* testsuite/libjava.jacks/jacks.xfail: Removed
13.1-runtime-method-5.
Index: gcc/java/jcf-write.c
===================================================================
--- gcc/java/jcf-write.c (revision 111942)
+++ gcc/java/jcf-write.c (working copy)
@@ -1,5 +1,5 @@
/* Write out a Java(TM) class file.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GCC.
@@ -2610,26 +2610,36 @@
tree context = DECL_CONTEXT (f);
int index, interface = 0;
RESERVE (5);
+
+ /* If the method is not static, use the qualifying type.
+ However, don't use the qualifying type if the method
+ was declared in Object. */
+ if (! METHOD_STATIC (f)
+ && ! DECL_CONSTRUCTOR_P (f)
+ && ! METHOD_PRIVATE (f)
+ && DECL_CONTEXT (f) != object_type_node)
+ {
+ tree arg1 = TREE_VALUE (TREE_OPERAND (exp, 1));
+ context = TREE_TYPE (TREE_TYPE (arg1));
+ }
+
if (METHOD_STATIC (f))
OP1 (OPCODE_invokestatic);
else if (DECL_CONSTRUCTOR_P (f) || CALL_USING_SUPER (exp)
- || METHOD_PRIVATE (f))
+ || METHOD_PRIVATE (f))
OP1 (OPCODE_invokespecial);
else
{
if (CLASS_INTERFACE (TYPE_NAME (context)))
- {
- tree arg1 = TREE_VALUE (TREE_OPERAND (exp, 1));
- context = TREE_TYPE (TREE_TYPE (arg1));
- if (CLASS_INTERFACE (TYPE_NAME (context)))
- interface = 1;
- }
+ interface = 1;
if (interface)
OP1 (OPCODE_invokeinterface);
else
OP1 (OPCODE_invokevirtual);
}
- index = find_methodref_with_class_index (&state->cpool, f, context);
+
+ index = find_methodref_with_class_index (&state->cpool, f,
+ context);
OP2 (index);
if (interface)
{
Index: libjava/testsuite/libjava.jacks/jacks.xfail
===================================================================
--- libjava/testsuite/libjava.jacks/jacks.xfail (revision 111948)
+++ libjava/testsuite/libjava.jacks/jacks.xfail (working copy)
@@ -5,7 +5,6 @@
13.1-runtime-constant-1
13.1-runtime-constant-3
13.1-runtime-field-1
-13.1-runtime-method-5
13.1-runtime-method-6
13.4.8-constant-runtime-1
13.4.8-constant-runtime-2