From 85194ee94ae7aea48bf25631aeba8b89f0f0d7d8 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Fri, 9 Jan 2004 17:08:44 +0000 Subject: re PR java/12755 (Binary Compatibility: Resolving static methods and classes is not thread safe) 2004-01-09 Andrew Haley 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 --- gcc/java/parse.y | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'gcc/java/parse.y') diff --git a/gcc/java/parse.y b/gcc/java/parse.y index c8b4596..20e6f9a 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -1,6 +1,6 @@ /* Source code parsing and tree node generation for the GNU compiler for the Java(TM) language. - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com) @@ -5451,7 +5451,7 @@ java_fix_constructors (void) if (CLASS_INTERFACE (TYPE_NAME (class_type))) continue; - current_class = class_type; + output_class = current_class = class_type; for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl)) { if (DECL_CONSTRUCTOR_P (decl)) @@ -7575,7 +7575,7 @@ java_reorder_fields (void) for (current = gclass_list; current; current = TREE_CHAIN (current)) { - current_class = TREE_TYPE (TREE_VALUE (current)); + output_class = current_class = TREE_TYPE (TREE_VALUE (current)); if (current_class == stop_reordering) break; @@ -7632,7 +7632,7 @@ java_layout_classes (void) for (current = gclass_list; current; current = TREE_CHAIN (current)) { - current_class = TREE_TYPE (TREE_VALUE (current)); + output_class = current_class = TREE_TYPE (TREE_VALUE (current)); layout_class (current_class); /* Error reported by the caller */ @@ -7696,7 +7696,7 @@ java_complete_expand_methods (tree class_decl) { tree clinit, decl, first_decl; - current_class = TREE_TYPE (class_decl); + output_class = current_class = TREE_TYPE (class_decl); /* Pre-expand to figure whether we really need it or not. If we do need it, we pre-expand the static fields so they're @@ -9017,6 +9017,15 @@ java_expand_classes (void) for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next) { + tree current; + for (current = cur_ctxp->class_list; + current; + current = TREE_CHAIN (current)) + gen_indirect_dispatch_tables (TREE_TYPE (current)); + } + + for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next) + { ctxp = cur_ctxp; input_filename = ctxp->filename; lang_init_source (2); /* Error msgs have method prototypes */ @@ -9025,7 +9034,6 @@ java_expand_classes (void) } input_filename = main_input_filename; - /* Find anonymous classes and expand their constructor. This extra pass is necessary because the constructor itself is only generated when the method in which it is defined is expanded. */ @@ -9035,7 +9043,7 @@ java_expand_classes (void) ctxp = cur_ctxp; for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) { - current_class = TREE_TYPE (current); + output_class = current_class = TREE_TYPE (current); if (ANONYMOUS_CLASS_P (current_class)) { tree d; @@ -9063,7 +9071,7 @@ java_expand_classes (void) for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) { tree d; - current_class = TREE_TYPE (current); + output_class = current_class = TREE_TYPE (current); for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d)) { if (DECL_RESULT (d) == NULL_TREE) @@ -9094,7 +9102,7 @@ java_expand_classes (void) for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) { tree d; - current_class = TREE_TYPE (current); + output_class = current_class = TREE_TYPE (current); for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d)) { if (DECL_RESULT (d) == NULL_TREE) @@ -9159,7 +9167,7 @@ java_expand_classes (void) current; current = TREE_CHAIN (current)) { - current_class = TREE_TYPE (TREE_VALUE (current)); + output_class = current_class = TREE_TYPE (TREE_VALUE (current)); if (flag_emit_class_files) write_classfile (current_class); if (flag_emit_xref) @@ -9180,7 +9188,7 @@ java_finish_classes (void) ctxp = cur_ctxp; for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) { - current_class = TREE_TYPE (current); + output_class = current_class = TREE_TYPE (current); finish_class (); } } -- cgit v1.1