aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@cygnus.com>1999-09-05 09:08:20 -0700
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-09-05 16:08:20 +0000
commita3770a813002ceaedfe097ea46c8ddc09b9c289c (patch)
tree53f583f3f8569b93ca268331c1f771e401b63045 /gcc/tree.c
parent616aeddaa175d5e70417df682d41ce8370bdeab2 (diff)
downloadgcc-a3770a813002ceaedfe097ea46c8ddc09b9c289c.zip
gcc-a3770a813002ceaedfe097ea46c8ddc09b9c289c.tar.gz
gcc-a3770a813002ceaedfe097ea46c8ddc09b9c289c.tar.bz2
Makefile.in (ggc-simple.o): Depend on varray.h.
* Makefile.in (ggc-simple.o): Depend on varray.h. (rtl.o): Depend on ggc.h. (genattrtab.o): Depend on ggc.h. (print-tree.o): Likewise. (fold-const.o): Likewise. * emit-rtl.c (sequence_element_free_list): Remove, and all references. (make_insn_raw): Don't cache insns when GC'ing. (emit_insn_before): Likewise. (emit_insn_after): Likewise. (emit_insn): Likewise. (start_sequence): Use xmalloc to allocate the sequence_stack. (end_sequence): Add free to free it. (gen_sequence): Don't cache insns when GC'ing. (clear_emit_caches): Don't use sequence_element_free_list. (init_emit): Use xcalloc, not xmalloc+bzero. * fold-const.c (size_int_wide): Kill the cache, when GC'ing. * function.c (pop_function_context_from): Use free to free the fixup_var_refs_queue. (put_reg_into_stack): Allocate it with xmalloc. * genattrtab.c: Include ggc.h. (operate_exp): Don't use obstack_free when GC'ing. (simplify_cond): Likewise. (simplify_text_exp): Likewise. (optimize_attrs): Likewise. * gengentrtl.c (gendef): Use ggc_alloc_rtx to allocate RTL, when GC'ing. (gencode): Generate a #include for ggc.h. * ggc-callbacks.c (ggc_p): Define it to zero. * ggc-none.c (ggc_p): Likewise. * ggc-simple.c: Include varray.h. (ggc_mark_tree_varray): New function. (ggc_add_tree_varray_root): Likewise. (ggc_mark_tree_varray_ptr): Likewise. * ggc.h (ggc_p): Declare. (varray_head_tag): Likewise. (ggc_add_tree_varray_root): Declare. * print-tree.c (print_node): Don't check for TREE_PERMANENT inconsistencies when GC'ing. * rtl.c: Include ggc.h. (rtvec_alloc): Use ggc_alloc_rtvec when GC'ing. (rtx_alloc): Use ggc_alloc_rtx when GC'ing. (rtx_free): Don't call obstack_free when GC'ing. * toplev.c (rest_of_compilation): Call ggc_collect after every pass, if GC'ing. * tree.c (push_obstacks): Do nothing, if GC'ing. (pop_obstacks_nochange): Likewise. (pop_obstacks): Likewise. (make_node): Use ggc_alloc_tree when GC'ing. (copy_node): Likewise. (get_identifier): Use ggc_alloc_string when GC'ing. (build_string): Likewise. (make_tree_vec): Use ggc_alloc_tree when GC'ing. (tree_cons): Likewise. (build1): Likewise. (type_hash_canon): Don't call obstack_free when GC'ing. Co-Authored-By: Bernd Schmidt <bernds@cygnus.co.uk> Co-Authored-By: Mark Mitchell <mark@codesourcery.com> From-SVN: r29125
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c82
1 files changed, 63 insertions, 19 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 1d0f273..03fc790 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -474,8 +474,12 @@ void
push_obstacks (current, saveable)
struct obstack *current, *saveable;
{
- struct obstack_stack *p
- = (struct obstack_stack *) obstack_alloc (&obstack_stack_obstack,
+ struct obstack_stack *p;
+
+ if (ggc_p)
+ return;
+
+ p = (struct obstack_stack *) obstack_alloc (&obstack_stack_obstack,
(sizeof (struct obstack_stack)));
p->current = current_obstack;
@@ -495,8 +499,12 @@ push_obstacks (current, saveable)
void
push_obstacks_nochange ()
{
- struct obstack_stack *p
- = (struct obstack_stack *) obstack_alloc (&obstack_stack_obstack,
+ struct obstack_stack *p;
+
+ if (ggc_p)
+ return;
+
+ p = (struct obstack_stack *) obstack_alloc (&obstack_stack_obstack,
(sizeof (struct obstack_stack)));
p->current = current_obstack;
@@ -512,7 +520,12 @@ push_obstacks_nochange ()
void
pop_obstacks ()
{
- struct obstack_stack *p = obstack_stack;
+ struct obstack_stack *p;
+
+ if (ggc_p)
+ return;
+
+ p = obstack_stack;
obstack_stack = p->next;
current_obstack = p->current;
@@ -1005,8 +1018,13 @@ make_node (code)
abort ();
}
- t = (tree) obstack_alloc (obstack, length);
- bzero ((PTR) t, length);
+ if (ggc_p)
+ t = ggc_alloc_tree (length);
+ else
+ {
+ t = (tree) obstack_alloc (obstack, length);
+ bzero ((PTR) t, length);
+ }
#ifdef GATHER_STATISTICS
tree_node_counts[(int)kind]++;
@@ -1119,8 +1137,13 @@ copy_node (node)
length += (TREE_VEC_LENGTH (node) - 1) * sizeof (char *);
}
- t = (tree) obstack_alloc (current_obstack, length);
- memcpy (t, node, length);
+ if (ggc_p)
+ t = ggc_alloc_tree (length);
+ else
+ {
+ t = (tree) obstack_alloc (current_obstack, length);
+ memcpy (t, node, length);
+ }
/* EXPR_WITH_FILE_LOCATION must keep filename info stored in TREE_CHAIN */
if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
@@ -1230,7 +1253,10 @@ get_identifier (text)
id_string_size += len;
#endif
- IDENTIFIER_POINTER (idp) = obstack_copy0 (&permanent_obstack, text, len);
+ if (ggc_p)
+ IDENTIFIER_POINTER (idp) = ggc_alloc_string (text, len);
+ else
+ IDENTIFIER_POINTER (idp) = obstack_copy0 (&permanent_obstack, text, len);
TREE_CHAIN (idp) = hash_table[hi];
hash_table[hi] = idp;
@@ -1469,7 +1495,10 @@ build_string (len, str)
register tree s = make_node (STRING_CST);
TREE_STRING_LENGTH (s) = len;
- TREE_STRING_POINTER (s) = obstack_copy0 (saveable_obstack, str, len);
+ if (ggc_p)
+ TREE_STRING_POINTER (s) = ggc_alloc_string (str, len);
+ else
+ TREE_STRING_POINTER (s) = obstack_copy0 (saveable_obstack, str, len);
return s;
}
@@ -1509,8 +1538,13 @@ make_tree_vec (len)
tree_node_sizes[(int)vec_kind] += length;
#endif
- t = (tree) obstack_alloc (obstack, length);
- bzero ((PTR) t, length);
+ if (ggc_p)
+ t = ggc_alloc_tree (length);
+ else
+ {
+ t = (tree) obstack_alloc (obstack, length);
+ bzero ((PTR) t, length);
+ }
TREE_SET_CODE (t, TREE_VEC);
TREE_VEC_LENGTH (t) = len;
@@ -2011,15 +2045,21 @@ tree_cons (purpose, value, chain)
#if 0
register tree node = make_node (TREE_LIST);
#else
- register int i;
- register tree node = (tree) obstack_alloc (current_obstack, sizeof (struct tree_list));
+ register tree node;
+
+ if (ggc_p)
+ node = ggc_alloc_tree (sizeof (struct tree_list));
+ else
+ {
+ node = (tree) obstack_alloc (current_obstack, sizeof (struct tree_list));
+ bzero (node, sizeof (struct tree_common));
+ }
+
#ifdef GATHER_STATISTICS
tree_node_counts[(int)x_kind]++;
tree_node_sizes[(int)x_kind] += sizeof (struct tree_list);
#endif
- for (i = (sizeof (struct tree_common) / sizeof (int)) - 1; i >= 0; i--)
- ((int *) node)[i] = 0;
TREE_SET_CODE (node, TREE_LIST);
if (current_obstack == &permanent_obstack)
@@ -3028,7 +3068,10 @@ build1 (code, type, node)
length = sizeof (struct tree_exp);
- t = (tree) obstack_alloc (obstack, length);
+ if (ggc_p)
+ t = ggc_alloc_tree (length);
+ else
+ t = (tree) obstack_alloc (obstack, length);
bzero ((PTR) t, length);
#ifdef GATHER_STATISTICS
@@ -3706,7 +3749,8 @@ type_hash_canon (hashcode, type)
t1 = type_hash_lookup (hashcode, type);
if (t1 != 0)
{
- obstack_free (TYPE_OBSTACK (type), type);
+ if (!ggc_p)
+ obstack_free (TYPE_OBSTACK (type), type);
#ifdef GATHER_STATISTICS
tree_node_counts[(int)t_kind]--;
tree_node_sizes[(int)t_kind] -= sizeof (struct tree_type);