diff options
author | Trevor Saunders <tsaunders@mozilla.com> | 2014-11-20 15:10:19 +0000 |
---|---|---|
committer | Trevor Saunders <tbsaunde@gcc.gnu.org> | 2014-11-20 15:10:19 +0000 |
commit | d242408fda0bb64230b5446911d860df3e19a3da (patch) | |
tree | f1326eb25df16ac5403659af6e7b0668a0042fb0 /gcc/ada | |
parent | aebf76a2d6de989fe3e8c88aa047e4cfbd1e340e (diff) | |
download | gcc-d242408fda0bb64230b5446911d860df3e19a3da.zip gcc-d242408fda0bb64230b5446911d860df3e19a3da.tar.gz gcc-d242408fda0bb64230b5446911d860df3e19a3da.tar.bz2 |
convert many if_marked htab to hash_table
ada/
* gcc-interface/decl.c, gcc-interface/utils.c: replace htab with
hash_table.
cp/
* cp-objcp-common.c: Use hash_table instead of htab.
gcc/
* config/i386/i386.c, function.c, trans-mem.c, tree-core.h,
tree.c, tree.h, ubsan.c, varasm.c: Use hash_table instead of htab.
From-SVN: r217867
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 41 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 61 |
3 files changed, 65 insertions, 42 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 457d7f9..fa056d3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2014-11-20 Trevor Saunders <tsaunders@mozilla.com> + + * gcc-interface/decl.c, gcc-interface/utils.c: replace htab with + hash_table. + 2014-11-20 Robert Dewar <dewar@adacore.com> * sem_prag.adb (Analyze_Pragma, case Elaborate): Forbid pragma diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 2ed68d4..c133a22 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -128,8 +128,35 @@ typedef struct variant_desc_d { /* A hash table used to cache the result of annotate_value. */ -static GTY ((if_marked ("tree_int_map_marked_p"), - param_is (struct tree_int_map))) htab_t annotate_value_cache; + +struct value_annotation_hasher : ggc_cache_hasher<tree_int_map *> +{ + static inline hashval_t + hash (tree_int_map *m) + { + return htab_hash_pointer (m->base.from); + } + + static inline bool + equal (tree_int_map *a, tree_int_map *b) + { + return a->base.from == b->base.from; + } + + static void + handle_cache_entry (tree_int_map *&m) + { + extern void gt_ggc_mx (tree_int_map *&); + if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY) + return; + else if (ggc_marked_p (m->base.from)) + gt_ggc_mx (m); + else + m = static_cast<tree_int_map *> (HTAB_DELETED_ENTRY); + } +}; + +static GTY ((cache)) hash_table<value_annotation_hasher> *annotate_value_cache; static bool allocatable_size_p (tree, bool); static void prepend_one_attribute (struct attrib **, @@ -7362,7 +7389,7 @@ annotate_value (tree gnu_size) struct tree_int_map *e; in.base.from = gnu_size; - e = (struct tree_int_map *) htab_find (annotate_value_cache, &in); + e = annotate_value_cache->find (&in); if (e) return (Node_Ref_Or_Val) e->to; @@ -7491,8 +7518,7 @@ annotate_value (tree gnu_size) look up, so we have to search again. Allocating and inserting an entry at that point would be an alternative, but then we'd better discard the entry if we decided not to cache it. */ - h = (struct tree_int_map **) - htab_find_slot (annotate_value_cache, &in, INSERT); + h = annotate_value_cache->find_slot (&in, INSERT); gcc_assert (!*h); *h = ggc_alloc<tree_int_map> (); (*h)->base.from = gnu_size; @@ -8840,8 +8866,7 @@ void init_gnat_decl (void) { /* Initialize the cache of annotated values. */ - annotate_value_cache - = htab_create_ggc (512, tree_int_map_hash, tree_int_map_eq, 0); + annotate_value_cache = hash_table<value_annotation_hasher>::create_ggc (512); } /* Destroy data structures of the decl.c module. */ @@ -8850,7 +8875,7 @@ void destroy_gnat_decl (void) { /* Destroy the cache of annotated values. */ - htab_delete (annotate_value_cache); + annotate_value_cache->empty (); annotate_value_cache = NULL; } diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 4d35060..32f0012 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -233,20 +233,23 @@ static GTY(()) vec<tree, va_gc> *global_renaming_pointers; /* A chain of unused BLOCK nodes. */ static GTY((deletable)) tree free_block_chain; -static int pad_type_hash_marked_p (const void *p); -static hashval_t pad_type_hash_hash (const void *p); -static int pad_type_hash_eq (const void *p1, const void *p2); - /* A hash table of padded types. It is modelled on the generic type hash table in tree.c, which must thus be used as a reference. */ -struct GTY(()) pad_type_hash { + +struct GTY((for_user)) pad_type_hash { unsigned long hash; tree type; }; -static GTY ((if_marked ("pad_type_hash_marked_p"), - param_is (struct pad_type_hash))) - htab_t pad_type_hash_table; +struct pad_type_hasher : ggc_cache_hasher<pad_type_hash *> +{ + static inline hashval_t hash (pad_type_hash *t) { return t->hash; } + static bool equal (pad_type_hash *a, pad_type_hash *b); + static void handle_cache_entry (pad_type_hash *&); +}; + +static GTY ((cache)) + hash_table<pad_type_hasher> *pad_type_hash_table; static tree merge_sizes (tree, tree, tree, bool, bool); static tree compute_related_constant (tree, tree); @@ -294,8 +297,7 @@ init_gnat_utils (void) dummy_node_table = ggc_cleared_vec_alloc<tree> (max_gnat_nodes); /* Initialize the hash table of padded types. */ - pad_type_hash_table - = htab_create_ggc (512, pad_type_hash_hash, pad_type_hash_eq, 0); + pad_type_hash_table = hash_table<pad_type_hasher>::create_ggc (512); } /* Destroy data structures of the utils.c module. */ @@ -312,7 +314,7 @@ destroy_gnat_utils (void) dummy_node_table = NULL; /* Destroy the hash table of padded types. */ - htab_delete (pad_type_hash_table); + pad_type_hash_table->empty (); pad_type_hash_table = NULL; /* Invalidate the global renaming pointers. */ @@ -1155,29 +1157,23 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) /* See if the data pointed to by the hash table slot is marked. */ -static int -pad_type_hash_marked_p (const void *p) -{ - const_tree const type = ((const struct pad_type_hash *) p)->type; - - return ggc_marked_p (type); -} - -/* Return the cached hash value. */ - -static hashval_t -pad_type_hash_hash (const void *p) +void +pad_type_hasher::handle_cache_entry (pad_type_hash *&t) { - return ((const struct pad_type_hash *) p)->hash; + extern void gt_ggc_mx (pad_type_hash *&); + if (t == HTAB_EMPTY_ENTRY || t == HTAB_DELETED_ENTRY) + return; + else if (ggc_marked_p (t->type)) + gt_ggc_mx (t); + else + t = static_cast<pad_type_hash *> (HTAB_DELETED_ENTRY); } -/* Return 1 iff the padded types are equivalent. */ +/* Return true iff the padded types are equivalent. */ -static int -pad_type_hash_eq (const void *p1, const void *p2) +bool +pad_type_hasher::equal (pad_type_hash *t1, pad_type_hash *t2) { - const struct pad_type_hash *const t1 = (const struct pad_type_hash *) p1; - const struct pad_type_hash *const t2 = (const struct pad_type_hash *) p2; tree type1, type2; if (t1->hash != t2->hash) @@ -1204,7 +1200,6 @@ lookup_and_insert_pad_type (tree type) { hashval_t hashcode; struct pad_type_hash in, *h; - void **loc; hashcode = iterative_hash_object (TYPE_HASH (TREE_TYPE (TYPE_FIELDS (type))), 0); @@ -1214,16 +1209,14 @@ lookup_and_insert_pad_type (tree type) in.hash = hashcode; in.type = type; - h = (struct pad_type_hash *) - htab_find_with_hash (pad_type_hash_table, &in, hashcode); + h = pad_type_hash_table->find_with_hash (&in, hashcode); if (h) return h->type; h = ggc_alloc<pad_type_hash> (); h->hash = hashcode; h->type = type; - loc = htab_find_slot_with_hash (pad_type_hash_table, h, hashcode, INSERT); - *loc = (void *)h; + *pad_type_hash_table->find_slot_with_hash (h, hashcode, INSERT) = h; return NULL_TREE; } |