aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-09-06 02:43:09 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-09-06 02:43:09 +0000
commit9cd64686e8f8f61a283ea72613b2c4acac4cf985 (patch)
treee2a685bcbfc3b5ef40f703f25a36b461437c4c79 /gcc
parent565e3f3ec215eb47c30758a8944a6efce5d1fbb1 (diff)
downloadgcc-9cd64686e8f8f61a283ea72613b2c4acac4cf985.zip
gcc-9cd64686e8f8f61a283ea72613b2c4acac4cf985.tar.gz
gcc-9cd64686e8f8f61a283ea72613b2c4acac4cf985.tar.bz2
Get ready for garbage collection.
* Makefile.in (CXX_TREE_H): Add varray.h (lex.o): Depend on ggc.h. (decl.o): Likewise. (decl2.o): Likewise. (method.o): Likewise. (search.o): Likewise. (pt.o): Likewise. (repo.o): Likewise. * class.c: Include ggc.h. (current_class_name): Remove. (current_class_type): Likewise. (current_access_specifier): Likewise. (previous_class_type): Likewise. (previous_class_values): Likewise. (class_cache_firstobj): Likewise. (current_lang_base): Likewise. (current_lang_stack): Likewise. (current_lang_stacksize): Likewise. (lang_name_c): Likewise. (lang_name_cplusplus): Likewise. (lang_name_java): Likewise. (current_lang_name): Likewise. (base_layout_decl): Likewise. (access_default_node): Likewise. (access_public_node): Likewise. (access_protected_node): Likewise. (access_private_node): Likewise. (access_default_virtual_node): Likewise. (access_public_virtual_node): Likewise. (access_protected_virtual_node): Likewise. (access_private_virtual_node): Likewise. (signed_zero_node): Likewise. (init_class_processing): Don't build base_layout_decl. (push_lang_context): Adjust now that current_lang_base is a varray. (pop_lang_context): Likewise. * cp-tree.h: Include varray.h. (cp_global_trees): Add access_default, access_public, access_protected, access_private, access_default_virtual, access_public_virtual, access_protected_virtual, access_private_virtual, ctor_identifier, delta2_identifier, delta_identifier, dtor_identifier, in_charge_identifier, index_identifier, nelts_identifier, this_identifier, pfn_identifier, pfn_or_delta2_identifier, vptr_identifier, lang_name_c, lang_name_cplusplus, lang_name_java, empty_except_spec, null, jclass, minus_one, terminate. (saved_scope): Move here from decl.c. Define globals in terms of saved_scope: current_namespace, current_class_name, current_class_type, current_access_specifier, current_lang_stack, current_lang_base, current_lang_name, current_function_parms, current_template_parms, processing_template_decl, processing_specialization, processing_explicit_instantiation, previous_class_type, previous_class_values, class_cache_firstobj. (scope_chain): New variable. (init_pt): New function. * decl.c (current_namespace): Remove. (this_identifier, in_charge_identifier, ctor_identifier): Likewise. (dtor_identifier, pfn_identifier, index_identifier): Likewise. (delta_identifier, delta2_identifier): Likewise. (pfn_or_delta2_identifier, tag_identifier): Likewise (vt_off_identifier, empty_except_spec, null_node): Likewise. (current_function_parms, current_lang_base): Remove. (current_lang_stack, previous_class_values): Remove. (class_binding_level): Macroize. (saved_scope): Remove. (current_saved_scope): Rename to scope_chain. (mark_saved_scope): Adjust for new scope structure. (maybe_push_to_top_level): Likewise. (pop_from_top_level): Likewise. (duplicate_decls): Adjust now that current_lang_base is a varray. (build_typename_type): Call ggc_add_tree_hash_table_root. (init_decl_processing): Call init_pt. Call push_to_top_level to set up globals. Add GC roots. (xref_basetypes): Adjust now that current_lang_base is a varray. * decl.h (this_identifier): Remove. (in_charge_identifier): Likewise. * decl2.c: Don't include varray.h. (current_namespace): Remove. (init_decl2): Add GC roots. * except.c (Terminate): Remove. (init_exception_processing): Use terminate_node instead. (build_terminate_handler): Likewise. * init.c (nc_nelts_field_id): Remove. (minus_one): Likewise. (init_init_processing): Use minus_one_node and nelts_identifier instead. Add GC roots. (jclass_node): Remove. (build_new_1): Use nelts_identifier. (build_vec_init): Likewise. (build_vec_delete): Likewise. * lex.c: Include ggc.h. (defarg_fn): Move declaration early. (defarg_parms): Likewise. (init_parse): Add GC roots. (handle_cp_pragma): Remove redundant declaration of pending_vtables. * method.c: Include ggc.h. (btypelist): Make it a varray. All uses changed. (ktypelist): Likewise. (init_method): Add GC roots. * pt.c: Don't include varray.h. Include ggc.h. (current_template_parms): Remove. (processing_template_decl): Likewise. (processing_specialization): Likewise. (processing_explicit_instantiation): Likewise. (init_pt): New function. * repo.c: Include ggc.h. (init_repo): Add GC roots. * search.c: Don't include varray.h. (_vptr_name): Remove. (lookup_field_1): Use vtpr_identifier instead. (expand_indirect_vtbls_init): Remove redundant declaration of in_charge_identifier. (init_search_processing): Use vptr_identifier. From-SVN: r29135
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog117
-rw-r--r--gcc/cp/Makefile.in18
-rw-r--r--gcc/cp/class.c60
-rw-r--r--gcc/cp/cp-tree.h211
-rw-r--r--gcc/cp/decl.c206
-rw-r--r--gcc/cp/decl.h5
-rw-r--r--gcc/cp/decl2.c10
-rw-r--r--gcc/cp/except.c13
-rw-r--r--gcc/cp/init.c28
-rw-r--r--gcc/cp/lex.c32
-rw-r--r--gcc/cp/method.c116
-rw-r--r--gcc/cp/pt.c17
-rw-r--r--gcc/cp/repo.c4
-rw-r--r--gcc/cp/search.c8
14 files changed, 464 insertions, 381 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3bb762b..9318c0b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,120 @@
+1999-09-05 Mark Mitchell <mark@codesourcery.com>
+
+ Get ready for garbage collection.
+ * Makefile.in (CXX_TREE_H): Add varray.h
+ (lex.o): Depend on ggc.h.
+ (decl.o): Likewise.
+ (decl2.o): Likewise.
+ (method.o): Likewise.
+ (search.o): Likewise.
+ (pt.o): Likewise.
+ (repo.o): Likewise.
+ * clas.c: Include ggc.h.
+ (current_class_name): Remove.
+ (current_class_type): Likewise.
+ (current_access_specifier): Likewise.
+ (previous_class_type): Likewise.
+ (previous_class_values): Likewise.
+ (class_cache_firstobj): Likewise.
+ (current_lang_base): Likewise.
+ (current_lang_stack): Likewise.
+ (current_lang_stacksize): Likewise.
+ (lang_name_c): Likewise.
+ (lang_name_cplusplus): Likewise.
+ (lang_name_java): Likewise.
+ (current_lang_name): Likewise.
+ (base_layout_decl): Likewise.
+ (access_default_node): Likewise.
+ (access_public_node): Likewise.
+ (access_protected_node): Likewise.
+ (access_private_node): Likewise.
+ (access_default_virtual_node): Likewise.
+ (access_public_virtual_node): Likewise.
+ (access_protected_virtual_node): Likewise.
+ (access_private_virtual_node): Likewise.
+ (signed_zero_node): Likewise.
+ (init_class_processing): Don't build base_layout_decl.
+ (push_lang_context): Adjust now that current_lang_base is a varray.
+ (pop_lang_context): Likewise.
+ * cp-tree.h: Include varray.h.
+ (cp_global_trees): Add access_default, access_public,
+ access_protected, access_private, access_default_virtual,
+ access_public_virtual, access_protected_virtual,
+ access_private_virtual, ctor_identifier, delta2_identifier,
+ delta_identifier, dtor_identifier, in_charge_identifier,
+ index_identifier, nelts_identifier, this_identifier,
+ pfn_identifier, pfn_or_delta2_identifier, vptr_identifier,
+ lang_name_c, lang_name_cplusplus, lang_name_java,
+ empty_except_spec, null, jclass, minus_one, terminate.
+ (saved_scope): Move here from decl.c. Define globals in terms of
+ saved_scope: current_namespace, current_class_name,
+ current_class_type, current_access_specifier, current_lang_stack,
+ current_lang_base, current_lang_name, current_function_parms,
+ current_template_parms, processing_template_decl,
+ processing_specialization, processing_explicit_instantiation,
+ previous_class_type, previous_class_values, class_cache_firstobj.
+ (scope_chain): New variable.
+ (init_pt): New function.
+ * decl.c (current_namespace): Remove.
+ (this_identifier, in_charge_identifier, ctor_identifier): Likewise.
+ (dtor_identifier, pfn_identifier, index_identifier): Likewise.
+ (delta_identifier, delta2_identifier): Likewise.
+ (pfn_or_delta2_identifier, tag_identifier): Likewise
+ (vt_off_identifier, empty_except_spec, null_node): Likewise.
+ (current_function_parms, current_lang_base): Remove.
+ (current_lang_stack, previous_class_values): Remove.
+ (class_binding_level): Macroize.
+ (saved_scope): Remove.
+ (current_saved_scope): Rename to scope_chain.
+ (mark_saved_scope): Adjust for new scope structure.
+ (maybe_push_to_top_level): Likewise.
+ (pop_from_top_level): Likewise.
+ (duplicate_decls): Adjust now that current_lang_base is a varray.
+ (build_typename_type): Call ggc_add_tree_hash_table_root.
+ (init_decl_processing): Call init_pt. Call push_to_top_level to
+ set up globals. Add GC roots.
+ (xref_basetypes): Adjust now that current_lang_base is a varray.
+ * decl.h (this_identifier): Remove.
+ (in_charge_identifier): Likewise.
+ * decl2.c: Don't include varray.h.
+ (current_namespace): Remove.
+ (init_decl2): Add GC roots.
+ * except.c (Terminate): Remove.
+ (init_exception_processing): Use terminate_node instead.
+ (build_terminate_handler): Likewise.
+ * init.c (nc_nelts_field_id): Remove.
+ (minus_one): Likewise.
+ (init_init_processing): Use minus_one_node and nelts_identifier
+ instead. Add GC roots.
+ (jclass_node): Remove.
+ (build_new_1): Use nelts_identifier.
+ (build_vec_init): Likewise.
+ (build_vec_delete): Likewise.
+ * lex.c: Include ggc.h.
+ (defarg_fn): Move declaration early.
+ (defarg_parms): Likewise.
+ (init_parse): Add GC roots.
+ (handle_cp_pragma): Remove redundant declaration of
+ pending_vtables.
+ * method.c: Include ggc.h.
+ (btypelist): Make it a varray. All uses changed.
+ (ktypelist): Likewise.
+ (init_method): Add GC roots.
+ * pt.c: Don't include varray.h. Include ggc.h.
+ (current_template_parms): Remove.
+ (processing_template_decl): Likewise.
+ (processing_specialization): Likewise.
+ (processing_explicit_instantiation): Likewise.
+ (init_pt): New function.
+ * repo.c: Include ggc.h.
+ (init_repo): Add GC roots.
+ * search.c: Don't include varray.h.
+ (_vptr_name): Remove.
+ (lookup_field_1): Use vtpr_identifier instead.
+ (expand_indirect_vtbls_init): Remove redundant declaration of
+ in_charge_identifier.
+ (init_search_processing): Use vptr_identifier.
+
1999-09-05 Richard Henderson <rth@cygnus.com>
Bernd Schmidt <bernds@cygnus.co.uk>
Mark Mitchell <mark@codesourcery.com>
diff --git a/gcc/cp/Makefile.in b/gcc/cp/Makefile.in
index c01bd5e..07e0f83 100644
--- a/gcc/cp/Makefile.in
+++ b/gcc/cp/Makefile.in
@@ -202,7 +202,7 @@ RTL_H = $(srcdir)/../rtl.h $(srcdir)/../rtl.def \
TREE_H = $(srcdir)/../tree.h $(srcdir)/../real.h $(srcdir)/../tree.def \
$(srcdir)/../machmode.h $(srcdir)/../machmode.def
CXX_TREE_H = $(TREE_H) cp-tree.h $(srcdir)/../c-common.h cp-tree.def \
- $(srcdir)/../function.h
+ $(srcdir)/../function.h $(srcdir)/../varray.h
PARSE_H = $(srcdir)/parse.h
PARSE_C = $(srcdir)/parse.c
EXPR_H = $(srcdir)/../expr.h ../insn-codes.h
@@ -241,17 +241,16 @@ spew.o : spew.c $(CONFIG_H) $(CXX_TREE_H) $(PARSE_H) $(srcdir)/../flags.h \
lex.o : lex.c $(CONFIG_H) $(CXX_TREE_H) \
$(PARSE_H) input.c $(srcdir)/../flags.h hash.h lex.h \
$(srcdir)/../c-pragma.h $(srcdir)/../system.h $(srcdir)/../toplev.h \
- $(srcdir)/../output.h $(srcdir)/../mbchar.h
+ $(srcdir)/../output.h $(srcdir)/../mbchar.h $(srcdir)/../ggc.h
decl.o : decl.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
lex.h decl.h $(srcdir)/../stack.h $(srcdir)/../output.h \
$(srcdir)/../except.h $(srcdir)/../system.h $(srcdir)/../toplev.h \
- $(srcdir)/../hash.h
+ $(srcdir)/../hash.h $(srcdir)/../ggc.h
decl2.o : decl2.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
lex.h decl.h $(EXPR_H) $(srcdir)/../except.h \
$(srcdir)/../output.h $(srcdir)/../except.h $(srcdir)/../system.h \
$(srcdir)/../toplev.h $(srcdir)/../dwarf2out.h $(srcdir)/../dwarfout.h \
- $(srcdir)/../../include/splay-tree.h $(srcdir)/../varray.h \
- $(srcdir)/../ggc.h
+ $(srcdir)/../../include/splay-tree.h $(srcdir)/../ggc.h
typeck2.o : typeck2.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
$(srcdir)/../system.h $(srcdir)/../toplev.h
typeck.o : typeck.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \
@@ -266,12 +265,11 @@ friend.o : friend.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \
init.o : init.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \
$(EXPR_H) $(srcdir)/../system.h $(srcdir)/../toplev.h $(srcdir)/../ggc.h
method.o : method.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \
- $(srcdir)/../toplev.h
+ $(srcdir)/../toplev.h $(srcdir)/../ggc.h
cvt.o : cvt.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h decl.h \
$(srcdir)/../flags.h $(srcdir)/../toplev.h $(srcdir)/../convert.h
search.o : search.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../stack.h \
- $(srcdir)/../flags.h $(srcdir)/../system.h $(srcdir)/../toplev.h \
- $(srcdir)/../varray.h
+ $(srcdir)/../flags.h $(srcdir)/../system.h $(srcdir)/../toplev.h
tree.o : tree.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
$(srcdir)/../system.h $(srcdir)/../toplev.h
ptree.o : ptree.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h
@@ -284,13 +282,13 @@ expr.o : expr.c $(CONFIG_H) $(CXX_TREE_H) $(RTL_H) $(srcdir)/../flags.h \
xref.o : xref.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../input.h \
$(srcdir)/../system.h $(srcdir)/../toplev.h
pt.o : pt.c $(CONFIG_H) $(CXX_TREE_H) decl.h $(PARSE_H) lex.h \
- $(srcdir)/../system.h $(srcdir)/../toplev.h
+ $(srcdir)/../system.h $(srcdir)/../toplev.h $(srcdir)/../ggc.h
error.o : error.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \
$(srcdir)/../toplev.h
errfn.o : errfn.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \
$(srcdir)/../toplev.h
repo.o : repo.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \
- $(srcdir)/../toplev.h
+ $(srcdir)/../toplev.h $(srcdir)/../ggc.h
semantics.o: semantics.c $(CONFIG_H) $(CXX_TREE_H) lex.h \
$(srcdir)/../except.h $(srcdir)/../system.h $(srcdir)/../toplev.h
dump.o: dump.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 2a0babb..7b50870 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA. */
#include "output.h"
#include "toplev.h"
#include "splay-tree.h"
+#include "ggc.h"
#include "obstack.h"
#define obstack_chunk_alloc xmalloc
@@ -71,19 +72,8 @@ typedef struct class_stack_node {
static int current_class_stack_size;
static class_stack_node_t current_class_stack;
-/* The following two can be derived from the previous one */
-tree current_class_name; /* IDENTIFIER_NODE: name of current class */
-tree current_class_type; /* _TYPE: the type of the current class */
-tree current_access_specifier;
-tree previous_class_type; /* _TYPE: the previous type that was a class */
-tree previous_class_values; /* TREE_LIST: copy of the class_shadowed list
- when leaving an outermost class scope. */
-
/* The obstack on which the cached class declarations are kept. */
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. */
-char *class_cache_firstobj;
struct base_info;
@@ -137,29 +127,6 @@ static tree build_vtbl_initializer PROTO((tree));
static int count_fields PROTO((tree));
static int add_fields_to_vec PROTO((tree, tree, int));
-/* Way of stacking language names. */
-tree *current_lang_base, *current_lang_stack;
-int current_lang_stacksize;
-
-/* Names of languages we recognize. */
-tree lang_name_c, lang_name_cplusplus, lang_name_java;
-tree current_lang_name;
-
-/* When layout out an aggregate type, the size of the
- basetypes (virtual and non-virtual) is passed to layout_record
- via this node. */
-static tree base_layout_decl;
-
-/* Constants used for access control. */
-tree access_default_node; /* 0 */
-tree access_public_node; /* 1 */
-tree access_protected_node; /* 2 */
-tree access_private_node; /* 3 */
-tree access_default_virtual_node; /* 4 */
-tree access_public_virtual_node; /* 5 */
-tree access_protected_virtual_node; /* 6 */
-tree access_private_virtual_node; /* 7 */
-
/* Variables shared between class.c and call.c. */
#ifdef GATHER_STATISTICS
@@ -780,8 +747,6 @@ build_vtable (binfo, type)
return decl;
}
-extern tree signed_size_zero_node;
-
/* Give TYPE a new virtual function table which is initialized
with a skeleton-copy of its original initialization. The only
entry that changes is the `delta' entry, so we can really
@@ -4488,10 +4453,6 @@ init_class_processing ()
= (class_stack_node_t) xmalloc (current_class_stack_size
* sizeof (struct class_stack_node));
- current_lang_stacksize = 10;
- current_lang_base = (tree *)xmalloc(current_lang_stacksize * sizeof (tree));
- current_lang_stack = current_lang_base;
-
access_default_node = build_int_2 (0, 0);
access_public_node = build_int_2 (1, 0);
access_protected_node = build_int_2 (2, 0);
@@ -4501,10 +4462,6 @@ init_class_processing ()
access_protected_virtual_node = build_int_2 (6, 0);
access_private_virtual_node = build_int_2 (7, 0);
- /* Keep these values lying around. */
- base_layout_decl = build_lang_decl (FIELD_DECL, NULL_TREE, error_mark_node);
- TREE_TYPE (base_layout_decl) = make_node (RECORD_TYPE);
-
gcc_obstack_init (&class_obstack);
}
@@ -4736,13 +4693,13 @@ push_lang_context (name)
tree name;
{
*current_lang_stack++ = current_lang_name;
- if (current_lang_stack >= current_lang_base + current_lang_stacksize)
+ if (current_lang_stack - &VARRAY_TREE (current_lang_base, 0)
+ >= (ptrdiff_t) VARRAY_SIZE (current_lang_base))
{
- current_lang_base
- = (tree *)xrealloc (current_lang_base,
- sizeof (tree) * (current_lang_stacksize + 10));
- current_lang_stack = current_lang_base + current_lang_stacksize;
- current_lang_stacksize += 10;
+ size_t old_size = VARRAY_SIZE (current_lang_base);
+
+ VARRAY_GROW (current_lang_base, old_size + 10);
+ current_lang_stack = &VARRAY_TREE (current_lang_base, old_size);
}
if (name == lang_name_cplusplus)
@@ -4781,6 +4738,9 @@ push_lang_context (name)
void
pop_lang_context ()
{
+ /* Clear the current entry so that garbage collector won't hold on
+ to it. */
+ *current_lang_stack = NULL_TREE;
current_lang_name = *--current_lang_stack;
if (current_lang_name == lang_name_cplusplus
|| current_lang_name == lang_name_java)
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index cdb93e3..14231e8 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -21,6 +21,7 @@ Boston, MA 02111-1307, USA. */
#include "c-common.h"
#include "function.h"
+#include "varray.h"
#ifndef _CP_TREE_H
#define _CP_TREE_H
@@ -390,6 +391,37 @@ enum cp_tree_index
CPTI_ABORT_FNDECL,
CPTI_GLOBAL_DELETE_FNDECL,
+ CPTI_ACCESS_DEFAULT,
+ CPTI_ACCESS_PUBLIC,
+ CPTI_ACCESS_PROTECTED,
+ CPTI_ACCESS_PRIVATE,
+ CPTI_ACCESS_DEFAULT_VIRTUAL,
+ CPTI_ACCESS_PUBLIC_VIRTUAL,
+ CPTI_ACCESS_PROTECTED_VIRTUAL,
+ CPTI_ACCESS_PRIVATE_VIRTUAL,
+
+ CPTI_CTOR_IDENTIFIER,
+ CPTI_DELTA2_IDENTIFIER,
+ CPTI_DELTA_IDENTIFIER,
+ CPTI_DTOR_IDENTIFIER,
+ CPTI_IN_CHARGE_IDENTIFIER,
+ CPTI_INDEX_IDENTIFIER,
+ CPTI_NELTS_IDENTIFIER,
+ CPTI_THIS_IDENTIFIER,
+ CPTI_PFN_IDENTIFIER,
+ CPTI_PFN_OR_DELTA2_IDENTIFIER,
+ CPTI_VPTR_IDENTIFIER,
+
+ CPTI_LANG_NAME_C,
+ CPTI_LANG_NAME_CPLUSPLUS,
+ CPTI_LANG_NAME_JAVA,
+
+ CPTI_EMPTY_EXCEPT_SPEC,
+ CPTI_NULL,
+ CPTI_JCLASS,
+ CPTI_MINUS_ONE,
+ CPTI_TERMINATE,
+
CPTI_MAX
};
@@ -433,6 +465,129 @@ extern tree cp_global_trees[CPTI_MAX];
#define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL]
#define global_delete_fndecl cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL]
+/* Define the sets of attributes that member functions and baseclasses
+ can have. These are sensible combinations of {public,private,protected}
+ cross {virtual,non-virtual}. */
+
+#define access_default_node cp_global_trees[CPTI_ACCESS_DEFAULT]
+#define access_public_node cp_global_trees[CPTI_ACCESS_PUBLIC]
+#define access_protected_node cp_global_trees[CPTI_ACCESS_PROTECTED]
+#define access_private_node cp_global_trees[CPTI_ACCESS_PRIVATE]
+#define access_default_virtual_node cp_global_trees[CPTI_ACCESS_DEFAULT_VIRTUAL]
+#define access_public_virtual_node cp_global_trees[CPTI_ACCESS_PUBLIC_VIRTUAL]
+#define access_protected_virtual_node cp_global_trees[CPTI_ACCESS_PROTECTED_VIRTUAL]
+#define access_private_virtual_node cp_global_trees[CPTI_ACCESS_PRIVATE_VIRTUAL]
+
+/* We cache these tree nodes so as to call get_identifier less
+ frequently. */
+
+#define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER]
+#define delta2_identifier cp_global_trees[CPTI_DELTA2_IDENTIFIER]
+#define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER]
+#define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER]
+#define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER]
+#define index_identifier cp_global_trees[CPTI_INDEX_IDENTIFIER]
+#define nelts_identifier cp_global_trees[CPTI_NELTS_IDENTIFIER]
+#define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER]
+#define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER]
+#define pfn_or_delta2_identifier cp_global_trees[CPTI_PFN_OR_DELTA2_IDENTIFIER]
+#define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER]
+
+#define lang_name_c cp_global_trees[CPTI_LANG_NAME_C]
+#define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
+#define lang_name_java cp_global_trees[CPTI_LANG_NAME_JAVA]
+
+/* Exception specifier used for throw(). */
+#define empty_except_spec cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC]
+
+/* The node for `__null'. */
+#define null_node cp_global_trees[CPTI_NULL]
+
+/* If non-NULL, a POINTER_TYPE equivalent to (java::lang::Class*). */
+#define jclass_node cp_global_trees[CPTI_JCLASS]
+
+/* A node for `(int) -1'. */
+#define minus_one_node cp_global_trees[CPTI_MINUS_ONE]
+
+/* The declaration for `std::terminate'. */
+#define terminate_node cp_global_trees[CPTI_TERMINATE]
+
+/* Global state. */
+
+struct saved_scope {
+ struct binding_level *old_binding_level;
+ tree old_bindings;
+ tree old_namespace;
+ struct saved_scope *prev;
+ tree class_name, class_type;
+ tree access_specifier;
+ tree function_decl;
+ struct binding_level *class_bindings;
+ varray_type lang_base;
+ tree *lang_stack;
+ tree lang_name;
+ tree x_function_parms;
+ tree template_parms;
+ HOST_WIDE_INT x_processing_template_decl;
+ tree x_previous_class_type;
+ tree x_previous_class_values;
+ int x_processing_specialization;
+ int x_processing_explicit_instantiation;
+ char *firstobj;
+};
+
+/* The current open namespace. */
+
+#define current_namespace scope_chain->old_namespace
+
+/* IDENTIFIER_NODE: name of current class */
+
+#define current_class_name scope_chain->class_name
+
+/* _TYPE: the type of the current class */
+
+#define current_class_type scope_chain->class_type
+
+/* When parsing a class definition, the access specifier most recently
+ given by the user, or, if no access specifier was given, the
+ default value appropriate for the kind of class (i.e., struct,
+ class, or union). */
+
+#define current_access_specifier scope_chain->access_specifier
+
+/* Pointer to the top of the language name stack. */
+
+#define current_lang_stack scope_chain->lang_stack
+#define current_lang_base scope_chain->lang_base
+#define current_lang_name scope_chain->lang_name
+
+/* Parsing a function declarator leaves a list of parameter names
+ or a chain or parameter decls here. */
+
+#define current_function_parms scope_chain->x_function_parms
+#define current_template_parms scope_chain->template_parms
+
+#define processing_template_decl scope_chain->x_processing_template_decl
+#define processing_specialization scope_chain->x_processing_specialization
+#define processing_explicit_instantiation scope_chain->x_processing_explicit_instantiation
+
+/* _TYPE: the previous type that was a class */
+
+#define previous_class_type scope_chain->x_previous_class_type
+
+/* This is a copy of the class_shadowed list of the previous class
+ binding contour when at global scope. It's used to reset
+ IDENTIFIER_CLASS_VALUEs when entering another class scope (i.e. a
+ cache miss). */
+
+#define previous_class_values scope_chain->x_previous_class_values
+
+/* The low-water mark on the class-cache obstack. */
+
+#define class_cache_firstobj scope_chain->firstobj
+
+extern struct saved_scope *scope_chain;
+
/* Global state pertinent to the current function. */
struct language_function
@@ -562,12 +717,12 @@ struct language_function
#define in_function_try_handler cp_function_chain->in_function_try_handler
extern tree current_function_return_value;
-extern tree current_namespace;
extern tree global_namespace;
extern tree ridpointers[];
extern tree ansi_opname[];
extern tree ansi_assopname[];
+extern tree null_pointer_node;
/* Nonzero means `$' can be in an identifier. */
@@ -2377,20 +2532,12 @@ extern tree type_for_size PROTO((unsigned, int));
extern int c_get_alias_set PROTO((tree));
/* in decl{2}.c */
-extern tree this_identifier;
-extern tree ctor_identifier, dtor_identifier;
-extern tree pfn_identifier;
-extern tree index_identifier;
-extern tree delta_identifier;
-extern tree delta2_identifier;
-extern tree pfn_or_delta2_identifier;
-extern tree tag_identifier;
-extern tree vt_off_identifier;
-extern tree empty_except_spec;
-
/* A node that is a list (length 1) of error_mark_nodes. */
extern tree error_mark_list;
+/* A list of virtual function tables we must make sure to write out. */
+extern tree pending_vtables;
+
/* Node for "pointer to (virtual) function".
This may be distinct from ptr_type_node so gdb can distinguish them. */
#define vfunc_ptr_type_node \
@@ -2400,8 +2547,6 @@ extern tree error_mark_list;
/* For building calls to `delete'. */
extern tree integer_two_node, integer_three_node;
-extern tree null_node;
-
extern tree anonymous_namespace_name;
/* in pt.c */
@@ -2416,9 +2561,6 @@ typedef enum unification_kind_t {
DEDUCE_EXACT
} unification_kind_t;
-extern tree current_template_parms;
-extern HOST_WIDE_INT processing_template_decl;
-
/* The template currently being instantiated, and where the instantiation
was triggered. */
struct tinst_level
@@ -2433,23 +2575,8 @@ extern void maybe_print_template_context PROTO ((void));
/* in class.c */
-/* When parsing a class definition, the access specifier most recently
- given by the user, or, if no access specifier was given, the
- default value appropriate for the kind of class (i.e., struct,
- class, or union). */
-extern tree current_access_specifier;
-
-extern tree current_class_name;
-extern tree current_class_type;
-extern tree previous_class_type;
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;
@@ -2634,20 +2761,6 @@ extern tree global_base_init_list;
&& MAIN_NAME_P (DECL_NAME (NODE)))
-/* Define the sets of attributes that member functions and baseclasses
- can have. These are sensible combinations of {public,private,protected}
- cross {virtual,non-virtual}. */
-
-/* in class.c. */
-extern tree access_default_node; /* 0 */
-extern tree access_public_node; /* 1 */
-extern tree access_protected_node; /* 2 */
-extern tree access_private_node; /* 3 */
-extern tree access_default_virtual_node; /* 4 */
-extern tree access_public_virtual_node; /* 5 */
-extern tree access_protected_virtual_node; /* 6 */
-extern tree access_private_virtual_node; /* 7 */
-
/* Things for handling inline functions. */
struct pending_inline
@@ -2715,9 +2828,6 @@ extern int at_eof;
enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
-/* The following two can be derived from the previous one */
-extern tree current_class_name; /* IDENTIFIER_NODE: name of current class */
-
/* Some macros for char-based bitfields. */
#define B_SET(a,x) (a[x>>3] |= (1 << (x&7)))
#define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7)))
@@ -3321,6 +3431,7 @@ extern void synthesize_method PROTO((tree));
extern tree get_id_2 PROTO((const char *, tree));
/* in pt.c */
+extern void init_pt PROTO ((void));
extern void check_template_shadow PROTO ((tree));
extern tree innermost_args PROTO ((tree));
extern tree tsubst PROTO ((tree, tree, int, tree));
@@ -3377,8 +3488,6 @@ extern void print_candidates PROTO((tree));
extern int instantiate_pending_templates PROTO((void));
extern tree tsubst_default_argument PROTO((tree, tree, tree));
-extern int processing_specialization;
-extern int processing_explicit_instantiation;
extern int processing_template_parmlist;
/* in repo.c */
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5f5e72f..93558bb 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -55,7 +55,6 @@ extern int current_class_depth;
extern tree static_ctors, static_dtors;
-extern tree current_namespace;
extern tree global_namespace;
extern int (*valid_lang_attribute) PROTO ((tree, tree, tree, tree));
@@ -294,6 +293,7 @@ tree unsigned_type_node;
tree ptr_type_node;
tree va_list_type_node;
+tree null_pointer_node;
/* Indicates that there is a type value in some namespace, although
that is not necessarily in scope at the moment. */
@@ -325,19 +325,6 @@ static int only_namespace_names;
#define original_result_rtx cp_function_chain->x_result_rtx
-/* C++: Keep these around to reduce calls to `get_identifier'.
- Identifiers for `this' in member functions and the auto-delete
- parameter for destructors. */
-tree this_identifier, in_charge_identifier;
-tree ctor_identifier, dtor_identifier;
-/* Used in pointer to member functions, in vtables, and in sigtables. */
-tree pfn_identifier, index_identifier, delta_identifier, delta2_identifier;
-tree pfn_or_delta2_identifier, tag_identifier;
-tree vt_off_identifier;
-
-/* Exception specifier used for throw(). */
-tree empty_except_spec;
-
struct named_label_list
{
struct binding_level *binding_level;
@@ -375,15 +362,9 @@ tree static_aggregates;
/* -- end of C++ */
-/* Two expressions that are constants with value zero.
- The first is of type `int', the second of type `void *'. */
+/* An expression of type `int' for the constant zero. */
tree integer_zero_node;
-tree null_pointer_node;
-
-/* The value for __null (NULL), namely, a zero of an integer type with
- the same number of bits as a pointer. */
-tree null_node;
/* A node for the integer constants 1, 2, and 3. */
@@ -398,23 +379,13 @@ static tree enum_next_value;
static int enum_overflow;
-/* Parsing a function declarator leaves a list of parameter names
- or a chain or parameter decls here. */
-
-tree last_function_parms;
-
/* Parsing a function declarator leaves here a chain of structure
and enum types declared in the parmlist. */
static tree last_function_parm_tags;
-/* After parsing the declarator that starts a function definition,
- `start_function' puts here the list of parameter names or chain of decls.
- `store_parm_decls' finds it here. */
-
-static tree current_function_parms;
-
/* Similar, for last_function_parm_tags. */
+tree last_function_parms;
static tree current_function_parm_tags;
/* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
@@ -462,10 +433,6 @@ extern int flag_huge_objects;
.common instead of .data at the expense of not flagging multiple
definitions. */
extern int flag_conserve_space;
-
-/* Pointers to the base and current top of the language name stack. */
-
-extern tree *current_lang_base, *current_lang_stack;
/* C and C++ flags are in decl2.c. */
@@ -480,11 +447,6 @@ extern tree *current_lang_base, *current_lang_stack;
extern int spew_debug;
-/* This is a copy of the class_shadowed list of the previous class binding
- contour when at global scope. It's used to reset IDENTIFIER_CLASS_VALUEs
- when entering another class scope (i.e. a cache miss). */
-extern tree previous_class_values;
-
/* A expression of value 0 with the same precision as a sizetype
node, but signed. */
tree signed_size_zero_node;
@@ -645,7 +607,7 @@ struct binding_level
/* The binding level of the current class, if any. */
-static struct binding_level *class_binding_level;
+#define class_binding_level scope_chain->class_bindings
/* A chain of binding_level structures awaiting reuse. */
@@ -2432,28 +2394,9 @@ pop_nested_namespace (ns)
local-value slots of all identifiers, so that only the global values
are at all visible. Simply setting current_binding_level to the global
scope isn't enough, because more binding levels may be pushed. */
-struct saved_scope {
- struct binding_level *old_binding_level;
- tree old_bindings;
- tree old_namespace;
- struct saved_scope *prev;
- tree class_name, class_type;
- tree access_specifier;
- tree function_decl;
- struct binding_level *class_bindings;
- tree *lang_base, *lang_stack, lang_name;
- int lang_stacksize;
- tree last_function_parms;
- tree template_parms;
- HOST_WIDE_INT processing_template_decl;
- 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;
+struct saved_scope *scope_chain;
-/* Mark ARG (which is really a struct saved_scoipe **) for GC. */
+/* Mark ARG (which is really a struct saved_scope **) for GC. */
static void
mark_saved_scope (arg)
@@ -2471,14 +2414,12 @@ mark_saved_scope (arg)
ggc_mark_tree (t->access_specifier);
ggc_mark_tree (t->function_decl);
if (t->lang_base)
- ggc_mark_tree (*t->lang_base);
- if (t->lang_stack)
- ggc_mark_tree (*t->lang_stack);
+ ggc_mark_tree_varray (t->lang_base);
ggc_mark_tree (t->lang_name);
- ggc_mark_tree (t->last_function_parms);
+ ggc_mark_tree (t->x_function_parms);
ggc_mark_tree (t->template_parms);
- ggc_mark_tree (t->previous_class_type);
- ggc_mark_tree (t->previous_class_values);
+ ggc_mark_tree (t->x_previous_class_type);
+ ggc_mark_tree (t->x_previous_class_values);
t = t->prev;
}
}
@@ -2543,15 +2484,16 @@ void
maybe_push_to_top_level (pseudo)
int pseudo;
{
- extern int current_lang_stacksize;
struct saved_scope *s
= (struct saved_scope *) xmalloc (sizeof (struct saved_scope));
- struct binding_level *b = current_binding_level;
+ struct binding_level *b;
tree old_bindings = NULL_TREE;
+ b = scope_chain ? current_binding_level : 0;
+
push_function_context_to (NULL_TREE);
- if (previous_class_type)
+ if (scope_chain && previous_class_type)
old_bindings = store_bindings (previous_class_values, old_bindings);
/* Have to include global_binding_level, because class-level decls
@@ -2577,35 +2519,19 @@ maybe_push_to_top_level (pseudo)
for (t = b->type_shadowed; t; t = TREE_CHAIN (t))
SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (t), TREE_VALUE (t));
}
-
- s->old_binding_level = current_binding_level;
+ if (scope_chain)
+ *s = *scope_chain;
+ s->old_binding_level = scope_chain ? current_binding_level : 0;
+ s->old_bindings = old_bindings;
+ s->prev = scope_chain;
+ scope_chain = s;
current_binding_level = b;
- s->old_namespace = current_namespace;
- s->class_name = current_class_name;
- s->class_type = current_class_type;
- s->access_specifier = current_access_specifier;
- s->function_decl = current_function_decl;
- s->class_bindings = class_binding_level;
- s->lang_stack = current_lang_stack;
- s->lang_base = current_lang_base;
- s->lang_stacksize = current_lang_stacksize;
- s->lang_name = current_lang_name;
- s->last_function_parms = last_function_parms;
- s->template_parms = current_template_parms;
- 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;
-
current_class_name = current_class_type = NULL_TREE;
current_function_decl = NULL_TREE;
class_binding_level = (struct binding_level *)0;
- current_lang_stacksize = 10;
- current_lang_stack = current_lang_base
- = (tree *) xmalloc (current_lang_stacksize * sizeof (tree));
+ VARRAY_TREE_INIT (current_lang_base, 10, "current_lang_base");
+ current_lang_stack = &VARRAY_TREE (current_lang_base, 0);
current_lang_name = lang_name_cplusplus;
strict_prototype = strict_prototypes_lang_cplusplus;
named_labels = NULL_TREE;
@@ -2617,10 +2543,6 @@ maybe_push_to_top_level (pseudo)
processing_template_decl = 0;
current_namespace = global_namespace;
- s->prev = current_saved_scope;
- s->old_bindings = old_bindings;
- current_saved_scope = s;
-
push_obstacks (&permanent_obstack, &permanent_obstack);
}
@@ -2633,8 +2555,7 @@ push_to_top_level ()
void
pop_from_top_level ()
{
- extern int current_lang_stacksize;
- struct saved_scope *s = current_saved_scope;
+ struct saved_scope *s = scope_chain;
tree t;
/* Clear out class-level bindings cache. */
@@ -2643,8 +2564,9 @@ pop_from_top_level ()
pop_obstacks ();
- current_binding_level = s->old_binding_level;
- current_saved_scope = s->prev;
+ VARRAY_FREE (current_lang_base);
+
+ scope_chain = s->prev;
for (t = s->old_bindings; t; )
{
tree save = t;
@@ -2654,34 +2576,16 @@ pop_from_top_level ()
SET_IDENTIFIER_TYPE_VALUE (id, TREE_VEC_ELT (t, 1));
IDENTIFIER_BINDING (id) = TREE_VEC_ELT (t, 2);
IDENTIFIER_CLASS_VALUE (id) = TREE_VEC_ELT (t, 3);
- }
+ }
t = TREE_CHAIN (t);
TREE_CHAIN (save) = free_binding_vecs;
free_binding_vecs = save;
}
- current_namespace = s->old_namespace;
- current_class_name = s->class_name;
- current_class_type = s->class_type;
- current_access_specifier = s->access_specifier;
- current_function_decl = s->function_decl;
- class_binding_level = s->class_bindings;
- free (current_lang_base);
- current_lang_base = s->lang_base;
- current_lang_stack = s->lang_stack;
- current_lang_name = s->lang_name;
- current_lang_stacksize = s->lang_stacksize;
+
if (current_lang_name == lang_name_cplusplus)
strict_prototype = strict_prototypes_lang_cplusplus;
else if (current_lang_name == lang_name_c)
strict_prototype = strict_prototypes_lang_c;
- last_function_parms = s->last_function_parms;
- current_template_parms = s->template_parms;
- processing_template_decl = s->processing_template_decl;
- previous_class_type = s->previous_class_type;
- 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);
@@ -3410,7 +3314,8 @@ duplicate_decls (newdecl, olddecl)
/* extern "C" int foo ();
int foo () { bar (); }
is OK. */
- if (current_lang_stack == current_lang_base)
+ if (current_lang_stack
+ == &VARRAY_TREE (current_lang_base, 0))
DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
else
{
@@ -5490,10 +5395,14 @@ build_typename_type (context, name, fullname, base_type)
push_obstacks (&permanent_obstack, &permanent_obstack);
- if (!ht.table
- && !hash_table_init (&ht, &hash_newfunc, &typename_hash,
- &typename_compare))
- fatal ("virtual memory exhausted");
+ if (!ht.table)
+ {
+ static struct hash_table *h = &ht;
+ if (!hash_table_init (&ht, &hash_newfunc, &typename_hash,
+ &typename_compare))
+ fatal ("virtual memory exhausted");
+ ggc_add_tree_hash_table_root (&h, 1);
+ }
/* The FULLNAME needs to exist for the life of the hash table, i.e.,
for the entire compilation. */
@@ -6092,14 +6001,6 @@ signal_catch (sig)
my_friendly_abort (0);
}
-#if 0
-/* Unused -- brendan 970107 */
-/* Array for holding types considered "built-in". These types
- are output in the module in which `main' is defined. */
-static tree *builtin_type_tdescs_arr;
-static int builtin_type_tdescs_len, builtin_type_tdescs_max;
-#endif
-
/* Push the declarations of builtin types into the namespace.
RID_INDEX, if < RID_MAX is the index of the builtin type
in the array RID_POINTERS. NAME is the name used when looking
@@ -6245,14 +6146,13 @@ init_decl_processing ()
cp_parse_init ();
init_decl2 ();
+ init_pt ();
- /* Create the global per-function variables. */
- push_function_context_to (NULL_TREE);
+ /* Create the global variables. */
+ push_to_top_level ();
/* Enter the global namespace. */
my_friendly_assert (global_namespace == NULL_TREE, 375);
- my_friendly_assert (current_lang_name == NULL_TREE, 375);
- current_lang_name = lang_name_cplusplus;
push_namespace (get_identifier ("::"));
global_namespace = current_namespace;
current_lang_name = NULL_TREE;
@@ -6704,7 +6604,6 @@ init_decl_processing ()
ggc_add_tree_root (c_global_trees, sizeof c_global_trees / sizeof(tree));
ggc_add_tree_root (cp_global_trees, sizeof cp_global_trees / sizeof(tree));
ggc_add_tree_root (&char_type_node, 1);
- ggc_add_tree_root (&current_function_decl, 1);
ggc_add_tree_root (&error_mark_node, 1);
ggc_add_tree_root (&integer_type_node, 1);
ggc_add_tree_root (&integer_three_node, 1);
@@ -6712,31 +6611,37 @@ init_decl_processing ()
ggc_add_tree_root (&integer_one_node, 1);
ggc_add_tree_root (&integer_zero_node, 1);
ggc_add_tree_root (&signed_size_zero_node, 1);
- ggc_add_tree_root (&named_labels, 1);
- ggc_add_tree_root (&null_pointer_node, 1);
ggc_add_tree_root (&size_one_node, 1);
ggc_add_tree_root (&size_zero_node, 1);
ggc_add_tree_root (&unsigned_type_node, 1);
+ ggc_add_tree_root (&ptr_type_node, 1);
+ ggc_add_tree_root (&null_pointer_node, 1);
+ ggc_add_tree_root (&va_list_type_node, 1);
ggc_add_tree_root (&void_type_node, 1);
ggc_add_root (&global_binding_level, 1, sizeof global_binding_level,
mark_binding_level);
- ggc_add_root (&current_saved_scope, 1, sizeof current_saved_scope,
- &mark_saved_scope);
+ ggc_add_root (&scope_chain, 1, sizeof scope_chain, &mark_saved_scope);
ggc_add_tree_root (&static_ctors, 1);
ggc_add_tree_root (&static_dtors, 1);
+ ggc_add_tree_root (&lastiddecl, 1);
ggc_add_tree_root (&enum_next_value, 1);
- ggc_add_tree_root (&last_function_parms, 1);
ggc_add_tree_root (&last_function_parm_tags, 1);
ggc_add_tree_root (&current_function_return_value, 1);
ggc_add_tree_root (&current_function_parms, 1);
ggc_add_tree_root (&current_function_parm_tags, 1);
+ ggc_add_tree_root (&last_function_parms, 1);
ggc_add_tree_root (&error_mark_list, 1);
- ggc_add_tree_root (&void_list_node, 1);
+
ggc_add_tree_root (&global_namespace, 1);
- ggc_add_tree_root (&current_namespace, 1);
ggc_add_tree_root (&global_type_node, 1);
ggc_add_tree_root (&anonymous_namespace_name, 1);
+
+ ggc_add_tree_root (&got_object, 1);
+ ggc_add_tree_root (&got_scope, 1);
+
+ ggc_add_tree_root (&current_lang_name, 1);
+ ggc_add_tree_root (&static_aggregates, 1);
}
/* Function to print any language-specific context for an error message. */
@@ -12644,7 +12549,8 @@ xref_basetypes (code_type_node, name, ref, binfo)
}
if (TYPE_FOR_JAVA (basetype)
- && current_lang_stack == current_lang_base)
+ && (current_lang_stack
+ == &VARRAY_TREE (current_lang_base, 0)))
TYPE_FOR_JAVA (ref) = 1;
/* Note that the BINFO records which describe individual
diff --git a/gcc/cp/decl.h b/gcc/cp/decl.h
index fcb247e..d6c376c 100644
--- a/gcc/cp/decl.h
+++ b/gcc/cp/decl.h
@@ -33,11 +33,6 @@ enum decl_context
/* We need this in here to get the decl_context definition. */
extern tree grokdeclarator PROTO((tree, tree, enum decl_context, int, tree));
-/* C++: Keep these around to reduce calls to `get_identifier'.
- Identifiers for `this' in member functions and the auto-delete
- parameter for destructors. */
-extern tree this_identifier, in_charge_identifier;
-
/* Parsing a function declarator leaves a list of parameter names
or a chain or parameter decls here. */
extern tree last_function_parms;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 76cebf8..169eba2 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -43,7 +43,6 @@ Boston, MA 02111-1307, USA. */
#include "dwarf2out.h"
#include "dwarfout.h"
#include "splay-tree.h"
-#include "varray.h"
#include "ggc.h"
#if USE_CPPLIB
@@ -128,9 +127,8 @@ int at_eof;
tree static_ctors, static_dtors;
-/* The current open namespace, and ::. */
+/* The :: namespace. */
-tree current_namespace;
tree global_namespace;
/* The stack for namespaces of current declarations. */
@@ -5276,4 +5274,10 @@ init_decl2 ()
{
ggc_add_tree_root (&decl_namespace_list, 1);
ggc_add_tree_varray_root (&saved_inlines, 1);
+ ggc_add_tree_varray_root (&pending_statics, 1);
+ ggc_add_tree_varray_root (&ssdf_decls, 1);
+ ggc_add_tree_root (&ssdf_decl, 1);
+ ggc_add_tree_root (&priority_decl, 1);
+ ggc_add_tree_root (&initialize_p_decl, 1);
+ ggc_add_tree_root (&pending_vtables, 1);
}
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index c5a80de..15e2e8f 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -151,11 +151,6 @@ asm (TEXT_SECTION_ASM_OP);
===================================================================== */
-/* local globals for function calls
- ====================================================================== */
-
-static tree Terminate;
-
/* ====================================================================== */
/* sets up all the global eh stuff that needs to be initialized at the
@@ -169,9 +164,9 @@ init_exception_processing ()
if (flag_honor_std)
push_namespace (get_identifier ("std"));
- Terminate = auto_function (get_identifier ("terminate"),
- vtype, NOT_BUILT_IN);
- TREE_THIS_VOLATILE (Terminate) = 1;
+ terminate_node = auto_function (get_identifier ("terminate"),
+ vtype, NOT_BUILT_IN);
+ TREE_THIS_VOLATILE (terminate_node) = 1;
if (flag_honor_std)
pop_namespace ();
@@ -500,7 +495,7 @@ static tree
build_terminate_handler ()
{
int yes = suspend_momentary ();
- tree term = build_function_call (Terminate, NULL_TREE);
+ tree term = build_function_call (terminate_node, NULL_TREE);
resume_momentary (yes);
return term;
}
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index e2e082b..b49dda3 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -50,11 +50,6 @@ static tree build_java_class_ref PROTO((tree));
static void expand_cleanup_for_base PROTO((tree, tree));
static tree get_temp_regvar PROTO((tree, tree));
-/* Cache the identifier nodes for the magic field of a new cookie. */
-static tree nc_nelts_field_id;
-
-static tree minus_one;
-
/* Set up local variable for this file. MUST BE CALLED AFTER
INIT_DECL_PROCESSING. */
@@ -64,20 +59,19 @@ void init_init_processing ()
{
tree fields[1];
- minus_one = build_int_2 (-1, -1);
+ minus_one_node = build_int_2 (-1, -1);
/* Define the structure that holds header information for
arrays allocated via operator new. */
BI_header_type = make_lang_type (RECORD_TYPE);
- nc_nelts_field_id = get_identifier ("nelts");
- fields[0] = build_lang_decl (FIELD_DECL, nc_nelts_field_id, sizetype);
+ nelts_identifier = get_identifier ("nelts");
+ fields[0] = build_lang_decl (FIELD_DECL, nelts_identifier, sizetype);
finish_builtin_type (BI_header_type, "__new_cookie", fields,
0, double_type_node);
BI_header_size = size_in_bytes (BI_header_type);
- ggc_add_tree_root (&current_base_init_list, 1);
- ggc_add_tree_root (&current_member_init_list, 1);
- ggc_add_tree_root (&minus_one, 1);
+ ggc_add_tree_root (&BI_header_type, 1);
+ ggc_add_tree_root (&BI_header_size, 1);
}
/* Subroutine of emit_base_init. For BINFO, initialize all the
@@ -2107,10 +2101,6 @@ build_new (placement, decl, init, use_global_new)
return rval;
}
-/* If non-NULL, a POINTER_TYPE equivalent to (java::lang::Class*). */
-
-static tree jclass_node = NULL_TREE;
-
/* Given a Java class, return a decl for the corresponding java.lang.Class. */
static tree
@@ -2328,7 +2318,7 @@ build_new_1 (exp)
build_pointer_type (BI_header_type),
rval, extra), NULL_PTR);
exp1 = build (MODIFY_EXPR, void_type_node,
- build_component_ref (cookie, nc_nelts_field_id,
+ build_component_ref (cookie, nelts_identifier,
NULL_TREE, 0),
nelts);
TREE_SIDE_EFFECTS (exp1) = 1;
@@ -2909,7 +2899,7 @@ build_vec_init (decl, base, maxindex, init, from_array)
if_stmt = begin_if_stmt ();
finish_if_stmt_cond (build (NE_EXPR, boolean_type_node,
- iterator, minus_one),
+ iterator, minus_one_node),
if_stmt);
/* Otherwise, loop through the elements. */
@@ -3004,7 +2994,7 @@ build_vec_init (decl, base, maxindex, init, from_array)
ptrdiff_type_node,
iterator,
integer_one_node),
- minus_one),
+ minus_one_node),
do_stmt);
finish_then_clause (if_stmt);
@@ -3372,7 +3362,7 @@ build_vec_delete (base, maxindex, auto_delete_vec, auto_delete,
tree cookie_addr = build (MINUS_EXPR, build_pointer_type (BI_header_type),
base, BI_header_size);
tree cookie = build_indirect_ref (cookie_addr, NULL_PTR);
- maxindex = build_component_ref (cookie, nc_nelts_field_id, NULL_TREE, 0);
+ maxindex = build_component_ref (cookie, nelts_identifier, NULL_TREE, 0);
do
type = TREE_TYPE (type);
while (TREE_CODE (type) == ARRAY_TYPE);
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 31999ff..72995f3 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -37,6 +37,7 @@ Boston, MA 02111-1307, USA. */
#include "c-pragma.h"
#include "toplev.h"
#include "output.h"
+#include "ggc.h"
#ifdef MULTIBYTE_CHARS
#include "mbchar.h"
@@ -173,6 +174,17 @@ static tree this_filename_time;
/* Array for holding counts of the numbers of tokens seen. */
extern int *token_count;
+
+/* When we see a default argument in a method declaration, we snarf it as
+ text using snarf_defarg. When we get up to namespace scope, we then go
+ through and parse all of them using do_pending_defargs. Since yacc
+ parsers are not reentrant, we retain defargs state in these two
+ variables so that subsequent calls to do_pending_defargs can resume
+ where the previous call left off. */
+
+static tree defarg_fns;
+static tree defarg_parm;
+
/* Return something to represent absolute declarators containing a *.
TARGET is the absolute declarator that the * contains.
@@ -875,6 +887,14 @@ init_parse (filename)
token_count = init_cpp_parse ();
interface_unknown = 1;
+ ggc_add_tree_root (ansi_opname, LAST_CPLUS_TREE_CODE);
+ ggc_add_tree_root (ansi_assopname, LAST_CPLUS_TREE_CODE);
+ ggc_add_tree_root (ridpointers, RID_MAX);
+ ggc_add_tree_root (&defarg_fns, 1);
+ ggc_add_tree_root (&defarg_parm, 1);
+ ggc_add_tree_root (&this_filename_time, 1);
+ ggc_add_tree_root (&filename_times, 1);
+
return filename;
}
@@ -1821,16 +1841,6 @@ maybe_snarf_defarg ()
do_snarf_defarg = 1;
}
-/* When we see a default argument in a method declaration, we snarf it as
- text using snarf_defarg. When we get up to namespace scope, we then go
- through and parse all of them using do_pending_defargs. Since yacc
- parsers are not reentrant, we retain defargs state in these two
- variables so that subsequent calls to do_pending_defargs can resume
- where the previous call left off. */
-
-tree defarg_fns;
-tree defarg_parm;
-
tree
snarf_defarg ()
{
@@ -2717,8 +2727,6 @@ handle_cp_pragma (pname)
if (! strcmp (pname, "vtable"))
{
- extern tree pending_vtables;
-
/* More follows: it must be a string constant (class name). */
token = real_yylex ();
if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index e3b2677..cf681e1 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -41,6 +41,7 @@ Boston, MA 02111-1307, USA. */
#include "hard-reg-set.h"
#include "flags.h"
#include "toplev.h"
+#include "ggc.h"
/* TREE_LIST of the current inline functions that need to be
processed. */
@@ -98,11 +99,31 @@ static void build_mangled_name_for_type_with_Gcode PROTO((tree, int));
# define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0'))
# define OB_LAST() (obstack_next_free (&scratch_obstack)[-1])
+/* type tables for K and B type compression */
+static varray_type btypelist;
+static varray_type ktypelist;
+
+/* number of each type seen */
+static size_t maxbtype;
+static size_t maxktype;
+
+/* Array of types seen so far in top-level call to `build_mangled_name'.
+ Allocated and deallocated by caller. */
+static varray_type typevec;
+
+/* Number of types interned by `build_mangled_name' so far. */
+static size_t maxtype;
+
+/* Called once to initialize method.c. */
+
void
init_method ()
{
gcc_obstack_init (&scratch_obstack);
scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0);
+ ggc_add_tree_varray_root (&btypelist, 1);
+ ggc_add_tree_varray_root (&ktypelist, 1);
+ ggc_add_tree_varray_root (&typevec, 1);
}
/* This must be large enough to hold any printed integer or floating-point
@@ -172,24 +193,6 @@ do_inline_function_hair (type, friend_list)
/* Here is where overload code starts. */
-/* type tables for K and B type compression */
-static tree *btypelist = NULL;
-static tree *ktypelist = NULL;
-static int maxbsize = 0;
-static int maxksize = 0;
-
-/* number of each type seen */
-static int maxbtype = 0;
-static int maxktype = 0;
-
-/* Array of types seen so far in top-level call to `build_mangled_name'.
- Allocated and deallocated by caller. */
-static tree *typevec = NULL;
-static int typevec_size;
-
-/* Number of types interned by `build_mangled_name' so far. */
-static int maxtype = 0;
-
/* Nonzero if we should not try folding parameter types. */
static int nofold;
@@ -205,10 +208,8 @@ start_squangling ()
nofold = 0;
maxbtype = 0;
maxktype = 0;
- maxbsize = 50;
- maxksize = 50;
- btypelist = (tree *)xmalloc (sizeof (tree) * maxbsize);
- ktypelist = (tree *)xmalloc (sizeof (tree) * maxksize);
+ VARRAY_TREE_INIT (btypelist, 50, "btypelist");
+ VARRAY_TREE_INIT (ktypelist, 50, "ktypelist");
}
}
@@ -217,16 +218,10 @@ end_squangling ()
{
if (flag_do_squangling)
{
- if (ktypelist)
- free (ktypelist);
- if (btypelist)
- free (btypelist);
- maxbsize = 0;
- maxksize = 0;
+ VARRAY_FREE (ktypelist);
+ VARRAY_FREE (btypelist);
maxbtype = 0;
maxktype = 0;
- ktypelist = NULL;
- btypelist = NULL;
}
}
@@ -303,7 +298,7 @@ static __inline int
old_backref_index (type)
tree type;
{
- int tindex = 0;
+ size_t tindex;
if (! is_back_referenceable_type (type))
return -1;
@@ -311,7 +306,7 @@ old_backref_index (type)
/* The entry for this parm is at maxtype-1, so don't look there for
something to repeat. */
for (tindex = 0; tindex < maxtype - 1; ++tindex)
- if (same_type_p (typevec[tindex], type))
+ if (same_type_p (VARRAY_TREE (typevec, tindex), type))
break;
if (tindex == maxtype - 1)
@@ -425,7 +420,7 @@ check_ktype (node, add)
tree node;
int add;
{
- int x;
+ size_t x;
tree localnode = node;
if (ktypelist == NULL)
@@ -434,20 +429,19 @@ check_ktype (node, add)
if (TREE_CODE (node) == TYPE_DECL)
localnode = TREE_TYPE (node);
- for (x=0; x < maxktype; x++)
+ for (x = 0; x < maxktype; x++)
{
- if (same_type_p (localnode, ktypelist[x]))
+ if (same_type_p (localnode, VARRAY_TREE (ktypelist, x)))
return x;
}
/* Didn't find it, so add it here. */
if (add)
{
- if (maxksize <= maxktype)
- {
- maxksize = maxksize* 3 / 2;
- ktypelist = (tree *)xrealloc (ktypelist, sizeof (tree) * maxksize);
- }
- ktypelist[maxktype++] = localnode;
+ if (VARRAY_SIZE (ktypelist) <= maxktype)
+ VARRAY_GROW (ktypelist,
+ VARRAY_SIZE (ktypelist) * 3 / 2);
+ VARRAY_TREE (ktypelist, maxktype) = localnode;
+ maxktype++;
}
return -1;
}
@@ -1166,8 +1160,9 @@ build_mangled_name (parmtypes, begin, end)
if (old_style_repeats)
{
/* Every argument gets counted. */
- my_friendly_assert (maxtype < typevec_size, 387);
- typevec[maxtype++] = parmtype;
+ my_friendly_assert (maxtype < VARRAY_SIZE (typevec), 387);
+ VARRAY_TREE (typevec, maxtype) = parmtype;
+ maxtype++;
}
if (last_type && same_type_p (parmtype, last_type))
@@ -1261,7 +1256,7 @@ static int
check_btype (type)
tree type;
{
- int x;
+ size_t x;
if (btypelist == NULL)
return 0;
@@ -1270,7 +1265,7 @@ check_btype (type)
return 0;
for (x = 0; x < maxbtype; x++)
- if (same_type_p (type, btypelist[x]))
+ if (same_type_p (type, VARRAY_TREE (btypelist, x)))
{
OB_PUTC ('B');
icat (x);
@@ -1279,15 +1274,14 @@ check_btype (type)
return 1 ;
}
- if (maxbsize <= maxbtype)
- {
- /* Enlarge the table. */
- maxbsize = maxbsize * 3 / 2;
- btypelist = (tree *)xrealloc (btypelist, sizeof (tree) * maxbsize);
- }
-
+ if (VARRAY_SIZE (btypelist) <= maxbtype)
+ /* Enlarge the table. */
+ VARRAY_GROW (btypelist,
+ VARRAY_SIZE (btypelist) * 3 / 2);
+
/* Register the TYPE. */
- btypelist[maxbtype++] = type;
+ VARRAY_TREE (btypelist, maxbtype) = type;
+ maxbtype++;
return 0;
}
@@ -1638,12 +1632,12 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
if (!flag_do_squangling)
{
/* Allocate typevec array. */
+ size_t typevec_size = list_length (parms);
maxtype = 0;
- typevec_size = list_length (parms);
if (!for_method && current_namespace != global_namespace)
/* The namespace of a global function needs one slot. */
typevec_size++;
- typevec = (tree *)alloca (typevec_size * sizeof (tree));
+ VARRAY_TREE_INIT (typevec, typevec_size, "typevec");
}
nofold = 0;
@@ -1655,8 +1649,9 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
if (!flag_do_squangling)
{
- my_friendly_assert (maxtype < typevec_size, 387);
- typevec[maxtype++] = this_type;
+ my_friendly_assert (maxtype < VARRAY_SIZE (typevec), 387);
+ VARRAY_TREE (typevec, maxtype) = this_type;
+ maxtype++;
}
if (TREE_CHAIN (parms))
@@ -1671,15 +1666,16 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
if (current_namespace != global_namespace
&& !flag_do_squangling)
{
- my_friendly_assert (maxtype < typevec_size, 387);
- typevec[maxtype++] = current_namespace;
+ my_friendly_assert (maxtype < VARRAY_SIZE (typevec), 387);
+ VARRAY_TREE (typevec, maxtype) = current_namespace;
+ maxtype++;
}
build_mangled_name (parms, 0, 0);
}
if (!flag_do_squangling)
/* Deallocate typevec array. */
- typevec = NULL;
+ VARRAY_FREE (typevec);
}
if (ret_type != NULL_TREE && for_method != 2)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b04ce70..01d4f1f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -40,8 +40,8 @@ Boston, MA 02111-1307, USA. */
#include "except.h"
#include "toplev.h"
#include "rtl.h"
-#include "varray.h"
#include "defaults.h"
+#include "ggc.h"
/* The type of functions taking a tree, and some additional data, and
returning an int. */
@@ -52,9 +52,6 @@ extern struct obstack permanent_obstack;
extern int lineno;
extern char *input_filename;
-tree current_template_parms;
-HOST_WIDE_INT processing_template_decl;
-
/* The PENDING_TEMPLATES is a TREE_LIST of templates whose
instantiations have been deferred, either because their definitions
were not yet available, or because we were putting off doing the
@@ -68,8 +65,6 @@ static tree *template_tail = &pending_templates;
static tree maybe_templates;
static tree *maybe_template_tail = &maybe_templates;
-int processing_specialization;
-int processing_explicit_instantiation;
int processing_template_parmlist;
static int template_header_count;
@@ -224,6 +219,16 @@ static void tsubst_default_arguments PROTO((tree));
#define TMPL_PARMS_DEPTH(NODE) \
(TREE_INT_CST_HIGH (TREE_PURPOSE (NODE)))
+/* Called once to initialize pt.c. */
+
+void
+init_pt ()
+{
+ ggc_add_tree_root (&pending_templates, 1);
+ ggc_add_tree_root (&maybe_templates, 1);
+ ggc_add_tree_root (&saved_trees, 1);
+}
+
/* Do any processing required when DECL (a member template declaration
using TEMPLATE_PARAMETERS as its innermost parameter list) is
finished. Returns the TEMPLATE_DECL corresponding to DECL, unless
diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c
index e63c0e1..4adcc35 100644
--- a/gcc/cp/repo.c
+++ b/gcc/cp/repo.c
@@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */
#include "input.h"
#include "obstack.h"
#include "toplev.h"
+#include "ggc.h"
static tree repo_get_id PROTO((tree));
static char *extract_string PROTO((char **));
@@ -308,6 +309,9 @@ init_repo (filename)
if (! flag_use_repository)
return;
+ ggc_add_tree_root (&pending_repo, 1);
+ ggc_add_tree_root (&original_repo, 1);
+
open_repo_file (filename);
if (repo_file == 0)
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 62fa402..dc81a33 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -31,7 +31,6 @@ Boston, MA 02111-1307, USA. */
#include "rtl.h"
#include "output.h"
#include "toplev.h"
-#include "varray.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
@@ -176,8 +175,6 @@ pop_search_level (obstack)
return stack;
}
-static tree _vptr_name;
-
/* Variables for gathering statistics. */
#ifdef GATHER_STATISTICS
static int n_fields_searched;
@@ -584,7 +581,7 @@ lookup_field_1 (type, name)
field = TREE_CHAIN (field);
}
/* Not found. */
- if (name == _vptr_name)
+ if (name == vptr_identifier)
{
/* Give the user what s/he thinks s/he wants. */
if (TYPE_VIRTUAL_P (type))
@@ -2792,7 +2789,6 @@ expand_indirect_vtbls_init (binfo, true_exp, decl_ptr)
if (fixup_insns)
{
- extern tree in_charge_identifier;
tree in_charge_node = lookup_name (in_charge_identifier, 0);
if (! in_charge_node)
{
@@ -3140,7 +3136,7 @@ void
init_search_processing ()
{
gcc_obstack_init (&search_obstack);
- _vptr_name = get_identifier ("_vptr");
+ vptr_identifier = get_identifier ("_vptr");
}
void