aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2004-01-09 17:08:44 +0000
committerAndrew Haley <aph@gcc.gnu.org>2004-01-09 17:08:44 +0000
commit85194ee94ae7aea48bf25631aeba8b89f0f0d7d8 (patch)
tree98aa4fb08cdfb195718477b393ddac9e38551240 /gcc/java/expr.c
parent900a35c82b8dd470433ac7b52e3187b05b7988c9 (diff)
downloadgcc-85194ee94ae7aea48bf25631aeba8b89f0f0d7d8.zip
gcc-85194ee94ae7aea48bf25631aeba8b89f0f0d7d8.tar.gz
gcc-85194ee94ae7aea48bf25631aeba8b89f0f0d7d8.tar.bz2
re PR java/12755 (Binary Compatibility: Resolving static methods and classes is not thread safe)
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. From-SVN: r75590
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 533b88c..82c110b 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -1,5 +1,5 @@
/* Process expressions for the GNU compiler for the Java(TM) language.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GCC.
@@ -1511,17 +1511,18 @@ build_field_ref (tree self_value, tree self_class, tree name)
if (base_type != TREE_TYPE (self_value))
self_value = fold (build1 (NOP_EXPR, base_type, self_value));
if (flag_indirect_dispatch
- && current_class != self_class)
- /* FIXME: current_class != self_class is not exactly the right
+ && output_class != self_class)
+ /* FIXME: output_class != self_class is not exactly the right
test. What we really want to know is whether self_class is
- in the same translation unit as current_class. If it is,
+ in the same translation unit as output_class. If it is,
we can make a direct reference. */
{
- tree otable_index
- = build_int_2
- (get_symbol_table_index (field_decl, &otable_methods), 0);
- tree field_offset = build (ARRAY_REF, integer_type_node, otable_decl,
- otable_index);
+ tree otable_index =
+ build_int_2 (get_symbol_table_index
+ (field_decl, &TYPE_OTABLE_METHODS (output_class)), 0);
+ tree field_offset =
+ build (ARRAY_REF, integer_type_node, TYPE_OTABLE_DECL (output_class),
+ otable_index);
tree address
= fold (build (PLUS_EXPR,
build_pointer_type (TREE_TYPE (field_decl)),
@@ -1771,10 +1772,12 @@ build_known_method_ref (tree method, tree method_type ATTRIBUTE_UNUSED,
}
else
{
- tree table_index = build_int_2 (get_symbol_table_index
- (method, &atable_methods), 0);
- func = build (ARRAY_REF, method_ptr_type_node, atable_decl,
- table_index);
+ tree table_index =
+ build_int_2 (get_symbol_table_index
+ (method, &TYPE_ATABLE_METHODS (output_class)), 0);
+ func =
+ build (ARRAY_REF, method_ptr_type_node,
+ TYPE_ATABLE_DECL (output_class), table_index);
}
}
else
@@ -1893,8 +1896,10 @@ build_invokevirtual (tree dtable, tree method)
if (flag_indirect_dispatch)
{
otable_index
- = build_int_2 (get_symbol_table_index (method, &otable_methods), 0);
- method_index = build (ARRAY_REF, integer_type_node, otable_decl,
+ = build_int_2 (get_symbol_table_index
+ (method, &TYPE_OTABLE_METHODS (output_class)), 0);
+ method_index = build (ARRAY_REF, integer_type_node,
+ TYPE_OTABLE_DECL (output_class),
otable_index);
}
else
@@ -1957,9 +1962,12 @@ build_invokeinterface (tree dtable, tree method)
if (flag_indirect_dispatch)
{
- otable_index
- = build_int_2 (get_symbol_table_index (method, &otable_methods), 0);
- idx = build (ARRAY_REF, integer_type_node, otable_decl, otable_index);
+ otable_index =
+ build_int_2 (get_symbol_table_index
+ (method, &TYPE_OTABLE_METHODS (output_class)), 0);
+ idx =
+ build (ARRAY_REF, integer_type_node, TYPE_OTABLE_DECL (output_class),
+ otable_index);
}
else
{
@@ -2605,7 +2613,7 @@ java_expand_expr (tree exp, rtx target, enum machine_mode tmode,
tree decl = BLOCK_EXPR_DECLS (catch);
tree type = (decl ? TREE_TYPE (TREE_TYPE (decl)) : NULL_TREE);
- expand_start_catch (type);
+ expand_start_catch (prepare_eh_table_type (type));
expand_expr_stmt (TREE_OPERAND (current, 0));
expand_end_catch ();
}