aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurynas Biveinis <laurynas.biveinis@gmail.com>2007-07-30 04:46:00 +0000
committerLaurynas Biveinis <laurynas.biveinis@gmail.com>2007-07-30 04:46:00 +0000
commitdeb78470e4042e1e49125cbf1c0a09e47885b4af (patch)
tree8fefa2797e67b660be8bfad9a2b3479316526717
parent48cf2a225eb300de598f536408b21422c69509fd (diff)
Make splay trees use type-tagged allocators
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/boehms-gc@127057 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/alias.c16
-rw-r--r--gcc/dwarf2asm.c16
-rw-r--r--gcc/gengtype.c11
-rw-r--r--gcc/ggc-common.c14
-rw-r--r--gcc/ggc.h11
-rw-r--r--gcc/ipa-reference.c16
-rw-r--r--gcc/omp-low.c20
-rw-r--r--include/splay-tree.h11
-rw-r--r--libiberty/splay-tree.c21
10 files changed, 111 insertions, 27 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 4884627de64..48d93f3fcc6 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1786,7 +1786,7 @@ gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GGC_H) \
$(HASHTAB_H) toplev.h $(PARAMS_H) hosthooks.h $(HOSTHOOKS_DEF_H) \
- valgrind-support.h
+ valgrind-support.h $(SPLAY_TREE_H)
ggc-boehm.o: ggc-boehm.c $(CONFIG_H) $(SYSTEM H) $(TIMEVAR_H) $(GGC_H)
diff --git a/gcc/alias.c b/gcc/alias.c
index 2457f1cb3c7..c288fcf0a05 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -148,6 +148,18 @@ struct alias_set_entry GTY(())
};
typedef struct alias_set_entry *alias_set_entry;
+static void *
+ggc_alloc_ase_splay_tree (int sz, void *nl)
+{
+ return ggc_splay_alloc_tree (gt_e_II12splay_tree_s, sz, nl);
+}
+
+static void *
+ggc_alloc_ase_splay_node (int sz, void *nl)
+{
+ return ggc_splay_alloc_node (gt_e_II17splay_tree_node_s, sz, nl);
+}
+
static int rtx_equal_for_memref_p (rtx, rtx);
static rtx find_symbolic_term (rtx);
static int memrefs_conflict_p (int, rtx, int, rtx, HOST_WIDE_INT);
@@ -673,7 +685,9 @@ record_alias_subset (HOST_WIDE_INT superset, HOST_WIDE_INT subset)
superset_entry = ggc_alloc_alias_set_entry();
superset_entry->alias_set = superset;
superset_entry->children
- = splay_tree_new_ggc (splay_tree_compare_ints);
+ = splay_tree_new_ggc (splay_tree_compare_ints,
+ ggc_alloc_ase_splay_tree,
+ ggc_alloc_ase_splay_node);
superset_entry->has_zero_child = 0;
VEC_replace (alias_set_entry, alias_sets, superset, superset_entry);
}
diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
index 7a067101a77..c6667077a05 100644
--- a/gcc/dwarf2asm.c
+++ b/gcc/dwarf2asm.c
@@ -694,6 +694,18 @@ static int dw2_output_indirect_constant_1 (splay_tree_node, void *);
static GTY((param1_is (char *), param2_is (tree))) splay_tree indirect_pool;
+static void *
+ggc_alloc_ip_splay_tree (int sz, void *nl)
+{
+ return ggc_splay_alloc_tree (gt_e_SP9tree_node12splay_tree_s, sz, nl);
+}
+
+static void *
+ggc_alloc_ip_splay_node (int sz, void *nl)
+{
+ return ggc_splay_alloc_node (gt_e_SP9tree_node17splay_tree_node_s, sz, nl);
+}
+
static GTY(()) int dw2_const_labelno;
#if defined(HAVE_GAS_HIDDEN) && defined(SUPPORTS_ONE_ONLY)
@@ -716,7 +728,9 @@ dw2_force_const_mem (rtx x, bool public)
tree decl;
if (! indirect_pool)
- indirect_pool = splay_tree_new_ggc (splay_tree_compare_pointers);
+ indirect_pool = splay_tree_new_ggc (splay_tree_compare_pointers,
+ ggc_alloc_ip_splay_tree,
+ ggc_alloc_ip_splay_node);
gcc_assert (GET_CODE (x) == SYMBOL_REF);
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 40b224daa71..90831568f50 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -2638,16 +2638,7 @@ write_typed_alloc_defns (type_p structures)
write_typed_struct_alloc_def (s, "cleared_vec_", "gt_ggc_e_",
VECTOR_DEF);
}
- /* TODO! Not clear at this stage if this is needed or not.
- for (s = param_structs; s; s = s->next)
- if (s->gc_used == GC_POINTED_TO)
- {
- write_typed_struct_alloc_def (s, "", "gt_e_", NON_VECTOR_DEF);
- write_typed_struct_alloc_def (s, "cleared_", "gt_e_", NON_VECTOR_DEF);
- write_typed_struct_alloc_def (s, "vec_", "gt_e_", VECTOR_DEF);
- write_typed_struct_alloc_def (s, "cleared_vec_", "gt_e_", VECTOR_DEF);
- }
- */
+
oprintf (header_file, "\n/* Typed allocation for known typedefs. */\n");
for (p = typedefs; p != NULL; p = p->next)
{
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index b2e4fafc261..e7feee8825d 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -28,6 +28,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "hashtab.h"
#include "ggc.h"
#include "ggc-internal.h"
+#include "splay-tree.h"
#include "toplev.h"
#include "params.h"
#include "hosthooks.h"
@@ -138,10 +139,19 @@ ggc_calloc (size_t s1, size_t s2)
/* These are for splay_tree_new_ggc. */
void *
-ggc_splay_alloc (int sz, void *nl)
+ggc_splay_alloc_tree (enum gt_types_enum obj_type, int sz, void *nl)
{
gcc_assert (!nl);
- return ggc_alloc (sz);
+ gcc_assert (sz == sizeof (struct splay_tree_s));
+ return ggc_alloc_typed (obj_type, sz);
+}
+
+void *
+ggc_splay_alloc_node (enum gt_types_enum obj_type, int sz, void *nl)
+{
+ gcc_assert (!nl);
+ gcc_assert (sz == sizeof (struct splay_tree_node_s));
+ return ggc_alloc_typed (obj_type, sz);
}
void
diff --git a/gcc/ggc.h b/gcc/ggc.h
index 9ca4c9a3ec1..1d6c9eea473 100644
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -103,11 +103,12 @@ extern void *ggc_alloc_atomic_stat (size_t MEM_STAT_DECL);
#define htab_create_ggc(SIZE, HASH, EQ, DEL) \
htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc, NULL)
-#define splay_tree_new_ggc(COMPARE) \
- splay_tree_new_with_allocator (COMPARE, NULL, NULL, \
- &ggc_splay_alloc, &ggc_splay_dont_free, \
- NULL)
-extern void *ggc_splay_alloc (int, void *);
+#define splay_tree_new_ggc(COMPARE, ALLOC_TREE, ALLOC_NODE) \
+ splay_tree_new_with_separate_allocators (COMPARE, NULL, NULL, \
+ &ALLOC_TREE, &ALLOC_NODE, \
+ &ggc_splay_dont_free, NULL)
+extern void *ggc_splay_alloc_tree (enum gt_types_enum, int, void *);
+extern void *ggc_splay_alloc_node (enum gt_types_enum, int, void *);
extern void ggc_splay_dont_free (void *, void *);
/* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS.
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index 8ad7a44d13c..e493e7958ca 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -81,6 +81,19 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
static GTY((param1_is(int), param2_is(tree)))
splay_tree reference_vars_to_consider;
+static void *
+ggc_alloc_ase_splay_tree (int sz, void *nl)
+{
+ return ggc_splay_alloc_tree (gt_e_IP9tree_node12splay_tree_s, sz, nl);
+}
+
+static void *
+ggc_alloc_ase_splay_node (int sz, void *nl)
+{
+ return ggc_splay_alloc_node (gt_e_IP9tree_node17splay_tree_node_s, sz, nl);
+}
+
+
/* This bitmap is used to knock out the module static variables whose
addresses have been taken and passed around. */
static bitmap module_statics_escape;
@@ -745,7 +758,8 @@ ipa_init (void)
memory_identifier_string = build_string(7, "memory");
reference_vars_to_consider =
- splay_tree_new_ggc (splay_tree_compare_ints);
+ splay_tree_new_ggc (splay_tree_compare_ints, ggc_alloc_ase_splay_tree,
+ ggc_alloc_ase_splay_node);
bitmap_obstack_initialize (&ipa_obstack);
module_statics_escape = BITMAP_ALLOC (&ipa_obstack);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 01bd5712903..4097f7631d5 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3839,6 +3839,20 @@ lower_omp_ordered (tree *stmt_p, omp_context *ctx)
static GTY((param1_is (tree), param2_is (tree)))
splay_tree critical_name_mutexes;
+static void *
+ggc_alloc_cnm_splay_tree (int sz, void *nl)
+{
+ return ggc_splay_alloc_tree (gt_e_P9tree_nodeP9tree_node12splay_tree_s, sz,
+ nl);
+}
+
+static void *
+ggc_alloc_cnm_splay_tree_node (int sz, void *nl)
+{
+ return ggc_splay_alloc_node (gt_e_P9tree_nodeP9tree_node17splay_tree_node_s,
+ sz, nl);
+}
+
static void
lower_omp_critical (tree *stmt_p, omp_context *ctx)
{
@@ -3852,8 +3866,10 @@ lower_omp_critical (tree *stmt_p, omp_context *ctx)
splay_tree_node n;
if (!critical_name_mutexes)
- critical_name_mutexes
- = splay_tree_new_ggc (splay_tree_compare_pointers);
+ critical_name_mutexes
+ = splay_tree_new_ggc (splay_tree_compare_pointers,
+ ggc_alloc_cnm_splay_tree,
+ ggc_alloc_cnm_splay_tree_node);
n = splay_tree_lookup (critical_name_mutexes, (splay_tree_key) name);
if (n == NULL)
diff --git a/include/splay-tree.h b/include/splay-tree.h
index 78d8f71c09f..1b01e7a1d25 100644
--- a/include/splay-tree.h
+++ b/include/splay-tree.h
@@ -14,7 +14,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-You should have received a copy of the GNU General Public License
+You should have received a copy of the GNU General Public Liecnse
along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */
@@ -107,7 +107,7 @@ struct splay_tree_s GTY(())
splay_tree_delete_value_fn delete_value;
/* Allocate/free functions, and a data pointer to pass to them. */
- splay_tree_allocate_fn allocate;
+ splay_tree_allocate_fn allocate_node;
splay_tree_deallocate_fn deallocate;
void * GTY((skip)) allocate_data;
@@ -123,6 +123,13 @@ extern splay_tree splay_tree_new_with_allocator (splay_tree_compare_fn,
splay_tree_allocate_fn,
splay_tree_deallocate_fn,
void *);
+extern splay_tree splay_tree_new_with_separate_allocators (splay_tree_compare_fn,
+ splay_tree_delete_key_fn,
+ splay_tree_delete_value_fn,
+ splay_tree_allocate_fn,
+ splay_tree_allocate_fn,
+ splay_tree_deallocate_fn,
+ void *);
extern void splay_tree_delete (splay_tree);
extern splay_tree_node splay_tree_insert (splay_tree,
splay_tree_key,
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index 060f900ae0a..532cdad625b 100644
--- a/libiberty/splay-tree.c
+++ b/libiberty/splay-tree.c
@@ -271,13 +271,30 @@ splay_tree_new_with_allocator (splay_tree_compare_fn compare_fn,
sp->comp = compare_fn;
sp->delete_key = delete_key_fn;
sp->delete_value = delete_value_fn;
- sp->allocate = allocate_fn;
+ sp->allocate_node = allocate_fn;
sp->deallocate = deallocate_fn;
sp->allocate_data = allocate_data;
return sp;
}
+splay_tree
+splay_tree_new_with_separate_allocators (splay_tree_compare_fn compare_fn,
+ splay_tree_delete_key_fn delete_key_fn,
+ splay_tree_delete_value_fn delete_value_fn,
+ splay_tree_allocate_fn tree_allocate_fn,
+ splay_tree_allocate_fn node_allocate_fn,
+ splay_tree_deallocate_fn deallocate_fn,
+ void *allocate_data)
+{
+ splay_tree sp = splay_tree_new_with_allocator(compare_fn, delete_key_fn,
+ delete_value_fn, tree_allocate_fn,
+ deallocate_fn, allocate_data);
+ sp->allocate_node = node_allocate_fn;
+ return sp;
+}
+
+
/* Deallocate SP. */
void
@@ -315,7 +332,7 @@ splay_tree_insert (splay_tree sp, splay_tree_key key, splay_tree_value value)
splay_tree_node node;
node = ((splay_tree_node)
- (*sp->allocate) (sizeof (struct splay_tree_node_s),
+ (*sp->allocate_node) (sizeof (struct splay_tree_node_s),
sp->allocate_data));
node->key = key;
node->value = value;