diff options
author | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-09 17:08:44 +0000 |
---|---|---|
committer | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-09 17:08:44 +0000 |
commit | 757f6c6c12a8ce0b42a6ac1f27df9c99da15947d (patch) | |
tree | 98aa4fb08cdfb195718477b393ddac9e38551240 /gcc/java/except.c | |
parent | 843505b2f08e637f8089132b4d8c4aad513f6b8f (diff) | |
download | gcc-757f6c6c12a8ce0b42a6ac1f27df9c99da15947d.tar.gz |
2004-01-09 Andrew Haley <aph@redhat.com>
PR java/12755:
* parse.y (java_fix_constructors): Set output_class.
(java_reorder_fields): Likewise.
(java_layout_classes): Likewise.
(java_expand_classes): Generate indirect dispatch tables.
(java_expand_classes): Set output_class.
(java_finish_classes): Likewise.
* lang.c (java_init): Turn on always_initialize_class_p if we're
using indirect dis[atch.
(java_decl_ok_for_sibcall): Use output_class, not current_class.
(java_get_callee_fndecl): Use class local atable.
* jcf-parse.c
(always_initialize_class_p): Decl moved to java-tree.h.
(HANDLE_CLASS_INFO): Set output_class.
(read_class): Likewise.
(parse_class_file): Call gen_indirect_dispatch_tables.
(parse_zip_file_entries): Set output_class.
(java_parse_file): Set output_class. Don't emit symbol tables.
* java-tree.h (output_class): New.
Remove global declarations for otable, atable, and ctable.
(always_initialize_class_p): moved here from decl.c.
(DECL_OWNER): New.
(TYPE_ATABLE_METHODS, TYPE_ATABLE_SYMS_DECL, TYPE_ATABLE_DECL,
TYPE_OTABLE_METHODS, TYPE_OTABLE_SYMS_DECL, TYPE_OTABLE_DECL,
TYPE_CTABLE_DECL, TYPE_CATCH_CLASSES): New.
(struct lang_type): Add otable_methods, otable_decl,
otable_syms_decl, atable_methods, atable_decl, atable_syms_decl,
ctable_decl, catch_classes, type_to_runtime_map.
* expr.c (build_field_ref): Make otable, atable, and ctable class
local rather than global.
(build_known_method_ref): Likewise.
(build_invokeinterface): Likewise.
(java_expand_expr): Pass runtime type (rather than actual type) to
expand_start_catch.
* except.c (prepare_eh_table_type): Create TYPE_TO_RUNTIME_MAP for
this class. Look up each class in that map to delete duplicates.
(expand_end_java_handler): Pass runtime type (rather than actual
type) to expand_start_catch.
* decl.c: (always_initialize_class_p): Decl moved to java-tree.h.
(do_nothing): New.
(java_init_decl_processing): Rearrange things. Remove global
declarations of otable, atable, and ctable.
(java_init_decl_processing): Make lang_eh_runtime_type do_nothing.
(java_expand_body): Set output_class.
* constants.c (build_constant_data_ref): Use output_class, not
current_class.
(alloc_name_constant): Likewise.
* class.c (gen_indirect_dispatch_tables): New.
(build_class_ref): Generate hard reference to superclass, even if
using indirect dispatch.
(build_static_field_ref): Use class local atable.
(make_class_data): Generate hard reference to superclass, even if
using indirect dispatch.
Generate symbolic references to interfaces when using indirect
dispatch.
(make_class_data): Emit otable, atable, and ctable.
Make otable, atable, and ctable class local rather than global.
(emit_catch_table): Make otable, atable, and ctable class local
rather than global.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75590 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/except.c')
-rw-r--r-- | gcc/java/except.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/gcc/java/except.c b/gcc/java/except.c index c0fa800c262..c5c7dcf27f4 100644 --- a/gcc/java/except.c +++ b/gcc/java/except.c @@ -1,5 +1,5 @@ /* Handle exceptions for GNU compiler for the Java(TM) language. - Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003 + Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GCC. @@ -312,6 +312,7 @@ tree prepare_eh_table_type (tree type) { tree exp; + tree *slot; const char *name; char *buf; tree decl; @@ -324,8 +325,16 @@ prepare_eh_table_type (tree type) * rewritten to point to the appropriate class. */ if (type == NULL_TREE) - exp = NULL_TREE; - else if (is_compiled_class (type) && !flag_indirect_dispatch) + return NULL_TREE; + + if (TYPE_TO_RUNTIME_MAP (output_class) == NULL) + TYPE_TO_RUNTIME_MAP (output_class) = java_treetreehash_create (10, 1); + + slot = java_treetreehash_new (TYPE_TO_RUNTIME_MAP (output_class), type); + if (*slot != NULL) + return TREE_VALUE (*slot); + + if (is_compiled_class (type) && !flag_indirect_dispatch) { name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); buf = alloca (strlen (name) + 5); @@ -339,8 +348,6 @@ prepare_eh_table_type (tree type) DECL_INITIAL (decl) = build_class_ref (type); layout_decl (decl, 0); pushdecl (decl); - rest_of_decl_compilation (decl, (char*) 0, global_bindings_p (), 0); - make_decl_rtl (decl, (char*) 0); exp = build1 (ADDR_EXPR, ptr_type_node, decl); } else @@ -357,14 +364,37 @@ prepare_eh_table_type (tree type) TREE_THIS_VOLATILE (decl) = 0; layout_decl (decl, 0); pushdecl (decl); - rest_of_decl_compilation (decl, (char*) 0, global_bindings_p (), 0); - make_decl_rtl (decl, (char*) 0); exp = build1 (ADDR_EXPR, build_pointer_type (utf8const_ptr_type), decl); - catch_classes = tree_cons (NULL, make_catch_class_record (exp, utf8_ref), catch_classes); + TYPE_CATCH_CLASSES (output_class) = + tree_cons (NULL, make_catch_class_record (exp, utf8_ref), + TYPE_CATCH_CLASSES (output_class)); } + + *slot = tree_cons (type, exp, NULL_TREE); + return exp; } +static int +expand_catch_class (void **entry, void *x ATTRIBUTE_UNUSED) +{ + struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry; + tree decl = TREE_OPERAND (TREE_VALUE ((tree)ite->value), 0); + rest_of_decl_compilation (decl, (char*) 0, global_bindings_p (), 0); + return true; +} + +/* For every class in the TYPE_TO_RUNTIME_MAP, expand the + corresponding object that is used by the runtime type matcher. */ + +void +java_expand_catch_classes (tree this_class) +{ + if (TYPE_TO_RUNTIME_MAP (this_class)) + htab_traverse + (TYPE_TO_RUNTIME_MAP (this_class), + expand_catch_class, NULL); +} /* Build a reference to the jthrowable object being carried in the exception header. */ @@ -404,7 +434,7 @@ expand_end_java_handler (struct eh_range *range) if (type == NULL) type = throwable_type_node; - expand_start_catch (type); + expand_start_catch (prepare_eh_table_type (type)); expand_goto (TREE_VALUE (handler)); expand_end_catch (); } |