mirror of git://gcc.gnu.org/git/gcc.git
fix hash_table when empty elements are not 0
gcc/ChangeLog: 2014-11-20 Trevor Saunders <tsaunders@mozilla.com> * hash-table.h (hash_table::hash_table): Call alloc_entries. (hash_table::alloc_entries): new method. (hash_table::expand): Call alloc_entries. (hash_table::empty): Likewise. From-SVN: r217868
This commit is contained in:
parent
d242408fda
commit
1f012f560f
|
|
@ -1,3 +1,10 @@
|
||||||
|
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
|
||||||
|
|
||||||
|
* hash-table.h (hash_table::hash_table): Call alloc_entries.
|
||||||
|
(hash_table::alloc_entries): new method.
|
||||||
|
(hash_table::expand): Call alloc_entries.
|
||||||
|
(hash_table::empty): Likewise.
|
||||||
|
|
||||||
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
|
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
|
||||||
|
|
||||||
* config/i386/i386.c, function.c, trans-mem.c, tree-core.h,
|
* config/i386/i386.c, function.c, trans-mem.c, tree-core.h,
|
||||||
|
|
|
||||||
|
|
@ -1201,6 +1201,7 @@ private:
|
||||||
template<typename T> friend void gt_pch_nx (hash_table<T> *,
|
template<typename T> friend void gt_pch_nx (hash_table<T> *,
|
||||||
gt_pointer_operator, void *);
|
gt_pointer_operator, void *);
|
||||||
|
|
||||||
|
value_type *alloc_entries (size_t n) const;
|
||||||
value_type *find_empty_slot_for_expand (hashval_t);
|
value_type *find_empty_slot_for_expand (hashval_t);
|
||||||
void expand ();
|
void expand ();
|
||||||
static bool is_deleted (value_type &v)
|
static bool is_deleted (value_type &v)
|
||||||
|
|
@ -1259,12 +1260,7 @@ hash_table<Descriptor, Allocator, true>::hash_table (size_t size, bool ggc) :
|
||||||
size_prime_index = hash_table_higher_prime_index (size);
|
size_prime_index = hash_table_higher_prime_index (size);
|
||||||
size = prime_tab[size_prime_index].prime;
|
size = prime_tab[size_prime_index].prime;
|
||||||
|
|
||||||
if (!m_ggc)
|
m_entries = alloc_entries (size);
|
||||||
m_entries = Allocator <value_type> ::data_alloc (size);
|
|
||||||
else
|
|
||||||
m_entries = ggc_cleared_vec_alloc<value_type> (size);
|
|
||||||
|
|
||||||
gcc_assert (m_entries != NULL);
|
|
||||||
m_size = size;
|
m_size = size;
|
||||||
m_size_prime_index = size_prime_index;
|
m_size_prime_index = size_prime_index;
|
||||||
}
|
}
|
||||||
|
|
@ -1282,6 +1278,26 @@ hash_table<Descriptor, Allocator, true>::~hash_table ()
|
||||||
ggc_free (m_entries);
|
ggc_free (m_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function returns an array of empty hash table elements. */
|
||||||
|
|
||||||
|
template<typename Descriptor, template<typename Type> class Allocator>
|
||||||
|
inline typename hash_table<Descriptor, Allocator, true>::value_type *
|
||||||
|
hash_table<Descriptor, Allocator, true>::alloc_entries (size_t n) const
|
||||||
|
{
|
||||||
|
value_type *nentries;
|
||||||
|
|
||||||
|
if (!m_ggc)
|
||||||
|
nentries = Allocator <value_type> ::data_alloc (n);
|
||||||
|
else
|
||||||
|
nentries = ::ggc_cleared_vec_alloc<value_type> (n);
|
||||||
|
|
||||||
|
gcc_assert (nentries != NULL);
|
||||||
|
for (size_t i = 0; i < n; i++)
|
||||||
|
mark_empty (nentries[i]);
|
||||||
|
|
||||||
|
return nentries;
|
||||||
|
}
|
||||||
|
|
||||||
/* Similar to find_slot, but without several unwanted side effects:
|
/* Similar to find_slot, but without several unwanted side effects:
|
||||||
- Does not call equal when it finds an existing entry.
|
- Does not call equal when it finds an existing entry.
|
||||||
- Does not change the count of elements/searches/collisions in the
|
- Does not change the count of elements/searches/collisions in the
|
||||||
|
|
@ -1351,13 +1367,7 @@ hash_table<Descriptor, Allocator, true>::expand ()
|
||||||
nsize = osize;
|
nsize = osize;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type *nentries;
|
value_type *nentries = alloc_entries (nsize);
|
||||||
if (!m_ggc)
|
|
||||||
nentries = Allocator <value_type> ::data_alloc (nsize);
|
|
||||||
else
|
|
||||||
nentries = ggc_cleared_vec_alloc<value_type> (nsize);
|
|
||||||
|
|
||||||
gcc_assert (nentries != NULL);
|
|
||||||
m_entries = nentries;
|
m_entries = nentries;
|
||||||
m_size = nsize;
|
m_size = nsize;
|
||||||
m_size_prime_index = nindex;
|
m_size_prime_index = nindex;
|
||||||
|
|
@ -1405,16 +1415,11 @@ hash_table<Descriptor, Allocator, true>::empty ()
|
||||||
int nsize = prime_tab[nindex].prime;
|
int nsize = prime_tab[nindex].prime;
|
||||||
|
|
||||||
if (!m_ggc)
|
if (!m_ggc)
|
||||||
{
|
|
||||||
Allocator <value_type> ::data_free (m_entries);
|
Allocator <value_type> ::data_free (m_entries);
|
||||||
m_entries = Allocator <value_type> ::data_alloc (nsize);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ggc_free (m_entries);
|
ggc_free (m_entries);
|
||||||
m_entries = ggc_cleared_vec_alloc<value_type> (nsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
m_entries = alloc_entries (nsize);
|
||||||
m_size = nsize;
|
m_size = nsize;
|
||||||
m_size_prime_index = nindex;
|
m_size_prime_index = nindex;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue