diff options
author | Andrew Haley <aph@redhat.com> | 2004-01-09 17:08:44 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2004-01-09 17:08:44 +0000 |
commit | 85194ee94ae7aea48bf25631aeba8b89f0f0d7d8 (patch) | |
tree | 98aa4fb08cdfb195718477b393ddac9e38551240 /gcc/java/decl.c | |
parent | 900a35c82b8dd470433ac7b52e3187b05b7988c9 (diff) | |
download | gcc-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/decl.c')
-rw-r--r-- | gcc/java/decl.c | 105 |
1 files changed, 33 insertions, 72 deletions
diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 46bb224..1ce2ad3 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1,6 +1,6 @@ /* Process declarations and variables 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. @@ -64,10 +64,6 @@ tree java_lang_cloneable_identifier_node; /* Name of the Serializable class. */ tree java_io_serializable_identifier_node; -/* Set to nonzero value in order to emit class initialization code - before static field references. */ -extern int always_initialize_class_p; - /* The DECL_MAP is a mapping from (index, type) to a decl node. If index < max_locals, it is the index of a local variable. if index >= max_locals, then index-max_locals is a stack slot. @@ -389,6 +385,13 @@ create_primitive_vtable (const char *name) return r; } +static tree +do_nothing (tree t) +{ + return t; +} + + void java_init_decl_processing (void) { @@ -538,6 +541,28 @@ java_init_decl_processing (void) float_array_vtable = create_primitive_vtable ("float"); double_array_vtable = create_primitive_vtable ("double"); + one_elt_array_domain_type = build_index_type (integer_one_node); + utf8const_type = make_node (RECORD_TYPE); + PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node); + PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node); + FINISH_RECORD (utf8const_type); + utf8const_ptr_type = build_pointer_type (utf8const_type); + + atable_type = build_array_type (ptr_type_node, + one_elt_array_domain_type); + TYPE_NONALIASED_COMPONENT (atable_type) = 1; + atable_ptr_type = build_pointer_type (atable_type); + + symbol_type = make_node (RECORD_TYPE); + PUSH_FIELD (symbol_type, field, "clname", utf8const_ptr_type); + PUSH_FIELD (symbol_type, field, "name", utf8const_ptr_type); + PUSH_FIELD (symbol_type, field, "signature", utf8const_ptr_type); + FINISH_RECORD (symbol_type); + + symbols_array_type = build_array_type (symbol_type, + one_elt_array_domain_type); + symbols_array_ptr_type = build_pointer_type (symbols_array_type); + /* As you're adding items here, please update the code right after this section, so that the filename containing the source code of the pre-defined class gets registered correctly. */ @@ -595,12 +620,6 @@ java_init_decl_processing (void) /* for lack of a better place to put this stub call */ init_expr_processing(); - utf8const_type = make_node (RECORD_TYPE); - PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node); - PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node); - FINISH_RECORD (utf8const_type); - utf8const_ptr_type = build_pointer_type (utf8const_type); - constants_type_node = make_node (RECORD_TYPE); PUSH_FIELD (constants_type_node, field, "size", unsigned_int_type_node); PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node); @@ -613,69 +632,10 @@ java_init_decl_processing (void) dtable_type = make_node (RECORD_TYPE); dtable_ptr_type = build_pointer_type (dtable_type); - one_elt_array_domain_type = build_index_type (integer_one_node); otable_type = build_array_type (integer_type_node, one_elt_array_domain_type); TYPE_NONALIASED_COMPONENT (otable_type) = 1; otable_ptr_type = build_pointer_type (otable_type); - atable_type = build_array_type (ptr_type_node, - one_elt_array_domain_type); - TYPE_NONALIASED_COMPONENT (atable_type) = 1; - atable_ptr_type = build_pointer_type (atable_type); - - symbol_type = make_node (RECORD_TYPE); - PUSH_FIELD (symbol_type, field, "clname", utf8const_ptr_type); - PUSH_FIELD (symbol_type, field, "name", utf8const_ptr_type); - PUSH_FIELD (symbol_type, field, "signature", utf8const_ptr_type); - FINISH_RECORD (symbol_type); - - symbols_array_type = build_array_type (symbol_type, - one_elt_array_domain_type); - symbols_array_ptr_type = build_pointer_type (symbols_array_type); - - if (flag_indirect_dispatch) - { - otable_decl = build_decl (VAR_DECL, get_identifier ("otable"), otable_type); - DECL_EXTERNAL (otable_decl) = 1; - TREE_STATIC (otable_decl) = 1; - TREE_READONLY (otable_decl) = 1; - TREE_CONSTANT (otable_decl) = 1; - pushdecl (otable_decl); - otable_syms_decl = build_decl (VAR_DECL, get_identifier ("otable_syms"), - symbols_array_type); - TREE_STATIC (otable_syms_decl) = 1; - TREE_CONSTANT (otable_syms_decl) = 1; - pushdecl (otable_syms_decl); - - atable_decl = build_decl (VAR_DECL, get_identifier ("atable"), atable_type); - DECL_EXTERNAL (atable_decl) = 1; - TREE_STATIC (atable_decl) = 1; - TREE_READONLY (atable_decl) = 1; - TREE_CONSTANT (atable_decl) = 1; - pushdecl (atable_decl); - atable_syms_decl = build_decl (VAR_DECL, get_identifier ("atable_syms"), - symbols_array_type); - TREE_STATIC (atable_syms_decl) = 1; - TREE_CONSTANT (atable_syms_decl) = 1; - pushdecl (atable_syms_decl); - } - - { - tree catch_class_type = make_node (RECORD_TYPE); - PUSH_FIELD (catch_class_type, field, "address", utf8const_ptr_type); - PUSH_FIELD (catch_class_type, field, "classname", ptr_type_node); - FINISH_RECORD (catch_class_type); - - ctable_decl - = build_decl (VAR_DECL, get_identifier ("catch_classes"), - build_array_type - (catch_class_type, 0)); - DECL_EXTERNAL (ctable_decl) = 1; - TREE_STATIC (ctable_decl) = 1; - TREE_READONLY (ctable_decl) = 1; - TREE_CONSTANT (ctable_decl) = 1; - pushdecl (ctable_decl); - } PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type); /* This isn't exactly true, but it is what we have in the source. @@ -945,12 +905,12 @@ java_init_decl_processing (void) eh_personality_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS ? "__gcj_personality_sj0" : "__gcj_personality_v0"); - lang_eh_runtime_type = prepare_eh_table_type; + + lang_eh_runtime_type = do_nothing; init_jcf_parse (); initialize_builtins (); - soft_fmod_node = built_in_decls[BUILT_IN_FMOD]; #if 0 soft_fmodf_node = built_in_decls[BUILT_IN_FMODF]; @@ -1860,6 +1820,7 @@ java_expand_body (tree fndecl) current_function_decl = fndecl; input_location = DECL_SOURCE_LOCATION (fndecl); + output_class = DECL_CONTEXT (current_function_decl); current_class = DECL_CONTEXT (fndecl); timevar_push (TV_EXPAND); |