Commit 513e0aa0 by Jeff Law

[PATCH] Fix slowness in demangler

	* cp-demangle.c (d_print_init): Remove const from 4th param.
	(cplus_demangle_fill_name): Initialize d->d_counting.
	(cplus_demangle_fill_extended_operator): Likewise.
	(cplus_demangle_fill_ctor): Likewise.
	(cplus_demangle_fill_dtor): Likewise.
	(d_make_empty): Likewise.
	(d_count_templates_scopes): Remobe const from 3rd param,
	Return on dc->d_counting > 1,
	Increment dc->d_counting.
        * cp-demint.c (cplus_demangle_fill_component): Initialize d->d_counting.
	(cplus_demangle_fill_builtin_type): Likewise.
	(cplus_demangle_fill_operator): Likewise.

	* demangle.h (struct demangle_component): Add member
	d_counting.

From-SVN: r278359
parent 32fc3719
2019-10-22 Eduard-Mihai Burtescu <eddyb@lyken.rs> 2019-11-16 Tim Ruehsen <tim.ruehsen@gmx.de>
* demangle.h (struct demangle_component): Add member
d_counting.
2019-11-16 Eduard-Mihai Burtescu <eddyb@lyken.rs>
* demangle.h (rust_demangle_callback): Add. * demangle.h (rust_demangle_callback): Add.
......
...@@ -468,6 +468,7 @@ struct demangle_component ...@@ -468,6 +468,7 @@ struct demangle_component
Initialize to zero. Private to d_print_comp. Initialize to zero. Private to d_print_comp.
All other fields are final after initialization. */ All other fields are final after initialization. */
int d_printing; int d_printing;
int d_counting;
union union
{ {
......
2019-10-22 Eduard-Mihai Burtescu <eddyb@lyken.rs> 2019-11-16 Tim Ruehsen <tim.ruehsen@gmx.de>
* cp-demangle.c (d_print_init): Remove const from 4th param.
(cplus_demangle_fill_name): Initialize d->d_counting.
(cplus_demangle_fill_extended_operator): Likewise.
(cplus_demangle_fill_ctor): Likewise.
(cplus_demangle_fill_dtor): Likewise.
(d_make_empty): Likewise.
(d_count_templates_scopes): Remobe const from 3rd param,
Return on dc->d_counting > 1,
Increment dc->d_counting.
* cp-demint.c (cplus_demangle_fill_component): Initialize d->d_counting.
(cplus_demangle_fill_builtin_type): Likewise.
(cplus_demangle_fill_operator): Likewise.
2019-11-16 Eduard-Mihai Burtescu <eddyb@lyken.rs>
* cplus-dem.c (cplus_demangle): Use rust_demangle directly. * cplus-dem.c (cplus_demangle): Use rust_demangle directly.
(rust_demangle): Remove. (rust_demangle): Remove.
......
...@@ -517,7 +517,7 @@ d_growable_string_callback_adapter (const char *, size_t, void *); ...@@ -517,7 +517,7 @@ d_growable_string_callback_adapter (const char *, size_t, void *);
static void static void
d_print_init (struct d_print_info *, demangle_callbackref, void *, d_print_init (struct d_print_info *, demangle_callbackref, void *,
const struct demangle_component *); struct demangle_component *);
static inline void d_print_error (struct d_print_info *); static inline void d_print_error (struct d_print_info *);
...@@ -864,6 +864,7 @@ cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len) ...@@ -864,6 +864,7 @@ cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len)
if (p == NULL || s == NULL || len <= 0) if (p == NULL || s == NULL || len <= 0)
return 0; return 0;
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
p->type = DEMANGLE_COMPONENT_NAME; p->type = DEMANGLE_COMPONENT_NAME;
p->u.s_name.s = s; p->u.s_name.s = s;
p->u.s_name.len = len; p->u.s_name.len = len;
...@@ -880,6 +881,7 @@ cplus_demangle_fill_extended_operator (struct demangle_component *p, int args, ...@@ -880,6 +881,7 @@ cplus_demangle_fill_extended_operator (struct demangle_component *p, int args,
if (p == NULL || args < 0 || name == NULL) if (p == NULL || args < 0 || name == NULL)
return 0; return 0;
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR; p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR;
p->u.s_extended_operator.args = args; p->u.s_extended_operator.args = args;
p->u.s_extended_operator.name = name; p->u.s_extended_operator.name = name;
...@@ -900,6 +902,7 @@ cplus_demangle_fill_ctor (struct demangle_component *p, ...@@ -900,6 +902,7 @@ cplus_demangle_fill_ctor (struct demangle_component *p,
|| (int) kind > gnu_v3_object_ctor_group) || (int) kind > gnu_v3_object_ctor_group)
return 0; return 0;
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
p->type = DEMANGLE_COMPONENT_CTOR; p->type = DEMANGLE_COMPONENT_CTOR;
p->u.s_ctor.kind = kind; p->u.s_ctor.kind = kind;
p->u.s_ctor.name = name; p->u.s_ctor.name = name;
...@@ -920,6 +923,7 @@ cplus_demangle_fill_dtor (struct demangle_component *p, ...@@ -920,6 +923,7 @@ cplus_demangle_fill_dtor (struct demangle_component *p,
|| (int) kind > gnu_v3_object_dtor_group) || (int) kind > gnu_v3_object_dtor_group)
return 0; return 0;
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
p->type = DEMANGLE_COMPONENT_DTOR; p->type = DEMANGLE_COMPONENT_DTOR;
p->u.s_dtor.kind = kind; p->u.s_dtor.kind = kind;
p->u.s_dtor.name = name; p->u.s_dtor.name = name;
...@@ -937,6 +941,7 @@ d_make_empty (struct d_info *di) ...@@ -937,6 +941,7 @@ d_make_empty (struct d_info *di)
return NULL; return NULL;
p = &di->comps[di->next_comp]; p = &di->comps[di->next_comp];
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
++di->next_comp; ++di->next_comp;
return p; return p;
} }
...@@ -4079,11 +4084,13 @@ d_growable_string_callback_adapter (const char *s, size_t l, void *opaque) ...@@ -4079,11 +4084,13 @@ d_growable_string_callback_adapter (const char *s, size_t l, void *opaque)
static void static void
d_count_templates_scopes (struct d_print_info *dpi, d_count_templates_scopes (struct d_print_info *dpi,
const struct demangle_component *dc) struct demangle_component *dc)
{ {
if (dc == NULL) if (dc == NULL || dc->d_counting > 1 || dpi->recursion > MAX_RECURSION_COUNT)
return; return;
++ dc->d_counting;
switch (dc->type) switch (dc->type)
{ {
case DEMANGLE_COMPONENT_NAME: case DEMANGLE_COMPONENT_NAME:
...@@ -4213,7 +4220,7 @@ d_count_templates_scopes (struct d_print_info *dpi, ...@@ -4213,7 +4220,7 @@ d_count_templates_scopes (struct d_print_info *dpi,
static void static void
d_print_init (struct d_print_info *dpi, demangle_callbackref callback, d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
void *opaque, const struct demangle_component *dc) void *opaque, struct demangle_component *dc)
{ {
dpi->len = 0; dpi->len = 0;
dpi->last_char = '\0'; dpi->last_char = '\0';
......
...@@ -125,6 +125,7 @@ cplus_demangle_fill_component (struct demangle_component *p, ...@@ -125,6 +125,7 @@ cplus_demangle_fill_component (struct demangle_component *p,
p->u.s_binary.left = left; p->u.s_binary.left = left;
p->u.s_binary.right = right; p->u.s_binary.right = right;
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
return 1; return 1;
} }
...@@ -149,6 +150,7 @@ cplus_demangle_fill_builtin_type (struct demangle_component *p, ...@@ -149,6 +150,7 @@ cplus_demangle_fill_builtin_type (struct demangle_component *p,
p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE; p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE;
p->u.s_builtin.type = &cplus_demangle_builtin_types[i]; p->u.s_builtin.type = &cplus_demangle_builtin_types[i];
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
return 1; return 1;
} }
} }
...@@ -176,6 +178,7 @@ cplus_demangle_fill_operator (struct demangle_component *p, ...@@ -176,6 +178,7 @@ cplus_demangle_fill_operator (struct demangle_component *p,
p->type = DEMANGLE_COMPONENT_OPERATOR; p->type = DEMANGLE_COMPONENT_OPERATOR;
p->u.s_operator.op = &cplus_demangle_operators[i]; p->u.s_operator.op = &cplus_demangle_operators[i];
p->d_printing = 0; p->d_printing = 0;
p->d_counting = 0;
return 1; return 1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment