diff options
author | Trevor Saunders <tsaunders@mozilla.com> | 2014-09-02 22:46:00 +0000 |
---|---|---|
committer | Trevor Saunders <tbsaunde@gcc.gnu.org> | 2014-09-02 22:46:00 +0000 |
commit | b086d5308de0d25444243f482f2f3d1dfd3a9a62 (patch) | |
tree | cb4aa8d407cf40f28ef0fcd771f1109d53f44f3c /gcc/symtab.c | |
parent | 70f0f8b2b1c9bf53b9158e4264bc1e93b963c31e (diff) |
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
Diffstat (limited to 'gcc/symtab.c')
-rw-r--r-- | gcc/symtab.c | 62 |
1 files changed, 9 insertions, 53 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c index 739a8e4a308..792b3b50ea6 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -407,15 +407,7 @@ symtab_node::unregister (void) if (!is_a <varpool_node *> (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<symtab_node *, symbol_priority_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<symbol_priority_map> (); - *loc = h; - h->symbol = this; h->init = DEFAULT_INIT_PRIORITY; h->fini = DEFAULT_INIT_PRIORITY; in_init_priority_hash = true; |