diff options
author | Andrew Haley <aph@redhat.com> | 2003-10-24 09:29:43 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2003-10-24 09:29:43 +0000 |
commit | 904715853c40f9a27b492794a6db817ea89a553a (patch) | |
tree | 8c726fb42c811bb6652ba1a759bae78c2c8d9378 /gcc/java/lang.c | |
parent | c769a35d59f282465c1a344617bf04d595e8c477 (diff) | |
download | gcc-904715853c40f9a27b492794a6db817ea89a553a.zip gcc-904715853c40f9a27b492794a6db817ea89a553a.tar.gz gcc-904715853c40f9a27b492794a6db817ea89a553a.tar.bz2 |
lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New.
2003-10-22 Andrew Haley <aph@redhat.com>
* lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New.
(java_get_callee_fndecl): New.
* jcf-parse.c (java_parse_file): Call emit_catch_table().
* java-tree.h (ctable_decl): New.
(catch_classes): New.
(java_tree_index): Add JTI_CTABLE_DECL, JTI_CATCH_CLASSES.
* decl.c (java_init_decl_processing): Add catch_class_type.
Add ctable_decl.
Add catch_classes field.
* class.c (build_indirect_class_ref): Break out from
build_class_ref.
(make_field_value): Check flag_indirect_dispatch.
(make_class_data): Ditto.
Tidy uses of PUSH_FIELD_VALUE.
Add field catch_classes.
(make_catch_class_record): New.
* java-tree.h (PUSH_FIELD_VALUE): Tidy.
2003-10-22 Andrew Haley <aph@redhat.com>
* java/lang/natClass.cc (initializeClass): Call
_Jv_linkExceptionClassTable.
(_Jv_LinkSymbolTable): Call )_Jv_ThrowNoSuchMethodError. Call
_Jv_Defer_Resolution on a method whose ncode is NULL.
(_Jv_linkExceptionClassTable): New function.
(_Jv_LayoutVTableMethods): If superclass looks like a constant pool
entry, look it up.
* java/lang/Class.h (struct _Jv_CatchClass): New.
(_Jv_linkExceptionClassTable): New friend.
(_Jv_Defer_Resolution): New friend.
(class Class.catch_classes): New field.
* include/java-interp.h (Jv_Defer_Resolution): New method.
(_Jv_PrepareClass): Make a friend of _Jv_MethodBase.
(_Jv_MethodBase.deferred): New field.
(_Jv_Defer_Resolution): New function.
* resolve.cc (_Jv_PrepareClass): Resolve deferred handlers.
* exception.cc (get_ttype_entry): Change return type to void**.
(PERSONALITY_FUNCTION): Remove all code related to using a
Utf8Const* for a match type. Change match type to be a pointer to
a pointer, rather than a pointer to a Class.
* defineclass.cc (handleCodeAttribute): Initialize
method->deferred.
(handleMethodsEnd): Likewise.
From-SVN: r72886
Diffstat (limited to 'gcc/java/lang.c')
-rw-r--r-- | gcc/java/lang.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/java/lang.c b/gcc/java/lang.c index ee476b2..615d250 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -68,6 +68,7 @@ static void dump_compound_expr (dump_info_p, tree); static bool java_decl_ok_for_sibcall (tree); static int java_estimate_num_insns (tree); static int java_start_inlining (tree); +static tree java_get_callee_fndecl (tree); #ifndef TARGET_OBJECT_SUFFIX # define TARGET_OBJECT_SUFFIX ".o" @@ -263,6 +264,9 @@ struct language_function GTY(()) #undef LANG_HOOKS_DECL_OK_FOR_SIBCALL #define LANG_HOOKS_DECL_OK_FOR_SIBCALL java_decl_ok_for_sibcall +#undef LANG_HOOKS_GET_CALLEE_FNDECL +#define LANG_HOOKS_GET_CALLEE_FNDECL java_get_callee_fndecl + #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION java_expand_body @@ -1205,4 +1209,45 @@ java_start_inlining (tree fn) return TREE_ASM_WRITTEN (fn) ? 1 : 0; } +/* Given a call_expr, try to figure out what its target might be. In + the case of an indirection via the atable, search for the decl. If + the decl is external, we return NULL. If we don't, the optimizer + will replace the indirection with a direct call, which undoes the + purpose of the atable indirection. */ +static tree +java_get_callee_fndecl (tree call_expr) +{ + tree method, table, element; + + HOST_WIDE_INT index; + + if (TREE_CODE (call_expr) != CALL_EXPR) + return NULL; + method = TREE_OPERAND (call_expr, 0); + STRIP_NOPS (method); + if (TREE_CODE (method) != ARRAY_REF) + return NULL; + table = TREE_OPERAND (method, 0); + if (table != atable_decl) + return NULL; + index = TREE_INT_CST_LOW (TREE_OPERAND (method, 1)); + + /* FIXME: Replace this for loop with a hash table lookup. */ + for (element = atable_methods; element; element = TREE_CHAIN (element)) + { + if (index == 1) + { + tree purpose = TREE_PURPOSE (element); + if (TREE_CODE (purpose) == FUNCTION_DECL + && ! DECL_EXTERNAL (purpose)) + return purpose; + else + return NULL; + } + --index; + } + + return NULL; +} + #include "gt-java-lang.h" |