From d60f72aec57414b8339eecb25c33b423af7e6946 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 9 Sep 1999 03:31:23 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 11 +++++++++++ gcc/cp/cp-tree.h | 13 +++---------- gcc/cp/decl.c | 41 +---------------------------------------- gcc/cp/lex.c | 39 +++++---------------------------------- 4 files changed, 20 insertions(+), 84 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a15b3bb..514cd2f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,16 @@ 1999-09-08 Mark Mitchell + * 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 function_decl. Tidy up. * decl.c (mark_saved_scope): Don't set them. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 6da2463..f5b1a6e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1474,20 +1474,19 @@ struct lang_decl_flags unsigned const_memfunc : 1; unsigned volatile_memfunc : 1; unsigned abstract_virtual : 1; - unsigned permanent_attr : 1 ; - unsigned constructor_for_vbase_attr : 1; + unsigned mutable_flag : 1; unsigned saved_inline : 1; unsigned use_template : 2; unsigned nonconverting : 1; unsigned declared_inline : 1; unsigned not_really_extern : 1; - unsigned needs_final_overrider : 1; + unsigned bitfield : 1; unsigned defined_in_class : 1; - unsigned dummy : 5; + unsigned dummy : 6; tree access; tree context; @@ -1515,9 +1514,6 @@ struct lang_decl { tree sorted_fields; 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; }; @@ -1639,9 +1635,6 @@ struct lang_decl must be overridden by derived classes. */ #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 class where a virtual function instance is actually defined, and the lexical scope of a friend function defined in a class body. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index dc2850e..264f7b2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3037,7 +3037,6 @@ int duplicate_decls (newdecl, olddecl) tree newdecl, olddecl; { - extern struct obstack permanent_obstack; unsigned olddecl_uid = DECL_UID (olddecl); int olddecl_friend = 0, types_match = 0; int new_defines_function = 0; @@ -3625,8 +3624,6 @@ duplicate_decls (newdecl, olddecl) if (TREE_CODE (newdecl) == FUNCTION_DECL) { 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); @@ -3634,11 +3631,6 @@ duplicate_decls (newdecl, olddecl) (char *) olddecl + 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 newdecl is a template instantiation, it is possible that @@ -3670,38 +3662,6 @@ duplicate_decls (newdecl, olddecl) if (TREE_VALUE (decls) == newdecl) 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 { @@ -14580,6 +14540,7 @@ lang_mark_tree (t) if (ld) { + ggc_mark (ld); ggc_mark_tree (ld->decl_flags.access); ggc_mark_tree (ld->decl_flags.context); if (TREE_CODE (t) != NAMESPACE_DECL) diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 51f0c00..1ab7f0d 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -4748,10 +4748,6 @@ extern int tree_node_counts[]; extern int tree_node_sizes[]; #endif -/* Place to save freed lang_decls which were allocated on the - permanent_obstack. */ -struct lang_decl *free_lang_decl_chain; - tree build_lang_decl (code, name, type) enum tree_code code; @@ -4760,17 +4756,9 @@ build_lang_decl (code, name, type) { 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); retrofit_lang_decl (t); - if (building_stmt_tree ()) - pop_obstacks (); - return t; } @@ -4781,7 +4769,6 @@ void retrofit_lang_decl (t) tree t; { - struct obstack *obstack = current_obstack; struct lang_decl *ld; size_t size; @@ -4790,26 +4777,10 @@ retrofit_lang_decl (t) else size = sizeof (struct lang_decl_flags); - if (! TREE_PERMANENT (t)) - 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); - + ld = (struct lang_decl *) ggc_alloc (size); memset (ld, 0, size); 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) DECL_LANGUAGE (t) = lang_cplusplus; else if (current_lang_name == lang_name_c) @@ -4832,7 +4803,7 @@ copy_lang_decl (node) tree node; { int size; - int *pi; + struct lang_decl *ld; if (! DECL_LANG_SPECIFIC (node)) return; @@ -4841,9 +4812,9 @@ copy_lang_decl (node) size = sizeof (struct lang_decl_flags); else size = sizeof (struct lang_decl); - pi = (int *)obstack_alloc (&permanent_obstack, size); - bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size); - DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi; + ld = (struct lang_decl *) ggc_alloc (size); + bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)ld, size); + DECL_LANG_SPECIFIC (node) = ld; } tree -- 2.7.4