diff options
author | Richard Henderson <rth@gcc.gnu.org> | 2005-05-25 15:08:31 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2005-05-25 15:08:31 -0700 |
commit | 6de33afa78e19bee96963ec3771c352a488287e1 (patch) | |
tree | 047bbcbef9a1b2d83cf20f62170c7df12ca50eff /gcc/java/mangle.c | |
parent | 81fc305201e8913727cb61303c4812730a95c59c (diff) | |
download | gcc-6de33afa78e19bee96963ec3771c352a488287e1.zip gcc-6de33afa78e19bee96963ec3771c352a488287e1.tar.gz gcc-6de33afa78e19bee96963ec3771c352a488287e1.tar.bz2 |
re PR libgcj/21692 (unexpected java.lang.NoClassDefFoundError)
PR libgcj/21692
cp/
* cp-tree.h (make_alias_for): Declare.
* decl2.c (build_java_method_aliases): New.
(cp_finish_file): Call it.
* method.c (make_alias_for): Split out from ...
(make_alias_for_thunk): ... here.
java/
* Make-lang.in (java/mangle.o): Depend on LANGHOOKS_DEF_H.
* class.c (build_class_ref): Set DECL_CLASS_FIELD_P and
DECL_CONTEXT; avoid pushdecl_top_level.
(build_dtable_decl): Set DECL_VTABLE_P and DECL_CONTEXT.
(layout_class): Don't SET_DECL_ASSEMBLER_NAME.
(layout_class_method): Likewise.
* decl.c (java_mark_cni_decl_local): New.
(java_mark_class_local): Use it.
* java-tree.h (DECL_LOCAL_CNI_METHOD_P): New.
(DECL_CLASS_FIELD_P, DECL_VTABLE_P): New.
(struct lang_decl_func): Add local_cni;
(struct lang_decl_var): Add class_field, vtable.
(java_mangle_decl): Declare.
* lang.c (LANG_HOOKS_SET_DECL_ASSEMBLER_NAME): New.
* mangle.c: Remove dup obstack.h; include langhooks-def.h.
(mangle_obstack_1): New.
(java_mangle_decl): Remove obstack argument. Call mangle_class_field,
mangle_vtable, and mangle_local_cni_method_decl. Fall back to
lhd_set_decl_assembler_name for things that don't need mangling.
(mangle_class_field): Rename from java_mangle_class_field, make
static, don't call init_mangling or finish_mangling.
(mangle_vtable): Similarly.
(mangle_local_cni_method_decl): New.
(init_mangling): Remove obstack argument. Use &mangle_obstack_1,
gcc_assert, and MANGLE_RAW_STRING.
(finish_mangling): Use gcc_assert, remove if 0 debugging code.
From-SVN: r100171
Diffstat (limited to 'gcc/java/mangle.c')
-rw-r--r-- | gcc/java/mangle.c | 124 |
1 files changed, 83 insertions, 41 deletions
diff --git a/gcc/java/mangle.c b/gcc/java/mangle.c index e0b53a1..22a3918 100644 --- a/gcc/java/mangle.c +++ b/gcc/java/mangle.c @@ -35,11 +35,14 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "java-tree.h" #include "obstack.h" #include "toplev.h" -#include "obstack.h" #include "ggc.h" +#include "langhooks-def.h" +static void mangle_class_field (tree); +static void mangle_vtable (tree); static void mangle_field_decl (tree); static void mangle_method_decl (tree); +static void mangle_local_cni_method_decl (tree); static void mangle_type (tree); static void mangle_pointer_type (tree); @@ -55,15 +58,15 @@ static void set_type_package_list (tree); static int entry_match_pointer_p (tree, int); static void emit_compression_string (int); -static void init_mangling (struct obstack *); +static void init_mangling (void); static tree finish_mangling (void); static void compression_table_add (tree); static void mangle_member_name (tree); -/* We use an incoming obstack, always to be provided to the interface - functions. */ +static struct obstack mangle_obstack_1; struct obstack *mangle_obstack; + #define MANGLE_RAW_STRING(S) \ obstack_grow (mangle_obstack, (S), sizeof (S)-1) @@ -73,46 +76,75 @@ static GTY(()) tree atms; /* This is the mangling interface: a decl, a class field (.class) and the vtable. */ -tree -java_mangle_decl (struct obstack *obstack, tree decl) +void +java_mangle_decl (tree decl) { - init_mangling (obstack); - switch (TREE_CODE (decl)) + /* A copy of the check from the beginning of lhd_set_decl_assembler_name. + Only FUNCTION_DECLs and VAR_DECLs for variables with static storage + duration need a real DECL_ASSEMBLER_NAME. */ + gcc_assert (TREE_CODE (decl) == FUNCTION_DECL + || (TREE_CODE (decl) == VAR_DECL + && (TREE_STATIC (decl) + || DECL_EXTERNAL (decl) + || TREE_PUBLIC (decl)))); + + /* Mangling only applies to class members. */ + if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl))) { - case VAR_DECL: - mangle_field_decl (decl); - break; - case FUNCTION_DECL: - mangle_method_decl (decl); - break; - default: - internal_error ("can't mangle %s", tree_code_name [TREE_CODE (decl)]); + init_mangling (); + switch (TREE_CODE (decl)) + { + case VAR_DECL: + if (DECL_LANG_SPECIFIC (decl)) + { + if (DECL_CLASS_FIELD_P (decl)) + { + mangle_class_field (DECL_CONTEXT (decl)); + break; + } + else if (DECL_VTABLE_P (decl)) + { + mangle_vtable (DECL_CONTEXT (decl)); + break; + } + } + mangle_field_decl (decl); + break; + + case FUNCTION_DECL: + if (DECL_LANG_SPECIFIC (decl) && DECL_LOCAL_CNI_METHOD_P (decl)) + mangle_local_cni_method_decl (decl); + else + mangle_method_decl (decl); + break; + + default: + gcc_unreachable (); + } + SET_DECL_ASSEMBLER_NAME (decl, finish_mangling ()); } - return finish_mangling (); + else + lhd_set_decl_assembler_name (decl); } -tree -java_mangle_class_field (struct obstack *obstack, tree type) +/* Beginning of the helper functions */ + +static void +mangle_class_field (tree type) { - init_mangling (obstack); mangle_record_type (type, /* for_pointer = */ 0); MANGLE_RAW_STRING ("6class$"); obstack_1grow (mangle_obstack, 'E'); - return finish_mangling (); } -tree -java_mangle_vtable (struct obstack *obstack, tree type) +static void +mangle_vtable (tree type) { - init_mangling (obstack); MANGLE_RAW_STRING ("TV"); mangle_record_type (type, /* for_pointer = */ 0); obstack_1grow (mangle_obstack, 'E'); - return finish_mangling (); } -/* Beginning of the helper functions */ - /* This mangles a field decl */ static void @@ -167,6 +199,18 @@ mangle_method_decl (tree mdecl) } } +/* This mangles a CNI method for a local class. If the target supports + hidden aliases, then G++ will have generated one for us. It is the + responsibility of java_mark_class_local to check target support, since + we need to set DECL_VISIBILITY (or not) much earlier. */ + +static void +mangle_local_cni_method_decl (tree decl) +{ + MANGLE_RAW_STRING ("GA"); + mangle_method_decl (decl); +} + /* This mangles a member name, like a function name or a field name. Handle cases were `name' is a C++ keyword. Return a nonzero value if unicode encoding was required. */ @@ -585,17 +629,19 @@ compression_table_add (tree type) /* Mangling initialization routine. */ static void -init_mangling (struct obstack *obstack) +init_mangling (void) { - mangle_obstack = obstack; - if (!compression_table) - compression_table = make_tree_vec (10); - else - /* Mangling already in progress. */ - abort (); + if (!mangle_obstack) + { + mangle_obstack = &mangle_obstack_1; + gcc_obstack_init (mangle_obstack); + } + + gcc_assert (compression_table == NULL); + compression_table = make_tree_vec (10); /* Mangled name are to be suffixed */ - obstack_grow (mangle_obstack, "_Z", 2); + MANGLE_RAW_STRING ("_Z"); } /* Mangling finalization routine. The mangled name is returned as a @@ -606,18 +652,14 @@ finish_mangling (void) { tree result; - if (!compression_table) - /* Mangling already finished. */ - abort (); + gcc_assert (compression_table); compression_table = NULL_TREE; compression_next = 0; obstack_1grow (mangle_obstack, '\0'); result = get_identifier (obstack_base (mangle_obstack)); obstack_free (mangle_obstack, obstack_base (mangle_obstack)); -#if 0 - printf ("// %s\n", IDENTIFIER_POINTER (result)); -#endif + return result; } |