From b086d5308de0d25444243f482f2f3d1dfd3a9a62 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Tue, 2 Sep 2014 22:46:00 +0000 Subject: support ggc hash_map and hash_set gcc/ChangeLog: * alloc-pool.c: Include coretypes.h. * cgraph.h, dbxout.c, dwarf2out.c, except.c, except.h, function.c, function.h, symtab.c, tree-cfg.c, tree-eh.c: Use hash_map and hash_set instead of htab. * ggc-page.c (in_gc): New variable. (ggc_free): Do nothing if a collection is taking place. (ggc_collect): Set in_gc appropriately. * ggc.h (gt_ggc_mx(const char *)): New function. (gt_pch_nx(const char *)): Likewise. (gt_ggc_mx(int)): Likewise. (gt_pch_nx(int)): Likewise. * hash-map.h (hash_map::hash_entry::ggc_mx): Likewise. (hash_map::hash_entry::pch_nx): Likewise. (hash_map::hash_entry::pch_nx_helper): Likewise. (hash_map::hash_map): Adjust. (hash_map::create_ggc): New function. (gt_ggc_mx): Likewise. (gt_pch_nx): Likewise. * hash-set.h (default_hashset_traits::ggc_mx): Likewise. (default_hashset_traits::pch_nx): Likewise. (hash_set::hash_entry::ggc_mx): Likewise. (hash_set::hash_entry::pch_nx): Likewise. (hash_set::hash_entry::pch_nx_helper): Likewise. (hash_set::hash_set): Adjust. (hash_set::create_ggc): New function. (hash_set::elements): Likewise. (gt_ggc_mx): Likewise. (gt_pch_nx): Likewise. * hash-table.h (hash_table::hash_table): Adjust. (hash_table::m_ggc): New member. (hash_table::~hash_table): Adjust. (hash_table::expand): Likewise. (hash_table::empty): Likewise. (gt_ggc_mx): New function. (hashtab_entry_note_pointers): Likewise. (gt_pch_nx): Likewise. From-SVN: r214834 --- gcc/symtab.c | 62 +++++++++--------------------------------------------------- 1 file changed, 9 insertions(+), 53 deletions(-) (limited to 'gcc/symtab.c') diff --git a/gcc/symtab.c b/gcc/symtab.c index 739a8e4..792b3b5 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -407,15 +407,7 @@ symtab_node::unregister (void) if (!is_a (this) || !DECL_HARD_REGISTER (decl)) symtab->unlink_from_assembler_name_hash (this, false); if (in_init_priority_hash) - { - symbol_priority_map in; - void **slot; - in.symbol = this; - - slot = htab_find_slot (symtab->init_priority_hash, &in, NO_INSERT); - if (slot) - htab_clear_slot (symtab->init_priority_hash, slot); - } + symtab->init_priority_hash->remove (this); } @@ -1455,14 +1447,10 @@ symtab_node::set_section (const char *section) priority_type symtab_node::get_init_priority () { - symbol_priority_map *h; - symbol_priority_map in; - if (!this->in_init_priority_hash) return DEFAULT_INIT_PRIORITY; - in.symbol = this; - h = (symbol_priority_map *) htab_find (symtab->init_priority_hash, - &in); + + symbol_priority_map *h = symtab->init_priority_hash->get (this); return h ? h->init : DEFAULT_INIT_PRIORITY; } @@ -1481,35 +1469,12 @@ enum availability symtab_node::get_availability (void) priority_type cgraph_node::get_fini_priority () { - symbol_priority_map *h; - symbol_priority_map in; - if (!this->in_init_priority_hash) return DEFAULT_INIT_PRIORITY; - in.symbol = this; - h = (symbol_priority_map *) htab_find (symtab->init_priority_hash, - &in); + symbol_priority_map *h = symtab->init_priority_hash->get (this); return h ? h->fini : DEFAULT_INIT_PRIORITY; } -/* Return true if the from tree in both priority maps are equal. */ - -int -symbol_priority_map_eq (const void *va, const void *vb) -{ - const symbol_priority_map *const a = (const symbol_priority_map *) va, - *const b = (const symbol_priority_map *) vb; - return (a->symbol == b->symbol); -} - -/* Hash a from symbol in a symbol_priority_map. */ - -unsigned int -symbol_priority_map_hash (const void *item) -{ - return htab_hash_pointer (((const symbol_priority_map *)item)->symbol); -} - /* Return the initialization and finalization priority information for DECL. If there is no previous priority information, a freshly allocated structure is returned. */ @@ -1517,23 +1482,14 @@ symbol_priority_map_hash (const void *item) symbol_priority_map * symtab_node::priority_info (void) { - symbol_priority_map in; - symbol_priority_map *h; - void **loc; - - in.symbol = this; if (!symtab->init_priority_hash) - symtab->init_priority_hash = htab_create_ggc (512, - symbol_priority_map_hash, - symbol_priority_map_eq, 0); + symtab->init_priority_hash = hash_map::create_ggc (13); - loc = htab_find_slot (symtab->init_priority_hash, &in, INSERT); - h = (symbol_priority_map *) *loc; - if (!h) + bool existed; + symbol_priority_map *h + = &symtab->init_priority_hash->get_or_insert (this, &existed); + if (!existed) { - h = ggc_cleared_alloc (); - *loc = h; - h->symbol = this; h->init = DEFAULT_INIT_PRIORITY; h->fini = DEFAULT_INIT_PRIORITY; in_init_priority_hash = true; -- cgit v1.1