Commit c33406f5 by Jan Hubicka Committed by Jan Hubicka

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
parent 95c952c5
2011-05-02 Jan Hubicka <jh@suse.cz>
* 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 <joseph@codesourcery.com> 2011-05-02 Joseph Myers <joseph@codesourcery.com>
* config/m68k/genopt.sh, config/m68k/m68k-isas.def, * config/m68k/genopt.sh, config/m68k/m68k-isas.def,
......
...@@ -348,26 +348,20 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache, ...@@ -348,26 +348,20 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache,
bool insert_at_next_slot_p) bool insert_at_next_slot_p)
{ {
void **slot; void **slot;
struct tree_int_map d_entry, *entry;
unsigned ix; unsigned ix;
bool existed_p; bool existed_p;
gcc_assert (t); gcc_assert (t);
d_entry.base.from = t; slot = pointer_map_insert (cache->node_map, t);
slot = htab_find_slot (cache->node_map, &d_entry, INSERT); if (!*slot)
if (*slot == NULL)
{ {
/* Determine the next slot to use in the cache. */ /* Determine the next slot to use in the cache. */
if (insert_at_next_slot_p) if (insert_at_next_slot_p)
ix = VEC_length (tree, cache->nodes); ix = VEC_length (tree, cache->nodes);
else else
ix = *ix_p; ix = *ix_p;
*slot = (void *)(size_t) (ix + 1);
entry = (struct tree_int_map *)pool_alloc (cache->node_map_entries);
entry->base.from = t;
entry->to = ix;
*slot = entry;
lto_streamer_cache_add_to_node_array (cache, ix, t); 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, ...@@ -376,8 +370,7 @@ lto_streamer_cache_insert_1 (struct lto_streamer_cache_d *cache,
} }
else else
{ {
entry = (struct tree_int_map *) *slot; ix = (size_t) *slot - 1;
ix = entry->to;
if (!insert_at_next_slot_p && ix != *ix_p) 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, ...@@ -442,14 +435,12 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t,
unsigned *ix_p) unsigned *ix_p)
{ {
void **slot; void **slot;
struct tree_int_map d_slot;
bool retval; bool retval;
unsigned ix; unsigned ix;
gcc_assert (t); gcc_assert (t);
d_slot.base.from = t; slot = pointer_map_contains (cache->node_map, t);
slot = htab_find_slot (cache->node_map, &d_slot, NO_INSERT);
if (slot == NULL) if (slot == NULL)
{ {
retval = false; retval = false;
...@@ -458,7 +449,7 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t, ...@@ -458,7 +449,7 @@ lto_streamer_cache_lookup (struct lto_streamer_cache_d *cache, tree t,
else else
{ {
retval = true; retval = true;
ix = ((struct tree_int_map *) *slot)->to; ix = (size_t) *slot - 1;
} }
if (ix_p) if (ix_p)
...@@ -608,11 +599,7 @@ lto_streamer_cache_create (void) ...@@ -608,11 +599,7 @@ lto_streamer_cache_create (void)
cache = XCNEW (struct lto_streamer_cache_d); 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 = pointer_map_create ();
cache->node_map_entries = create_alloc_pool ("node map",
sizeof (struct tree_int_map),
100);
/* Load all the well-known tree nodes that are always created by /* Load all the well-known tree nodes that are always created by
the compiler on startup. This prevents writing them out the compiler on startup. This prevents writing them out
...@@ -636,8 +623,7 @@ lto_streamer_cache_delete (struct lto_streamer_cache_d *c) ...@@ -636,8 +623,7 @@ lto_streamer_cache_delete (struct lto_streamer_cache_d *c)
if (c == NULL) if (c == NULL)
return; return;
htab_delete (c->node_map); pointer_map_destroy (c->node_map);
free_alloc_pool (c->node_map_entries);
VEC_free (tree, heap, c->nodes); VEC_free (tree, heap, c->nodes);
free (c); free (c);
} }
......
...@@ -346,10 +346,7 @@ typedef void (lto_free_section_data_f) (struct lto_file_decl_data *, ...@@ -346,10 +346,7 @@ typedef void (lto_free_section_data_f) (struct lto_file_decl_data *,
struct lto_streamer_cache_d struct lto_streamer_cache_d
{ {
/* The mapping between tree nodes and slots into the nodes array. */ /* The mapping between tree nodes and slots into the nodes array. */
htab_t node_map; struct pointer_map_t *node_map;
/* Node map to store entries into. */
alloc_pool node_map_entries;
/* The nodes pickled so far. */ /* The nodes pickled so far. */
VEC(tree,heap) *nodes; VEC(tree,heap) *nodes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment