Commit d60f72ae by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (lang_decl_flags): Remove permanent_attr.

	* cp-tree.h (lang_decl_flags): Remove permanent_attr.
	Remove next.
	(LANG_DECL_PERMANENT): Remove.
	* decl.c (duplicate_decls): Don't mess about with obstacks trying
	to free memory.
	(lang_mark_tree): Mark DECL_LANG_SPECIFIC.
	* lex.c (free_lang_decl_chain): Remove.
	(build_lang_decl): Don't use obstacks.
	(retrofit_lang_decl): Likewise.
	(copy_lang_decl): Likewise.

From-SVN: r29223
parent 37b31aef
1999-09-08 Mark Mitchell <mark@codesourcery.com> 1999-09-08 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (lang_decl_flags): Remove permanent_attr.
Remove next.
(LANG_DECL_PERMANENT): Remove.
* decl.c (duplicate_decls): Don't mess about with obstacks trying
to free memory.
(lang_mark_tree): Mark DECL_LANG_SPECIFIC.
* lex.c (free_lang_decl_chain): Remove.
(build_lang_decl): Don't use obstacks.
(retrofit_lang_decl): Likewise.
(copy_lang_decl): Likewise.
* cp-tree.h (saved_scope): Remove old_binding_level and * cp-tree.h (saved_scope): Remove old_binding_level and
function_decl. Tidy up. function_decl. Tidy up.
* decl.c (mark_saved_scope): Don't set them. * decl.c (mark_saved_scope): Don't set them.
......
...@@ -1474,20 +1474,19 @@ struct lang_decl_flags ...@@ -1474,20 +1474,19 @@ struct lang_decl_flags
unsigned const_memfunc : 1; unsigned const_memfunc : 1;
unsigned volatile_memfunc : 1; unsigned volatile_memfunc : 1;
unsigned abstract_virtual : 1; unsigned abstract_virtual : 1;
unsigned permanent_attr : 1 ;
unsigned constructor_for_vbase_attr : 1; unsigned constructor_for_vbase_attr : 1;
unsigned mutable_flag : 1; unsigned mutable_flag : 1;
unsigned saved_inline : 1; unsigned saved_inline : 1;
unsigned use_template : 2; unsigned use_template : 2;
unsigned nonconverting : 1; unsigned nonconverting : 1;
unsigned declared_inline : 1; unsigned declared_inline : 1;
unsigned not_really_extern : 1; unsigned not_really_extern : 1;
unsigned needs_final_overrider : 1; unsigned needs_final_overrider : 1;
unsigned bitfield : 1; unsigned bitfield : 1;
unsigned defined_in_class : 1; unsigned defined_in_class : 1;
unsigned dummy : 5; unsigned dummy : 6;
tree access; tree access;
tree context; tree context;
...@@ -1515,9 +1514,6 @@ struct lang_decl ...@@ -1515,9 +1514,6 @@ struct lang_decl
{ {
tree sorted_fields; tree sorted_fields;
struct pending_inline *pending_inline_info; struct pending_inline *pending_inline_info;
/* The lang_decls on the free_lang_decl_chain are chained together
through this pointer. */
struct lang_decl *next;
} u; } u;
}; };
...@@ -1639,9 +1635,6 @@ struct lang_decl ...@@ -1639,9 +1635,6 @@ struct lang_decl
must be overridden by derived classes. */ must be overridden by derived classes. */
#define DECL_NEEDS_FINAL_OVERRIDER_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.needs_final_overrider) #define DECL_NEEDS_FINAL_OVERRIDER_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.needs_final_overrider)
/* Nonzero if allocated on permanent_obstack. */
#define LANG_DECL_PERMANENT(LANGDECL) ((LANGDECL)->decl_flags.permanent_attr)
/* The _TYPE context in which this _DECL appears. This field holds the /* The _TYPE context in which this _DECL appears. This field holds the
class where a virtual function instance is actually defined, and the class where a virtual function instance is actually defined, and the
lexical scope of a friend function defined in a class body. */ lexical scope of a friend function defined in a class body. */
......
...@@ -3037,7 +3037,6 @@ int ...@@ -3037,7 +3037,6 @@ int
duplicate_decls (newdecl, olddecl) duplicate_decls (newdecl, olddecl)
tree newdecl, olddecl; tree newdecl, olddecl;
{ {
extern struct obstack permanent_obstack;
unsigned olddecl_uid = DECL_UID (olddecl); unsigned olddecl_uid = DECL_UID (olddecl);
int olddecl_friend = 0, types_match = 0; int olddecl_friend = 0, types_match = 0;
int new_defines_function = 0; int new_defines_function = 0;
...@@ -3625,8 +3624,6 @@ duplicate_decls (newdecl, olddecl) ...@@ -3625,8 +3624,6 @@ duplicate_decls (newdecl, olddecl)
if (TREE_CODE (newdecl) == FUNCTION_DECL) if (TREE_CODE (newdecl) == FUNCTION_DECL)
{ {
int function_size; int function_size;
struct lang_decl *ol = DECL_LANG_SPECIFIC (olddecl);
struct lang_decl *nl = DECL_LANG_SPECIFIC (newdecl);
function_size = sizeof (struct tree_decl); function_size = sizeof (struct tree_decl);
...@@ -3634,11 +3631,6 @@ duplicate_decls (newdecl, olddecl) ...@@ -3634,11 +3631,6 @@ duplicate_decls (newdecl, olddecl)
(char *) olddecl + sizeof (struct tree_common), (char *) olddecl + sizeof (struct tree_common),
function_size - sizeof (struct tree_common)); function_size - sizeof (struct tree_common));
/* Can we safely free the storage used by newdecl? */
#define ROUND(x) ((x + obstack_alignment_mask (&permanent_obstack)) \
& ~ obstack_alignment_mask (&permanent_obstack))
if (DECL_TEMPLATE_INSTANTIATION (newdecl)) if (DECL_TEMPLATE_INSTANTIATION (newdecl))
{ {
/* If newdecl is a template instantiation, it is possible that /* If newdecl is a template instantiation, it is possible that
...@@ -3670,38 +3662,6 @@ duplicate_decls (newdecl, olddecl) ...@@ -3670,38 +3662,6 @@ duplicate_decls (newdecl, olddecl)
if (TREE_VALUE (decls) == newdecl) if (TREE_VALUE (decls) == newdecl)
TREE_VALUE (decls) = olddecl; TREE_VALUE (decls) = olddecl;
} }
if (((char *)newdecl + ROUND (function_size) == (char *)nl
&& ((char *)newdecl + ROUND (function_size)
+ ROUND (sizeof (struct lang_decl))
== obstack_next_free (&permanent_obstack)))
|| ((char *)newdecl + ROUND (function_size)
== obstack_next_free (&permanent_obstack)))
{
DECL_MAIN_VARIANT (newdecl) = olddecl;
DECL_LANG_SPECIFIC (olddecl) = ol;
bcopy ((char *)nl, (char *)ol, sizeof (struct lang_decl));
obstack_free (&permanent_obstack, newdecl);
}
else if (LANG_DECL_PERMANENT (ol) && ol != nl)
{
if (DECL_MAIN_VARIANT (olddecl) == olddecl)
{
struct lang_decl *free_lang_decl = ol;
/* Save these lang_decls that would otherwise be lost. */
if (DECL_LANG_SPECIFIC (olddecl) == ol)
abort ();
free_lang_decl->u.next = free_lang_decl_chain;
free_lang_decl_chain = free_lang_decl;
}
else
{
/* Storage leak. */;
}
}
} }
else else
{ {
...@@ -14580,6 +14540,7 @@ lang_mark_tree (t) ...@@ -14580,6 +14540,7 @@ lang_mark_tree (t)
if (ld) if (ld)
{ {
ggc_mark (ld);
ggc_mark_tree (ld->decl_flags.access); ggc_mark_tree (ld->decl_flags.access);
ggc_mark_tree (ld->decl_flags.context); ggc_mark_tree (ld->decl_flags.context);
if (TREE_CODE (t) != NAMESPACE_DECL) if (TREE_CODE (t) != NAMESPACE_DECL)
......
...@@ -4748,10 +4748,6 @@ extern int tree_node_counts[]; ...@@ -4748,10 +4748,6 @@ extern int tree_node_counts[];
extern int tree_node_sizes[]; extern int tree_node_sizes[];
#endif #endif
/* Place to save freed lang_decls which were allocated on the
permanent_obstack. */
struct lang_decl *free_lang_decl_chain;
tree tree
build_lang_decl (code, name, type) build_lang_decl (code, name, type)
enum tree_code code; enum tree_code code;
...@@ -4760,17 +4756,9 @@ build_lang_decl (code, name, type) ...@@ -4760,17 +4756,9 @@ build_lang_decl (code, name, type)
{ {
tree t; tree t;
/* When we're building statement trees, declarations need to live
forever. */
if (building_stmt_tree ())
push_permanent_obstack ();
t = build_decl (code, name, type); t = build_decl (code, name, type);
retrofit_lang_decl (t); retrofit_lang_decl (t);
if (building_stmt_tree ())
pop_obstacks ();
return t; return t;
} }
...@@ -4781,7 +4769,6 @@ void ...@@ -4781,7 +4769,6 @@ void
retrofit_lang_decl (t) retrofit_lang_decl (t)
tree t; tree t;
{ {
struct obstack *obstack = current_obstack;
struct lang_decl *ld; struct lang_decl *ld;
size_t size; size_t size;
...@@ -4790,26 +4777,10 @@ retrofit_lang_decl (t) ...@@ -4790,26 +4777,10 @@ retrofit_lang_decl (t)
else else
size = sizeof (struct lang_decl_flags); size = sizeof (struct lang_decl_flags);
if (! TREE_PERMANENT (t)) ld = (struct lang_decl *) ggc_alloc (size);
obstack = saveable_obstack;
else
/* Could be that saveable is permanent and current is not. */
obstack = &permanent_obstack;
if (CAN_HAVE_FULL_LANG_DECL_P (t) && free_lang_decl_chain
&& obstack == &permanent_obstack)
{
ld = free_lang_decl_chain;
free_lang_decl_chain = free_lang_decl_chain->u.next;
}
else
ld = (struct lang_decl *) obstack_alloc (obstack, size);
memset (ld, 0, size); memset (ld, 0, size);
DECL_LANG_SPECIFIC (t) = ld; DECL_LANG_SPECIFIC (t) = ld;
LANG_DECL_PERMANENT (ld) = obstack == &permanent_obstack;
my_friendly_assert (LANG_DECL_PERMANENT (ld) == TREE_PERMANENT (t), 234);
if (current_lang_name == lang_name_cplusplus) if (current_lang_name == lang_name_cplusplus)
DECL_LANGUAGE (t) = lang_cplusplus; DECL_LANGUAGE (t) = lang_cplusplus;
else if (current_lang_name == lang_name_c) else if (current_lang_name == lang_name_c)
...@@ -4832,7 +4803,7 @@ copy_lang_decl (node) ...@@ -4832,7 +4803,7 @@ copy_lang_decl (node)
tree node; tree node;
{ {
int size; int size;
int *pi; struct lang_decl *ld;
if (! DECL_LANG_SPECIFIC (node)) if (! DECL_LANG_SPECIFIC (node))
return; return;
...@@ -4841,9 +4812,9 @@ copy_lang_decl (node) ...@@ -4841,9 +4812,9 @@ copy_lang_decl (node)
size = sizeof (struct lang_decl_flags); size = sizeof (struct lang_decl_flags);
else else
size = sizeof (struct lang_decl); size = sizeof (struct lang_decl);
pi = (int *)obstack_alloc (&permanent_obstack, size); ld = (struct lang_decl *) ggc_alloc (size);
bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size); bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)ld, size);
DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi; DECL_LANG_SPECIFIC (node) = ld;
} }
tree tree
......
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