aboutsummaryrefslogtreecommitdiff
path: root/gcc/hash-table.h
diff options
context:
space:
mode:
authorTrevor Saunders <tsaunders@mozilla.com>2014-10-12 22:22:53 +0000
committerTrevor Saunders <tbsaunde@gcc.gnu.org>2014-10-12 22:22:53 +0000
commit2a22f99cb12d82712dd93cfef808b1cef543601b (patch)
treec828063f153ceb609ce5c7d44ea9f00391b32950 /gcc/hash-table.h
parent7b262a51ea2310bdb6cc901de00f04b0e7be0a4e (diff)
downloadgcc-2a22f99cb12d82712dd93cfef808b1cef543601b.zip
gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.gz
gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.bz2
move many gc hashtab to hash_table
gcc/ * asan.c, cfgloop.c, cfgloop.h, cgraph.c, cgraph.h, config/darwin.c, config/m32c/m32c.c, config/mep/mep.c, config/mips/mips.c, config/rs6000/rs6000.c, dwarf2out.c, function.c, function.h, gimple-ssa.h, libfuncs.h, optabs.c, output.h, rtl.h, sese.c, symtab.c, tree-cfg.c, tree-dfa.c, tree-ssa.c, varasm.c: Use hash-table instead of hashtab. * doc/gty.texi (for_user): Document new option. * gengtype.c (create_user_defined_type): Don't try to get a struct for char. (walk_type): Don't error out on for_user option. (write_func_for_structure): Emit user marking routines if requested by for_user option. (write_local_func_for_structure): Likewise. (main): Mark types with for_user option as used. * ggc.h (gt_pch_nx): Add overload for unsigned int. * hash-map.h (hash_map::hash_entry::pch_nx_helper): AddOverloads. * hash-table.h (ggc_hasher): New struct. (hash_table::create_ggc): New function. (gt_pch_nx): New overload for hash_table. java/ * class.c, decl.c, except.c, expr.c, java-tree.h, lang.c: Use hash_table instead of hashtab. objc/ * objc-act.c: use hash_table instead of hashtab. cp/ * cp-gimplify.c, cp-tree.h, decl.c, mangle.c, name-lookup.c, pt.c, semantics.c, tree.c, typeck2.c: Use hash_table instead of hashtab. fortran/ * trans-decl.c, trans.c, trans.h: Use hash_table instead of hashtab. c-family/ * c-common.c: Use hash_table instead of hashtab. From-SVN: r216127
Diffstat (limited to 'gcc/hash-table.h')
-rw-r--r--gcc/hash-table.h64
1 files changed, 60 insertions, 4 deletions
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 028b7de..2493f2e 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -198,6 +198,7 @@ along with GCC; see the file COPYING3. If not see
#include "ggc.h"
#include "hashtab.h"
+#include <new>
template<typename, typename, typename> class hash_map;
template<typename, typename> class hash_set;
@@ -301,6 +302,38 @@ pointer_hash <Type>::equal (const value_type &existing,
return existing == candidate;
}
+/* Hasher for entry in gc memory. */
+
+template<typename T>
+struct ggc_hasher
+{
+ typedef T value_type;
+ typedef T compare_type;
+ typedef int store_values_directly;
+
+ static void remove (T) {}
+
+ static void
+ ggc_mx (T p)
+ {
+ extern void gt_ggc_mx (T &);
+ gt_ggc_mx (p);
+ }
+
+ static void
+ pch_nx (T &p)
+ {
+ extern void gt_pch_nx (T &);
+ gt_pch_nx (p);
+ }
+
+ static void
+ pch_nx (T &p, gt_pointer_operator op, void *cookie)
+ {
+ op (&p, cookie);
+ }
+};
+
/* Table of primes and their inversion information. */
@@ -1004,6 +1037,16 @@ public:
explicit hash_table (size_t, bool ggc = false);
~hash_table ();
+ /* Create a hash_table in gc memory. */
+
+ static hash_table *
+ create_ggc (size_t n)
+ {
+ hash_table *table = ggc_alloc<hash_table> ();
+ new (table) hash_table (n, true);
+ return table;
+ }
+
/* Current size (in entries) of the hash table. */
size_t size () const { return m_size; }
@@ -1110,9 +1153,15 @@ public:
private:
template<typename T> friend void gt_ggc_mx (hash_table<T> *);
template<typename T> friend void gt_pch_nx (hash_table<T> *);
- template<typename T> friend void hashtab_entry_note_pointers (void *, void *, gt_pointer_operator, void *);
- template<typename T, typename U, typename V> friend void gt_pch_nx (hash_map<T, U, V> *, gt_pointer_operator, void *);
- template<typename T, typename U> friend void gt_pch_nx (hash_set<T, U> *, gt_pointer_operator, void *);
+ template<typename T> friend void
+ hashtab_entry_note_pointers (void *, void *, gt_pointer_operator, void *);
+ template<typename T, typename U, typename V> friend void
+ gt_pch_nx (hash_map<T, U, V> *, gt_pointer_operator, void *);
+ template<typename T, typename U> friend void gt_pch_nx (hash_set<T, U> *,
+ gt_pointer_operator,
+ void *);
+ template<typename T> friend void gt_pch_nx (hash_table<T> *,
+ gt_pointer_operator, void *);
value_type *find_empty_slot_for_expand (hashval_t);
void expand ();
@@ -1598,7 +1647,7 @@ template<typename D>
static void
gt_pch_nx (hash_table<D> *h)
{
- bool success ATTRIBUTE_UNUSED
+ bool success
= gt_pch_note_object (h->m_entries, h, hashtab_entry_note_pointers<D>);
gcc_checking_assert (success);
for (size_t i = 0; i < h->m_size; i++)
@@ -1611,4 +1660,11 @@ gt_pch_nx (hash_table<D> *h)
}
}
+template<typename D>
+static inline void
+gt_pch_nx (hash_table<D> *h, gt_pointer_operator op, void *cookie)
+{
+ op (&h->m_entries, cookie);
+}
+
#endif /* TYPED_HASHTAB_H */