gecko-dev/xpcom
L. David Baron 07c2f2dc49 Bug 1352889 - Ensure that PLDHashTable's second hash doesn't have padding with 0 bits for tables with capacity larger than 2^16. r=njn
PLDHashTable takes the result of the hash function and multiplies it by
kGoldenRatio to ensure that it has a good distribution of bits across
the 32-bit hash value, and then zeroes out the low bit so that it can be
used for the collision flag.  This result is called hash0.  From hash0
it computes two different numbers used to find entries in the table
storage:  hash1 is used to find an initial position in the table to
begin searching for an entry; hash2 is then used to repeatedly offset
that position (mod the size of the table) to build a chain of positions
to search.

In a table with capacity 2^c entries, hash1 is simply the upper c bits
of hash0.  This patch does not change this.

Prior to this patch, hash2 was the c bits below hash1, padded at the low
end with zeroes when c > 16.  (Note that bug 927705, changeset
1a02bec165e16f370cace3da21bb2b377a0a7242, increased the maximum capacity
from 2^23 to 2^26 since 2^23 was sometimes insufficient!)  This manner
of computing hash2 is problematic because it increases the risk of long
chains for very large tables, since there is less variation in the hash2
result due to the zero padding.

So this patch changes the hash2 computation by using the low bits of
hash0 instead of shifting it around, thus avoiding 0 bits in parts of
the hash2 value that are significant.

Note that this changes what hash2 is in all cases except when the table
capacity is exactly 2^16, so it does change our hashing characteristics.
For tables with capacity less than 2^16, it should be using a different
second hash, but with the same amount of random-ish data.  For tables
with capacity greater than 2^16, it should be using more random-ish
data.

Note that this patch depends on the patch for bug 1353458 in order to
avoid causing test failures.

MozReview-Commit-ID: JvnxAMBY711

--HG--
extra : transplant_source : 2%D2%C2%CE%E1%92%C8%F8H%D7%15%A4%86%5B%3Ac%0B%08%3DA
2017-05-31 13:44:02 -07:00
..
base Bug 1367496 - Add more release asserts to the cycle collector. r=smaug 2017-05-24 10:13:02 -07:00
build Bug 1367899: Add handling for test r/m32, r32 and jne rel8 opcodes; r=dmajor 2017-05-26 01:56:07 +02:00
components Bug 1360971 - Part 1: Add the nsCategoryCache<T>::GetCachedEntries() API; r=froydnj 2017-05-08 10:31:13 -04:00
doc
ds Bug 1352889 - Ensure that PLDHashTable's second hash doesn't have padding with 0 bits for tables with capacity larger than 2^16. r=njn 2017-05-31 13:44:02 -07:00
glue Bug 1332639 followup. I apparently didn't actually remove the nsStringAPI.* files, but that was the intention, r=oops 2017-03-02 09:23:08 -05:00
idl-parser Bug 1366869 - Make DISPATCH_NORMAL be the default flags argument for nsIEventTarget::Dispatch (r=froydnj) 2017-05-23 12:05:43 -07:00
io Bug 1364050 - Part 4 - Remove references to "downloads.rdf". r=mak 2017-05-11 09:37:10 +01:00
libxpt/xptcall
reflect Bug 1360321 - 6. Add AArch64 support in xpcom; r=froydnj 2017-05-17 13:06:23 -04:00
rust Bug 1336153 - Remove MOZ_RUST. r=ted 2017-05-09 11:36:13 -07:00
string Bug 1353755 - remove nsCharTraits::assign; r=erahm 2017-05-22 09:23:09 -04:00
system Bug 1349363 - Centralize pref-checking code for e10s-multi control. r=Felipe 2017-04-17 14:36:04 -07:00
tests Merge m-c to autoland on a CLOSED TREE. a=merge 2017-05-26 15:45:41 -04:00
threads merge mozilla-inbound to mozilla-central + UPGRADE_NSS_RELEASE a=merge 2017-05-30 11:37:46 +02:00
typelib Bug 1336311 - Change code comments with http://hg.mozilla.org to https://. r=gps 2017-02-07 17:52:56 +01:00
windbgdlg
xpidl
moz.build Bug 1295762 - Part 1: Implement rust bindings to XPCOM's string types, r=froydnj 2016-09-20 11:26:43 -04:00
xpcom-config.h.in Bug 1326145 - Remove HAVE_CPP_AMBIGUITY_RESOLVING_USING. r=froydnj 2016-12-29 18:05:20 +11:00
xpcom-private.h.in