diff options
Diffstat (limited to 'gcc/java/class.c')
-rw-r--r-- | gcc/java/class.c | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/gcc/java/class.c b/gcc/java/class.c index 3e8ae2693d6..68732b74dd5 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -970,10 +970,13 @@ build_class_ref (tree type) DECL_ARTIFICIAL (decl) = 1; if (is_compiled == 1) DECL_EXTERNAL (decl) = 1; - SET_DECL_ASSEMBLER_NAME (decl, - java_mangle_class_field - (&temporary_obstack, type)); - pushdecl_top_level (decl); + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + DECL_CLASS_FIELD_P (decl) = 1; + DECL_CONTEXT (decl) = type; + + /* ??? We want to preserve the DECL_CONTEXT we set just above, + that that means not calling pushdecl_top_level. */ + IDENTIFIER_GLOBAL_VALUE (decl_name) = decl; } } else @@ -1065,19 +1068,18 @@ build_static_field_ref (tree fdecl) { tree fclass = DECL_CONTEXT (fdecl); int is_compiled = is_compiled_class (fclass); + int from_class = ! CLASS_FROM_SOURCE_P (current_class); /* Allow static final fields to fold to a constant. When using - -fno-assume-compiled, gcj will sometimes try to fold a field from - an uncompiled class. This is required when the field in question - meets the appropriate criteria for a compile-time constant. - However, currently sometimes gcj is too eager and will end up - returning the field itself, leading to an incorrect external - reference being generated. */ - if ((is_compiled && !flag_indirect_dispatch) - || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE - && (JSTRING_TYPE_P (TREE_TYPE (fdecl)) - || JNUMERIC_TYPE_P (TREE_TYPE (fdecl))) - && TREE_CONSTANT (DECL_INITIAL (fdecl)))) + -findirect-dispatch, we simply never do this folding if compiling + from .class; in the .class file constants will be referred to via + the constant pool. */ + if ((!flag_indirect_dispatch || !from_class) + && (is_compiled + || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE + && (JSTRING_TYPE_P (TREE_TYPE (fdecl)) + || JNUMERIC_TYPE_P (TREE_TYPE (fdecl))) + && TREE_CONSTANT (DECL_INITIAL (fdecl))))) { if (is_compiled == 1) DECL_EXTERNAL (fdecl) = 1; @@ -1969,7 +1971,7 @@ is_compiled_class (tree class) tree build_dtable_decl (tree type) { - tree dtype; + tree dtype, decl; /* We need to build a new dtable type so that its size is uniquely computed when we're dealing with the class for real and not just @@ -2017,8 +2019,12 @@ build_dtable_decl (tree type) else dtype = dtable_type; - return build_decl (VAR_DECL, - java_mangle_vtable (&temporary_obstack, type), dtype); + decl = build_decl (VAR_DECL, get_identifier ("vt$"), dtype); + DECL_CONTEXT (decl) = type; + MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); + DECL_VTABLE_P (decl) = 1; + + return decl; } /* Pre-pend the TYPE_FIELDS of THIS_CLASS with a dummy FIELD_DECL for the @@ -2092,7 +2098,6 @@ void layout_class (tree this_class) { tree super_class = CLASSTYPE_SUPER (this_class); - tree field; class_list = tree_cons (this_class, NULL_TREE, class_list); if (CLASS_BEING_LAIDOUT (this_class)) @@ -2140,18 +2145,6 @@ layout_class (tree this_class) push_super_field (this_class, maybe_super_class); } - for (field = TYPE_FIELDS (this_class); - field != NULL_TREE; field = TREE_CHAIN (field)) - { - if (FIELD_STATIC (field)) - { - /* Set DECL_ASSEMBLER_NAME to something suitably mangled. */ - SET_DECL_ASSEMBLER_NAME (field, - java_mangle_decl - (&temporary_obstack, field)); - } - } - layout_type (this_class); /* Also recursively load/layout any superinterfaces, but only if @@ -2319,11 +2312,6 @@ layout_class_method (tree this_class, tree super_class, compiled into this object file. */ DECL_EXTERNAL (method_decl) = 1; - /* This is a good occasion to mangle the method's name */ - SET_DECL_ASSEMBLER_NAME (method_decl, - java_mangle_decl (&temporary_obstack, - method_decl)); - if (ID_INIT_P (method_name)) { const char *p = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (this_class))); |