From 3c5e89937856c5e9707c97b8125bab36e0089848 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Mon, 22 Oct 2012 10:38:40 +0000 Subject: [PATCH] Fix two-char hash to use correct fallback for zero hashes. R=verwaest@chromium.org BUG= Review URL: https://chromiumcodereview.appspot.com/11228004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12782 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap.cc | 2 +- src/objects-inl.h | 2 +- src/objects.cc | 2 +- src/objects.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/heap.cc b/src/heap.cc index 037e460c3f..e3fcb93a75 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -2713,7 +2713,7 @@ bool Heap::CreateInitialObjects() { // hash code in place. The hash code for the hidden_symbol is zero to ensure // that it will always be at the first entry in property descriptors. { MaybeObject* maybe_obj = - AllocateSymbol(CStrVector(""), 0, String::kZeroHash); + AllocateSymbol(CStrVector(""), 0, String::kEmptyStringHash); if (!maybe_obj->ToObject(&obj)) return false; } hidden_symbol_ = String::cast(obj); diff --git a/src/objects-inl.h b/src/objects-inl.h index ebcbbd23fd..d2f996bae6 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -4955,7 +4955,7 @@ uint32_t StringHasher::GetHashCore(uint32_t running_hash) { running_hash ^= (running_hash >> 11); running_hash += (running_hash << 15); if ((running_hash & String::kHashBitMask) == 0) { - return 27; + return kZeroHash; } return running_hash; } diff --git a/src/objects.cc b/src/objects.cc index 1735175571..f1488226cb 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -12083,7 +12083,7 @@ class TwoCharHashTableKey : public HashTableKey { hash += hash << 3; hash ^= hash >> 11; hash += hash << 15; - if ((hash & String::kHashBitMask) == 0) hash = String::kZeroHash; + if ((hash & String::kHashBitMask) == 0) hash = StringHasher::kZeroHash; #ifdef DEBUG StringHasher hasher(2, seed); hasher.AddCharacter(c1); diff --git a/src/objects.h b/src/objects.h index 9122e16855..0d1a69cb98 100644 --- a/src/objects.h +++ b/src/objects.h @@ -7380,7 +7380,7 @@ class String: public HeapObject { kIsNotArrayIndexMask | kHashNotComputedMask; // Value of hash field containing computed hash equal to zero. - static const int kZeroHash = kIsNotArrayIndexMask; + static const int kEmptyStringHash = kIsNotArrayIndexMask; // Maximal string length. static const int kMaxLength = (1 << (32 - 2)) - 1;