 Chromium Code Reviews
 Chromium Code Reviews Issue 9124004:
  Backport hash collision workaround to 3.6.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/3.6/
    
  
    Issue 9124004:
  Backport hash collision workaround to 3.6.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/3.6/| Index: src/objects.h | 
| =================================================================== | 
| --- src/objects.h (revision 10353) | 
| +++ src/objects.h (working copy) | 
| @@ -5734,7 +5734,7 @@ | 
| class StringHasher { | 
| public: | 
| - explicit inline StringHasher(int length); | 
| + explicit inline StringHasher(int length, uint32_t seed); | 
| // Returns true if the hash of this string can be computed without | 
| // looking at the contents. | 
| @@ -5785,7 +5785,9 @@ | 
| // Calculates string hash. | 
| template <typename schar> | 
| -inline uint32_t HashSequentialString(const schar* chars, int length); | 
| +inline uint32_t HashSequentialString(const schar* chars, | 
| + int length, | 
| + uint32_t seed); | 
| // The characteristics of a string are stored in its map. Retrieving these | 
| @@ -6007,7 +6009,8 @@ | 
| inline uint32_t Hash(); | 
| static uint32_t ComputeHashField(unibrow::CharacterStream* buffer, | 
| - int length); | 
| + int length, | 
| + uint32_t seed); | 
| static bool ComputeArrayIndex(unibrow::CharacterStream* buffer, | 
| uint32_t* index, | 
| @@ -6072,6 +6075,10 @@ | 
| // 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; | 
| 
Vyacheslav Egorov (Chromium)
2012/01/09 19:09:33
this constant is duplicated in every code generato
 
Erik Corry
2012/01/10 00:18:44
Yes, this should be fixed in bleeding edge.
 | 
| + | 
| // Array index strings this short can keep their index in the hash | 
| // field. | 
| static const int kMaxCachedArrayIndexLength = 7; |