diff options
author | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-02 22:46:00 +0000 |
---|---|---|
committer | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-09-02 22:46:00 +0000 |
commit | 8f359205089fa4570dd9db058aed35e391ceb357 (patch) | |
tree | cb4aa8d407cf40f28ef0fcd771f1109d53f44f3c /gcc/except.c | |
parent | c4de79b608465ea31bd920224bd7fdff2deeaecf (diff) | |
download | gcc-8f359205089fa4570dd9db058aed35e391ceb357.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@214834 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/except.c')
-rw-r--r-- | gcc/except.c | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/gcc/except.c b/gcc/except.c index 1f57c3f5cd8..fecc06046a2 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -149,8 +149,13 @@ along with GCC; see the file COPYING3. If not see #endif static GTY(()) int call_site_base; -static GTY ((param_is (union tree_node))) - htab_t type_to_runtime_map; + +struct tree_hash_traits : default_hashmap_traits +{ + static hashval_t hash (tree t) { return TREE_HASH (t); } +}; + +static GTY (()) hash_map<tree, tree, tree_hash_traits> *type_to_runtime_map; /* Describe the SjLj_Function_Context structure. */ static GTY(()) tree sjlj_fc_type_node; @@ -213,9 +218,6 @@ typedef hash_table<action_record_hasher> action_hash_type; static bool get_eh_region_and_lp_from_rtx (const_rtx, eh_region *, eh_landing_pad *); -static int t2r_eq (const void *, const void *); -static hashval_t t2r_hash (const void *); - static void dw2_build_landing_pads (void); static int collect_one_action_chain (action_hash_type *, eh_region); @@ -237,7 +239,8 @@ init_eh (void) if (! flag_exceptions) return; - type_to_runtime_map = htab_create_ggc (31, t2r_hash, t2r_eq, NULL); + type_to_runtime_map + = hash_map<tree, tree, tree_hash_traits>::create_ggc (31); /* Create the SjLj_Function_Context structure. This should match the definition in unwind-sjlj.c. */ @@ -671,54 +674,28 @@ eh_region_outermost (struct function *ifun, eh_region region_a, return region_a; } -static int -t2r_eq (const void *pentry, const void *pdata) -{ - const_tree const entry = (const_tree) pentry; - const_tree const data = (const_tree) pdata; - - return TREE_PURPOSE (entry) == data; -} - -static hashval_t -t2r_hash (const void *pentry) -{ - const_tree const entry = (const_tree) pentry; - return TREE_HASH (TREE_PURPOSE (entry)); -} - void add_type_for_runtime (tree type) { - tree *slot; - /* If TYPE is NOP_EXPR, it means that it already is a runtime type. */ if (TREE_CODE (type) == NOP_EXPR) return; - slot = (tree *) htab_find_slot_with_hash (type_to_runtime_map, type, - TREE_HASH (type), INSERT); - if (*slot == NULL) - { - tree runtime = lang_hooks.eh_runtime_type (type); - *slot = tree_cons (type, runtime, NULL_TREE); - } + bool existed = false; + tree *slot = &type_to_runtime_map->get_or_insert (type, &existed); + if (!existed) + *slot = lang_hooks.eh_runtime_type (type); } tree lookup_type_for_runtime (tree type) { - tree *slot; - /* If TYPE is NOP_EXPR, it means that it already is a runtime type. */ if (TREE_CODE (type) == NOP_EXPR) return type; - slot = (tree *) htab_find_slot_with_hash (type_to_runtime_map, type, - TREE_HASH (type), NO_INSERT); - /* We should have always inserted the data earlier. */ - return TREE_VALUE (*slot); + return *type_to_runtime_map->get (type); } @@ -3150,12 +3127,12 @@ output_function_exception_table (const char *fnname) } void -set_eh_throw_stmt_table (struct function *fun, struct htab *table) +set_eh_throw_stmt_table (function *fun, hash_map<gimple, int> *table) { fun->eh->throw_stmt_table = table; } -htab_t +hash_map<gimple, int> * get_eh_throw_stmt_table (struct function *fun) { return fun->eh->throw_stmt_table; |