cp-tree.h (class_cache_firstobj): Declare.
authorMark Mitchell <mark@codesourcery.com>
Tue, 15 Jun 1999 16:42:46 +0000 (16:42 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 15 Jun 1999 16:42:46 +0000 (16:42 +0000)
* cp-tree.h (class_cache_firstobj): Declare.
(maybe_push_cache_obstack): Rename to push_cache_obstack.
* class.c (permanent_obstack): Remove declaration.
(class_cache_firstobj): Make it global.
(add_method): Don't use permanent_obstack directly.
(pushclass): Only free the class_cache_obstack if we know how far
back to free it.
(maybe_push_cache_obstack): Rename to push_cache_obstack.
* decl.c: Remove dead comment.
(saved_scope): Add class_cache_firstobj.
(push_to_top_level): Save it.
(pop_from_top_level): Restore it.
(push_class_level_binding): Use push_cache_obstack, not
maybe_push_cache_obstack.
* search.c (push_class_decls): Likewise.

From-SVN: r27534

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/search.c

index 99386f1b1fb0f1797db00e386d25ee134c906199..0f87c30c2db230003b621e665a4534ecb200da7b 100644 (file)
@@ -1,3 +1,21 @@
+1999-06-15  Mark Mitchell  <mark@codesourcery.com>
+
+       * cp-tree.h (class_cache_firstobj): Declare.
+       (maybe_push_cache_obstack): Rename to push_cache_obstack.
+       * class.c (permanent_obstack): Remove declaration.
+       (class_cache_firstobj): Make it global.
+       (add_method): Don't use permanent_obstack directly.
+       (pushclass): Only free the class_cache_obstack if we know how far
+       back to free it.
+       (maybe_push_cache_obstack): Rename to push_cache_obstack.
+       * decl.c: Remove dead comment.
+       (saved_scope): Add class_cache_firstobj.
+       (push_to_top_level): Save it.
+       (pop_from_top_level): Restore it.
+       (push_class_level_binding): Use push_cache_obstack, not
+       maybe_push_cache_obstack.
+       * search.c (push_class_decls): Likewise.
+       
 1999-06-14  Martin von Löwis  <loewis@informatik.hu-berlin.de>
 
        * pt.c (tsubst_friend_function): Push into namespace of friend
index 4fe5353edb6272816a12aa369775f987bafa92c6..a04d2a05e016d9e84eec36b99aec15efe49336d7 100644 (file)
@@ -36,8 +36,6 @@ Boston, MA 02111-1307, USA.  */
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
 
-extern struct obstack permanent_obstack;
-
 /* This is how we tell when two virtual member functions are really the
    same.  */
 #define SAME_FN(FN1DECL, FN2DECL) (DECL_ASSEMBLER_NAME (FN1DECL) == DECL_ASSEMBLER_NAME (FN2DECL))
@@ -90,7 +88,7 @@ tree previous_class_values;   /* TREE_LIST: copy of the class_shadowed list
 static struct obstack class_cache_obstack;
 /* The first object allocated on that obstack.  We can use
    obstack_free with tis value to free the entire obstack.  */
-static char *class_cache_firstobj;
+char *class_cache_firstobj;
 
 struct base_info;
 
@@ -1136,7 +1134,8 @@ void
 add_method (type, fields, method)
      tree type, *fields, method;
 {
-  push_obstacks (&permanent_obstack, &permanent_obstack);
+  push_obstacks_nochange ();
+  end_temporary_allocation ();
 
   /* Setting the DECL_CONTEXT and DECL_CLASS_CONTEXT here is probably
      redundant.  */
@@ -4440,7 +4439,8 @@ pushclass (type, modify)
       invalidate_class_lookup_cache ();
 
       /* Now, free the obstack on which we cached all the values.  */
-      obstack_free (&class_cache_obstack, class_cache_firstobj);
+      if (class_cache_firstobj)
+       obstack_free (&class_cache_obstack, class_cache_firstobj);
       class_cache_firstobj 
        = (char*) obstack_finish (&class_cache_obstack);
     }
@@ -5197,7 +5197,7 @@ print_class_statistics ()
    effect is undone by pop_obstacks.  */
 
 void
-maybe_push_cache_obstack ()
+push_cache_obstack ()
 {
   static int cache_obstack_initialized;
 
index 4971b7999d4bde0635a865534f8005cc389525e0..4d243b4a53b374f6b0d95a337c9830b56a5d0c45 100644 (file)
@@ -2253,6 +2253,9 @@ extern int current_class_depth;
 extern tree current_lang_name;
 extern tree lang_name_cplusplus, lang_name_c, lang_name_java;
 
+/* The low-water mark on the class-cache obstack.  */
+extern char *class_cache_firstobj;
+
 /* Points to the name of that function. May not be the DECL_NAME
    of CURRENT_FUNCTION_DECL due to overloading */
 extern tree original_function_name;
@@ -2744,7 +2747,7 @@ extern void push_lang_context                     PROTO((tree));
 extern void pop_lang_context                   PROTO((void));
 extern tree instantiate_type                   PROTO((tree, tree, int));
 extern void print_class_statistics             PROTO((void));
-extern void maybe_push_cache_obstack           PROTO((void));
+extern void push_cache_obstack                 PROTO((void));
 extern unsigned HOST_WIDE_INT skip_rtti_stuff  PROTO((tree *, tree));
 extern void build_self_reference               PROTO((void));
 extern void warn_hidden                                PROTO((tree));
index b941bb867435dfb2c4a0e3fb6b9469665f6dbfe5..1fc452551dce4e2287b761f1203931bce8e789c3 100644 (file)
@@ -63,8 +63,6 @@ extern tree global_namespace;
 extern void (*print_error_function) PROTO((char *));
 extern int (*valid_lang_attribute) PROTO ((tree, tree, tree, tree));
 
-/* Stack of places to restore the search obstack back to.  */
-   
 /* Obstack used for remembering local class declarations (like
    enums and static (const) members.  */
 #include "stack.h"
@@ -2466,6 +2464,7 @@ struct saved_scope {
   tree previous_class_type, previous_class_values;
   int processing_specialization;
   int processing_explicit_instantiation;
+  char *class_cache_firstobj;
 };
 static struct saved_scope *current_saved_scope;
 
@@ -2583,6 +2582,7 @@ maybe_push_to_top_level (pseudo)
   s->processing_template_decl = processing_template_decl;
   s->previous_class_type = previous_class_type;
   s->previous_class_values = previous_class_values;
+  s->class_cache_firstobj = class_cache_firstobj;
   s->processing_specialization = processing_specialization;
   s->processing_explicit_instantiation = processing_explicit_instantiation;
 
@@ -2598,6 +2598,7 @@ maybe_push_to_top_level (pseudo)
   shadowed_labels = NULL_TREE;
   minimal_parse_mode = 0;
   previous_class_type = previous_class_values = NULL_TREE;
+  class_cache_firstobj = 0;
   processing_specialization = 0;
   processing_explicit_instantiation = 0;
   current_template_parms = NULL_TREE;
@@ -2669,6 +2670,7 @@ pop_from_top_level ()
   previous_class_values = s->previous_class_values;
   processing_specialization = s->processing_specialization;
   processing_explicit_instantiation = s->processing_explicit_instantiation;
+  class_cache_firstobj = s->class_cache_firstobj;
 
   free (s);
 
@@ -4471,7 +4473,7 @@ push_class_level_binding (name, x)
      IDENTIFIER_CLASS_VALUE.  */
   if (push_class_binding (name, x))
     {
-      maybe_push_cache_obstack ();
+      push_cache_obstack ();
       class_binding_level->class_shadowed
        = tree_cons (name, IDENTIFIER_CLASS_VALUE (name),
                     class_binding_level->class_shadowed);
index 9bac6e6ad49a75c3132aa7d652c9c9ea1cfc9d1f..75a1ac2c8c5337e19a40642e28d45646ce04e930 100644 (file)
@@ -2982,7 +2982,7 @@ push_class_decls (type)
   /* Build up all the relevant bindings and such on the cache
      obstack.  That way no memory is wasted when we throw away the
      cache later.  */
-  maybe_push_cache_obstack ();
+  push_cache_obstack ();
 
   /* Enter type declarations and mark.  */
   dfs_walk (TYPE_BINFO (type), dfs_push_type_decls, unmarked_pushdecls_p, 0);
@@ -2990,7 +2990,7 @@ push_class_decls (type)
   /* Enter non-type declarations and unmark.  */
   dfs_walk (TYPE_BINFO (type), dfs_push_decls, marked_pushdecls_p, 0);
 
-  /* Undo the call to maybe_push_cache_obstack above.  */
+  /* Undo the call to push_cache_obstack above.  */
   pop_obstacks ();
 
   current_obstack = ambient_obstack;