&& (PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE))))))
/* Things we only need one of. This module is not reentrant. */
-static struct globals
+typedef struct globals GTY(())
{
- /* The name in which we're building the mangled name. */
- struct obstack name_obstack;
-
/* An array of the current substitution candidates, in the order
we've seen them. */
varray_type substitutions;
/* The entity that is being mangled. */
- tree entity;
+ tree GTY ((skip)) entity;
/* True if the mangling will be different in a future version of the
ABI. */
bool need_abi_warning;
-} G;
+} globals;
+
+static GTY (()) globals G;
+
+/* The obstack on which we build mangled names. */
+static struct obstack *mangle_obstack;
+
+/* The obstack on which we build mangled names that are not going to
+ be IDENTIFIER_NODEs. */
+static struct obstack name_obstack;
+
+ /* The first object on the name_obstack; we use this to free memory
+ allocated on the name_obstack. */
+static void *name_base;
/* Indices into subst_identifiers. These are identifiers used in
special substitution rules. */
/* Control functions. */
-static inline void start_mangling (const tree);
+static inline void start_mangling (const tree, bool);
static inline const char *finish_mangling (const bool);
static tree mangle_special_for_type (const tree, const char *);
/* Append a single character to the end of the mangled
representation. */
#define write_char(CHAR) \
- obstack_1grow (&G.name_obstack, (CHAR))
+ obstack_1grow (mangle_obstack, (CHAR))
/* Append a sized buffer to the end of the mangled representation. */
#define write_chars(CHAR, LEN) \
- obstack_grow (&G.name_obstack, (CHAR), (LEN))
+ obstack_grow (mangle_obstack, (CHAR), (LEN))
/* Append a NUL-terminated string to the end of the mangled
representation. */
#define write_string(STRING) \
- obstack_grow (&G.name_obstack, (STRING), strlen (STRING))
+ obstack_grow (mangle_obstack, (STRING), strlen (STRING))
/* Nonzero if NODE1 and NODE2 are both TREE_LIST nodes and have the
same purpose (context, which may be a type) and value (template
/* Start mangling ENTITY. */
static inline void
-start_mangling (const tree entity)
+start_mangling (const tree entity, const bool ident_p)
{
G.entity = entity;
G.need_abi_warning = false;
- VARRAY_TREE_INIT (G.substitutions, 1, "mangling substitutions");
- obstack_free (&G.name_obstack, obstack_base (&G.name_obstack));
+ if (!ident_p)
+ {
+ obstack_free (&name_obstack, name_base);
+ mangle_obstack = &name_obstack;
+ name_base = obstack_alloc (&name_obstack, 0);
+ }
+ else
+ mangle_obstack = &ident_hash->stack;
}
/* Done with mangling. Return the generated mangled name. If WARN is
G.entity);
/* Clear all the substitutions. */
- G.substitutions = 0;
+ VARRAY_CLEAR (G.substitutions);
/* Null-terminate the string. */
write_char ('\0');
- return (const char *) obstack_base (&G.name_obstack);
+ return (const char *) obstack_finish (mangle_obstack);
}
/* Initialize data structures for mangling. */
void
init_mangle (void)
{
- gcc_obstack_init (&G.name_obstack);
+ gcc_obstack_init (&name_obstack);
+ name_base = obstack_alloc (&name_obstack, 0);
+ VARRAY_TREE_INIT (G.substitutions, 1, "mangling substitutions");
/* Cache these identifiers for quick comparison when checking for
standard substitutions. */
{
const char *result;
- start_mangling (decl);
+ start_mangling (decl, /*ident_p=*/true);
if (TREE_CODE (decl) == TYPE_DECL)
write_type (TREE_TYPE (decl));
return result;
}
+/* Like get_identifier, except that NAME is assumed to have been
+ allocated on the obstack used by the identifier hash table. */
+
+static inline tree
+get_identifier_nocopy (const char *name)
+{
+ hashnode ht_node = ht_lookup (ident_hash, name,
+ strlen (name), HT_ALLOCED);
+ return HT_IDENT_TO_GCC_IDENT (ht_node);
+}
+
/* Create an identifier for the external mangled name of DECL. */
void
mangle_decl (const tree decl)
{
- tree id = get_identifier (mangle_decl_string (decl));
-
- SET_DECL_ASSEMBLER_NAME (decl, id);
+ SET_DECL_ASSEMBLER_NAME (decl,
+ get_identifier_nocopy (mangle_decl_string (decl)));
}
/* Generate the mangled representation of TYPE. */
{
const char *result;
- start_mangling (type);
+ start_mangling (type, /*ident_p=*/false);
write_type (type);
result = finish_mangling (/*warn=*/false);
if (DEBUG_MANGLE)
return result;
}
-/* Create an identifier for the mangled representation of TYPE. */
-
-tree
-mangle_type (const tree type)
-{
- return get_identifier (mangle_type_string (type));
-}
-
/* Create an identifier for the mangled name of a special component
for belonging to TYPE. CODE is the ABI-specified code for this
component. */
/* We don't have an actual decl here for the special component, so
we can't just process the <encoded-name>. Instead, fake it. */
- start_mangling (type);
+ start_mangling (type, /*ident_p=*/true);
/* Start the mangling. */
write_string ("_Z");
if (DEBUG_MANGLE)
fprintf (stderr, "mangle_special_for_type = %s\n\n", result);
- return get_identifier (result);
+ return get_identifier_nocopy (result);
}
/* Create an identifier for the mangled representation of the typeinfo
{
const char *result;
- start_mangling (type);
+ start_mangling (type, /*ident_p=*/true);
write_string ("_Z");
write_string ("TC");
result = finish_mangling (/*warn=*/false);
if (DEBUG_MANGLE)
fprintf (stderr, "mangle_ctor_vtbl_for_type = %s\n\n", result);
- return get_identifier (result);
+ return get_identifier_nocopy (result);
}
/* Mangle a this pointer or result pointer adjustment.
{
const char *result;
- start_mangling (fn_decl);
+ start_mangling (fn_decl, /*ident_p=*/true);
write_string ("_Z");
write_char ('T');
result = finish_mangling (/*warn=*/false);
if (DEBUG_MANGLE)
fprintf (stderr, "mangle_thunk = %s\n\n", result);
- return get_identifier (result);
+ return get_identifier_nocopy (result);
}
/* This hash table maps TYPEs to the IDENTIFIER for a conversion
tree
mangle_guard_variable (const tree variable)
{
- start_mangling (variable);
+ start_mangling (variable, /*ident_p=*/true);
write_string ("_ZGV");
if (strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0)
/* The name of a guard variable for a reference temporary should refer
write_string (IDENTIFIER_POINTER (DECL_NAME (variable)) + 4);
else
write_name (variable, /*ignore_local_scope=*/0);
- return get_identifier (finish_mangling (/*warn=*/false));
+ return get_identifier_nocopy (finish_mangling (/*warn=*/false));
}
/* Return an identifier for the name of a temporary variable used to
tree
mangle_ref_init_variable (const tree variable)
{
- start_mangling (variable);
+ start_mangling (variable, /*ident_p=*/true);
write_string ("_ZGR");
write_name (variable, /*ignore_local_scope=*/0);
- return get_identifier (finish_mangling (/*warn=*/false));
+ return get_identifier_nocopy (finish_mangling (/*warn=*/false));
}
\f