Change ggc-common hash tables from htab_t to hash_table:
ggc-common.c loc_hash
ggc-common.c ptr_hash
Add a new hash_table method elements_with_deleted to meet the needs of
gcc-common.c.
Correct many methods with parameter types compare_type to the correct
value_type. (Correct code was unlikely to notice the change, but
incorrect code will.)
Tested on x86-64.
Okay for branch?
Index: gcc/ChangeLog
2012-11-30 Lawrence Crowl cr...@google.com
* hash-table.h (class hash_table):
Correct many methods with parameter types compare_type to the correct
value_type. (Correct code was unlikely to notice the change.)
(hash_table::elements_with_deleted) New.
* ggc-common.c (htab_t saving_htab):
Change type to hash_table. Update dependent calls and types.
(htab_t loc_hash): Likewise.
(htab_t ptr_hash): Likewise.
(call_count): Rename ggc_call_count.
(call_alloc): Rename ggc_call_alloc.
(loc_descriptor): Rename make_loc_descriptor.
(add_statistics): Rename ggc_add_statistics.
* Makefile.in: Update to changes above.
Index: gcc/hash-table.h
===
--- gcc/hash-table.h(revision 193902)
+++ gcc/hash-table.h(working copy)
@@ -380,19 +380,19 @@ public:
void create (size_t initial_slots);
bool is_created ();
void dispose ();
- value_type *find (const compare_type *comparable);
+ value_type *find (const value_type *value);
value_type *find_with_hash (const compare_type *comparable, hashval_t hash);
- value_type **find_slot (const compare_type *comparable,
- enum insert_option insert);
+ value_type **find_slot (const value_type *value, enum insert_option insert);
value_type **find_slot_with_hash (const compare_type *comparable,
hashval_t hash, enum insert_option insert);
void empty ();
void clear_slot (value_type **slot);
- void remove_elt (const compare_type *comparable);
+ void remove_elt (const value_type *value);
void remove_elt_with_hash (const compare_type *comparable, hashval_t hash);
- size_t size();
- size_t elements();
- double collisions();
+ size_t size ();
+ size_t elements ();
+ size_t elements_with_deleted ();
+ double collisions ();
template typename Argument,
int (*Callback) (value_type **slot, Argument argument)
@@ -431,9 +431,9 @@ hash_table Descriptor, Allocator::is_c
template typename Descriptor,
template typename Type class Allocator
inline typename Descriptor::value_type *
-hash_table Descriptor, Allocator::find (const compare_type *comparable)
+hash_table Descriptor, Allocator::find (const value_type *value)
{
- return find_with_hash (comparable, Descriptor::hash (comparable));
+ return find_with_hash (value, Descriptor::hash (value));
}
@@ -443,9 +443,9 @@ template typename Descriptor,
template typename Type class Allocator
inline typename Descriptor::value_type **
hash_table Descriptor, Allocator
-::find_slot (const compare_type *comparable, enum insert_option insert)
+::find_slot (const value_type *value, enum insert_option insert)
{
- return find_slot_with_hash (comparable, Descriptor::hash
(comparable), insert);
+ return find_slot_with_hash (value, Descriptor::hash (value), insert);
}
@@ -454,9 +454,9 @@ hash_table Descriptor, Allocator
template typename Descriptor,
template typename Type class Allocator
inline void
-hash_table Descriptor, Allocator::remove_elt (const compare_type *comparable)
+hash_table Descriptor, Allocator::remove_elt (const value_type *value)
{
- remove_elt_with_hash (comparable, Descriptor::hash (comparable));
+ remove_elt_with_hash (value, Descriptor::hash (value));
}
@@ -476,12 +476,23 @@ hash_table Descriptor, Allocator::size
template typename Descriptor,
template typename Type class Allocator
inline size_t
-hash_table Descriptor, Allocator::elements()
+hash_table Descriptor, Allocator::elements ()
{
return htab-n_elements - htab-n_deleted;
}
+/* Return the current number of elements in this hash table. */
+
+template typename Descriptor,
+ template typename Type class Allocator
+inline size_t
+hash_table Descriptor, Allocator::elements_with_deleted ()
+{
+ return htab-n_elements;
+}
+
+
/* Return the fraction of fixed collisions during all work with given
hash table. */
Index: gcc/ggc-common.c
===
--- gcc/ggc-common.c(revision 193902)
+++ gcc/ggc-common.c(working copy)
@@ -24,7 +24,7 @@ along with GCC; see the file COPYING3.
#include config.h
#include system.h
#include coretypes.h
-#include hashtab.h
+#include hash-table.h
#include ggc.h
#include ggc-internal.h
#include diagnostic-core.h
@@ -47,10 +47,6 @@ static ggc_statistics *ggc_stats;
struct traversal_state;
static int ggc_htab_delete (void **, void *);