diff options
author | Bryce McKinlay <bryce@gcc.gnu.org> | 2004-04-14 18:45:20 +0100 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2004-04-14 18:45:20 +0100 |
commit | d7afe286b32d866128d542bd8a733c4f21bd2206 (patch) | |
tree | b9dbd14f53ce12873b97ef6caeb33b3335f0e3c5 /gcc/java/class.c | |
parent | cd2b7af02951e96f1a436d6b5584267e49259930 (diff) | |
download | gcc-d7afe286b32d866128d542bd8a733c4f21bd2206.zip gcc-d7afe286b32d866128d542bd8a733c4f21bd2206.tar.gz gcc-d7afe286b32d866128d542bd8a733c4f21bd2206.tar.bz2 |
[multiple changes]
2004-04-14 Andrew Haley <aph@redhat.com>
Bryce McKinlay <mckinlay@redhat.com>
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Use
_Jv_LookupInterfaceMethodIdx for calls to interfaces.
* include/jvm.h (_Jv_CallAnyMethodA): Add new face' arg.
* testsuite/libjava.lang/InvokeInterface.java: New file.
* testsuite/libjava.lang/InvokeInterface.out: New file.
2004-04-14 Bryce McKinlay <mckinlay@redhat.com>
* class.c (get_interface_method_index): New function. Return
dispatch index for interface method.
(make_method_value): For interface methods, set index field to
iface dispatch index, not DECL_VINDEX.
* expr.c (build_invokeinterface): Use get_interface_method_index.
From-SVN: r80684
Diffstat (limited to 'gcc/java/class.c')
-rw-r--r-- | gcc/java/class.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc/java/class.c b/gcc/java/class.c index 66bdeb9..3ba60bd 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1246,10 +1246,15 @@ make_method_value (tree mdecl) tree minit; tree index; tree code; + tree class_decl; #define ACC_TRANSLATED 0x4000 int accflags = get_access_flags_from_decl (mdecl) | ACC_TRANSLATED; - - if (!flag_indirect_dispatch && DECL_VINDEX (mdecl) != NULL_TREE) + + class_decl = DECL_CONTEXT (mdecl); + /* For interfaces, the index field contains the dispatch index. */ + if (CLASS_INTERFACE (TYPE_NAME (class_decl))) + index = build_int_2 (get_interface_method_index (mdecl, class_decl), 0); + else if (!flag_indirect_dispatch && DECL_VINDEX (mdecl) != NULL_TREE) index = DECL_VINDEX (mdecl); else index = integer_minus_one_node; @@ -2133,6 +2138,23 @@ layout_class_methods (tree this_class) TYPE_NVIRTUALS (this_class) = dtable_count; } +/* Return the index of METHOD in INTERFACE. This index begins at 1 and is used as an + argument for _Jv_LookupInterfaceMethodIdx(). */ +int +get_interface_method_index (tree method, tree interface) +{ + tree meth; + int i = 1; + + for (meth = TYPE_METHODS (interface); ; meth = TREE_CHAIN (meth), i++) + { + if (meth == method) + return i; + if (meth == NULL_TREE) + abort (); + } +} + /* Lay METHOD_DECL out, returning a possibly new value of DTABLE_COUNT. Also mangle the method's name. */ |