Commit ea3a515d authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Fix the logic that should ensure that a string cannot have

a hash key of zero.
Review URL: http://codereview.chromium.org/9113006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10338 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1327cb0a
......@@ -4381,7 +4381,7 @@ uint32_t StringHasher::GetHash() {
result += (result << 3);
result ^= (result >> 11);
result += (result << 15);
if (result == 0) {
if ((result & String::kHashBitMask) == 0) {
result = 27;
}
return result;
......
......@@ -11444,7 +11444,7 @@ class TwoCharHashTableKey : public HashTableKey {
hash += hash << 3;
hash ^= hash >> 11;
hash += hash << 15;
if (hash == 0) hash = 27;
if ((hash & String::kHashBitMask) == 0) hash = 27;
#ifdef DEBUG
StringHasher hasher(2, seed);
hasher.AddCharacter(c1);
......
......@@ -6459,6 +6459,10 @@ class String: public HeapObject {
// Shift constant retrieving hash code from hash field.
static const int kHashShift = kNofHashBitFields;
// Only these bits are relevant in the hash, since the top two are shifted
// out.
static const uint32_t kHashBitMask = 0xffffffffu >> kHashShift;
// Array index strings this short can keep their index in the hash
// field.
static const int kMaxCachedArrayIndexLength = 7;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment