From c33406f5b10e9924b9f7a629cc7ded45585ec90b Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Mon, 2 May 2011 18:44:04 +0200 Subject: [PATCH] lto-streamer.c (lto_streamer_cache_insert_1, [...]): Use pointer map instead of hashtable. * lto-streamer.c (lto_streamer_cache_insert_1, lto_streamer_cache_lookup, lto_streamer_cache_create, lto_streamer_cache_delete): Use pointer map instead of hashtable. * lto-streamer.h (lto_streamer_cache_d): Turn node_map into pointer_map. From-SVN: r173259 --- gcc/ChangeLog | 7 +++++++ gcc/lto-streamer.c | 30 ++++++++---------------------- gcc/lto-streamer.h | 5 +---- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 28f909f7ea9..c7165f840d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-05-02 Jan Hubicka + + * lto-streamer.c (lto_streamer_cache_insert_1, + lto_streamer_cache_lookup, lto_streamer_cache_create, + lto_streamer_cache_delete): Use pointer map instead of hashtable. + * lto-streamer.h (lto_streamer_cache_d): Turn node_map into pointer_map. + 2011-05-02 Joseph Myers * config/m68k/genopt.sh, config/m68k/m68k-isas.def, diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index 80927927dcc..be54305d2c5 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -348,26 +348,20 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, bool insert_at_next_slot_p) { void **slot; - struct tree_int_map d_entry, *entry; unsigned ix; bool existed_p; gcc_assert (t); - d_entry.base.from = t; - slot = htab_find_slot (cache->node_map, &d_entry, INSERT); - if (*slot == NULL) + slot = pointer_map_insert (cache->node_map, t); + if (!*slot) { /* Determine the next slot to use in the cache. */ if (insert_at_next_slot_p) ix = VEC_length (tree, cache->nodes); else ix = *ix_p; - - entry = (struct tree_int_map *)pool_alloc (cache->node_map_entries); - entry->base.from = t; - entry->to = ix; - *slot = entry; + *slot = (void *)(size_t) (ix + 1); lto_streamer_cache_add_to_node_array (cache, ix, t); @@ -376,8 +370,7 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, } else { - entry = (struct tree_int_map *) *slot; - ix = entry->to; + ix = (size_t) *slot - 1; if (!insert_at_next_slot_p && ix != *ix_p) { @@ -442,14 +435,12 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t, unsigned *ix_p) { void **slot; - struct tree_int_map d_slot; bool retval; unsigned ix; gcc_assert (t); - d_slot.base.from = t; - slot = htab_find_slot (cache->node_map, &d_slot, NO_INSERT); + slot = pointer_map_contains (cache->node_map, t); if (slot == NULL) { retval = false; @@ -458,7 +449,7 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t, else { retval = true; - ix = ((struct tree_int_map *) *slot)->to; + ix = (size_t) *slot - 1; } if (ix_p) @@ -608,11 +599,7 @@ lto_streamer_cache_create (void) cache = XCNEW (struct lto_streamer_cache_d); - cache->node_map = htab_create (101, tree_int_map_hash, tree_int_map_eq, NULL); - - cache->node_map_entries = create_alloc_pool ("node map", - sizeof (struct tree_int_map), - 100); + cache->node_map = pointer_map_create (); /* Load all the well-known tree nodes that are always created by the compiler on startup. This prevents writing them out @@ -636,8 +623,7 @@ lto_streamer_cache_delete (struct lto_streamer_cache_d *c) if (c == NULL) return; - htab_delete (c->node_map); - free_alloc_pool (c->node_map_entries); + pointer_map_destroy (c->node_map); VEC_free (tree, heap, c->nodes); free (c); } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 4fe8f513a33..3d87e18a825 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -346,10 +346,7 @@ typedef void (lto_free_section_data_f) (struct lto_file_decl_data *, struct lto_streamer_cache_d { /* The mapping between tree nodes and slots into the nodes array. */ - htab_t node_map; - - /* Node map to store entries into. */ - alloc_pool node_map_entries; + struct pointer_map_t *node_map; /* The nodes pickled so far. */ VEC(tree,heap) *nodes; -- 2.30.2