Title: [125620] branches/safari-536.26-branch/Source

Diff

Modified: branches/safari-536.26-branch/Source/_javascript_Core/ChangeLog (125619 => 125620)


--- branches/safari-536.26-branch/Source/_javascript_Core/ChangeLog	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/_javascript_Core/ChangeLog	2012-08-14 23:25:58 UTC (rev 125620)
@@ -1,3 +1,21 @@
+2012-08-14  Lucas Forschler  <[email protected]>
+
+    Merge r124268.
+
+    2012-07-31  Sam Weinig  <[email protected]>
+
+            Stop masking 8 bits off of the visited link hash. We need all the bits!
+            https://bugs.webkit.org/show_bug.cgi?id=92799
+
+            Reviewed by Anders Carlsson.
+
+            * runtime/Identifier.cpp:
+            (JSC::IdentifierCStringTranslator::hash):
+            (JSC::IdentifierLCharFromUCharTranslator::hash):
+            * runtime/Identifier.h:
+            (JSC::IdentifierCharBufferTranslator::hash):
+            Update for new function names.
+
 2012-08-10  Lucas Forschler  <[email protected]>
     
     Windows build fix after merging radar 12050720.
@@ -69156,3 +69174,4 @@
         global object's register storage, and initializing new registers.
 
 == Rolled over to ChangeLog-2011-02-16 ==
+.

Modified: branches/safari-536.26-branch/Source/_javascript_Core/runtime/Identifier.cpp (125619 => 125620)


--- branches/safari-536.26-branch/Source/_javascript_Core/runtime/Identifier.cpp	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/_javascript_Core/runtime/Identifier.cpp	2012-08-14 23:25:58 UTC (rev 125620)
@@ -49,7 +49,7 @@
 struct IdentifierCStringTranslator {
     static unsigned hash(const LChar* c)
     {
-        return StringHasher::computeHash<LChar>(c);
+        return StringHasher::computeHashAndMaskTop8Bits<LChar>(c);
     }
 
     static bool equal(StringImpl* r, const LChar* s)
@@ -72,7 +72,7 @@
 struct IdentifierLCharFromUCharTranslator {
     static unsigned hash(const CharBuffer<UChar>& buf)
     {
-        return StringHasher::computeHash<UChar>(buf.s, buf.length);
+        return StringHasher::computeHashAndMaskTop8Bits<UChar>(buf.s, buf.length);
     }
     
     static bool equal(StringImpl* str, const CharBuffer<UChar>& buf)

Modified: branches/safari-536.26-branch/Source/_javascript_Core/runtime/Identifier.h (125619 => 125620)


--- branches/safari-536.26-branch/Source/_javascript_Core/runtime/Identifier.h	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/_javascript_Core/runtime/Identifier.h	2012-08-14 23:25:58 UTC (rev 125620)
@@ -147,7 +147,7 @@
     struct IdentifierCharBufferTranslator {
         static unsigned hash(const CharBuffer<T>& buf)
         {
-            return StringHasher::computeHash<T>(buf.s, buf.length);
+            return StringHasher::computeHashAndMaskTop8Bits<T>(buf.s, buf.length);
         }
         
         static bool equal(StringImpl* str, const CharBuffer<T>& buf)

Modified: branches/safari-536.26-branch/Source/WTF/ChangeLog (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/ChangeLog	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/ChangeLog	2012-08-14 23:25:58 UTC (rev 125620)
@@ -1,3 +1,43 @@
+2012-08-14  Lucas Forschler  <[email protected]>
+
+    Merge r124268.
+
+    2012-07-31  Sam Weinig  <[email protected]>
+
+            Stop masking 8 bits off of the visited link hash. We need all the bits!
+            https://bugs.webkit.org/show_bug.cgi?id=92799
+
+            Reviewed by Anders Carlsson.
+
+            * wtf/StringHasher.h:
+            (WTF::StringHasher::hashWithTop8BitsMasked):
+            (WTF::StringHasher::hash):
+            (StringHasher):
+            (WTF::StringHasher::computeHashAndMaskTop8Bits):
+            (WTF::StringHasher::hashMemory):
+            (WTF::StringHasher::avalancheBits):
+            Rename existing computeHash and hash functions to computeHashAndMaskTop8Bits
+            and hashWithTop8BitsMasked respectively. Add new computeHash and hash functions
+            that do the StringHash without the masking.
+
+            * wtf/text/AtomicString.cpp:
+            (WTF::CStringTranslator::hash):
+            (WTF::UCharBufferTranslator::hash):
+            (WTF::HashAndCharactersTranslator::hash):
+            (WTF::SubstringTranslator::hash):
+            (WTF::LCharBufferFromLiteralDataTranslator::hash):
+            (WTF::AtomicString::fromUTF8Internal):
+            * wtf/text/StringHash.h:
+            (WTF::CaseFoldingHash::hash):
+            * wtf/text/StringImpl.h:
+            (WTF::StringImpl::setHash):
+            * wtf/text/StringStatics.cpp:
+            (WTF::StringImpl::hashSlowCase):
+            * wtf/unicode/UTF8.cpp:
+            (WTF::Unicode::calculateStringHashAndLengthFromUTF8MaskingTop8Bits):
+            * wtf/unicode/UTF8.h:
+            Update for new function names.
+
 2012-05-23  Lucas Forschler  <[email protected]>
 
     Merge 117744
@@ -4641,3 +4681,4 @@
 
         This patch creates the WTF directory, which begins the process of
         moving WTF out of _javascript_Core.
+.

Modified: branches/safari-536.26-branch/Source/WTF/wtf/StringHasher.h (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/wtf/StringHasher.h	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/wtf/StringHasher.h	2012-08-14 23:25:58 UTC (rev 125620)
@@ -63,24 +63,10 @@
         m_hasPendingCharacter = true;
     }
 
-    inline unsigned hash() const
+    inline unsigned hashWithTop8BitsMasked() const
     {
-        unsigned result = m_hash;
+        unsigned result = avalancheBits();
 
-        // Handle end case.
-        if (m_hasPendingCharacter) {
-            result += m_pendingCharacter;
-            result ^= result << 11;
-            result += result >> 17;
-        }
-
-        // Force "avalanching" of final 31 bits.
-        result ^= result << 3;
-        result += result >> 5;
-        result ^= result << 2;
-        result += result >> 15;
-        result ^= result << 10;
-
         // Reserving space from the high bits for flags preserves most of the hash's
         // value, since hash lookup typically masks out the high bits anyway.
         result &= (1u << (sizeof(result) * 8 - flagCount)) - 1;
@@ -95,6 +81,67 @@
         return result;
     }
 
+    inline unsigned hash() const
+    {
+        unsigned result = avalancheBits();
+
+        // This avoids ever returning a hash code of 0, since that is used to
+        // signal "hash not computed yet". Setting the high bit maintains
+        // reasonable fidelity to a hash code of 0 because it is likely to yield
+        // exactly 0 when hash lookup masks out the high bits.
+        if (!result)
+            result = 0x80000000;
+
+        return result;
+    }
+
+    template<typename T, UChar Converter(T)> static inline unsigned computeHashAndMaskTop8Bits(const T* data, unsigned length)
+    {
+        StringHasher hasher;
+        bool rem = length & 1;
+        length >>= 1;
+
+        while (length--) {
+            hasher.addCharacters(Converter(data[0]), Converter(data[1]));
+            data += 2;
+        }
+
+        if (rem)
+            hasher.addCharacter(Converter(*data));
+
+        return hasher.hashWithTop8BitsMasked();
+    }
+
+    template<typename T, UChar Converter(T)> static inline unsigned computeHashAndMaskTop8Bits(const T* data)
+    {
+        StringHasher hasher;
+
+        while (true) {
+            UChar b0 = Converter(*data++);
+            if (!b0)
+                break;
+            UChar b1 = Converter(*data++);
+            if (!b1) {
+                hasher.addCharacter(b0);
+                break;
+            }
+
+            hasher.addCharacters(b0, b1);
+        }
+
+        return hasher.hashWithTop8BitsMasked();
+    }
+
+    template<typename T> static inline unsigned computeHashAndMaskTop8Bits(const T* data, unsigned length)
+    {
+        return computeHashAndMaskTop8Bits<T, defaultConverter>(data, length);
+    }
+
+    template<typename T> static inline unsigned computeHashAndMaskTop8Bits(const T* data)
+    {
+        return computeHashAndMaskTop8Bits<T, defaultConverter>(data);
+    }
+
     template<typename T, UChar Converter(T)> static inline unsigned computeHash(const T* data, unsigned length)
     {
         StringHasher hasher;
@@ -145,13 +192,13 @@
     template<size_t length> static inline unsigned hashMemory(const void* data)
     {
         COMPILE_ASSERT(!(length % 4), length_must_be_a_multible_of_four);
-        return computeHash<UChar>(static_cast<const UChar*>(data), length / sizeof(UChar));
+        return computeHashAndMaskTop8Bits<UChar>(static_cast<const UChar*>(data), length / sizeof(UChar));
     }
 
     static inline unsigned hashMemory(const void* data, unsigned size)
     {
         ASSERT(!(size % 2));
-        return computeHash<UChar>(static_cast<const UChar*>(data), size / sizeof(UChar));
+        return computeHashAndMaskTop8Bits<UChar>(static_cast<const UChar*>(data), size / sizeof(UChar));
     }
 
 private:
@@ -173,6 +220,27 @@
         m_hash += m_hash >> 11;
     }
 
+    inline unsigned avalancheBits() const
+    {
+        unsigned result = m_hash;
+
+        // Handle end case.
+        if (m_hasPendingCharacter) {
+            result += m_pendingCharacter;
+            result ^= result << 11;
+            result += result >> 17;
+        }
+
+        // Force "avalanching" of final 31 bits.
+        result ^= result << 3;
+        result += result >> 5;
+        result ^= result << 2;
+        result += result >> 15;
+        result ^= result << 10;
+
+        return result;
+    }
+
     unsigned m_hash;
     bool m_hasPendingCharacter;
     UChar m_pendingCharacter;

Modified: branches/safari-536.26-branch/Source/WTF/wtf/text/AtomicString.cpp (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/wtf/text/AtomicString.cpp	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/wtf/text/AtomicString.cpp	2012-08-14 23:25:58 UTC (rev 125620)
@@ -88,7 +88,7 @@
 struct CStringTranslator {
     static unsigned hash(const LChar* c)
     {
-        return StringHasher::computeHash(c);
+        return StringHasher::computeHashAndMaskTop8Bits(c);
     }
 
     static inline bool equal(StringImpl* r, const LChar* s)
@@ -122,7 +122,7 @@
 struct UCharBufferTranslator {
     static unsigned hash(const UCharBuffer& buf)
     {
-        return StringHasher::computeHash(buf.s, buf.length);
+        return StringHasher::computeHashAndMaskTop8Bits(buf.s, buf.length);
     }
 
     static bool equal(StringImpl* const& str, const UCharBuffer& buf)
@@ -147,7 +147,7 @@
 struct HashAndCharactersTranslator {
     static unsigned hash(const HashAndCharacters& buffer)
     {
-        ASSERT(buffer.hash == StringHasher::computeHash(buffer.characters, buffer.length));
+        ASSERT(buffer.hash == StringHasher::computeHashAndMaskTop8Bits(buffer.characters, buffer.length));
         return buffer.hash;
     }
 
@@ -260,7 +260,7 @@
 struct SubstringTranslator {
     static unsigned hash(const SubstringLocation& buffer)
     {
-        return StringHasher::computeHash(buffer.baseString->characters() + buffer.start, buffer.length);
+        return StringHasher::computeHashAndMaskTop8Bits(buffer.baseString->characters() + buffer.start, buffer.length);
     }
 
     static bool equal(StringImpl* const& string, const SubstringLocation& buffer)
@@ -342,7 +342,7 @@
 {
     HashAndUTF8Characters buffer;
     buffer.characters = charactersStart;
-    buffer.hash = calculateStringHashAndLengthFromUTF8(charactersStart, charactersEnd, buffer.length, buffer.utf16Length);
+    buffer.hash = calculateStringHashAndLengthFromUTF8MaskingTop8Bits(charactersStart, charactersEnd, buffer.length, buffer.utf16Length);
 
     if (!buffer.hash)
         return nullAtom;

Modified: branches/safari-536.26-branch/Source/WTF/wtf/text/StringHash.h (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/wtf/text/StringHash.h	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/wtf/text/StringHash.h	2012-08-14 23:25:58 UTC (rev 125620)
@@ -97,7 +97,7 @@
 
         static unsigned hash(const UChar* data, unsigned length)
         {
-            return StringHasher::computeHash<UChar, foldCase<UChar> >(data, length);
+            return StringHasher::computeHashAndMaskTop8Bits<UChar, foldCase<UChar> >(data, length);
         }
 
         static unsigned hash(StringImpl* str)
@@ -109,7 +109,7 @@
 
         static unsigned hash(const LChar* data, unsigned length)
         {
-            return StringHasher::computeHash<LChar, foldCase<LChar> >(data, length);
+            return StringHasher::computeHashAndMaskTop8Bits<LChar, foldCase<LChar> >(data, length);
         }
 
         static inline unsigned hash(const char* data, unsigned length)

Modified: branches/safari-536.26-branch/Source/WTF/wtf/text/StringImpl.h (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/wtf/text/StringImpl.h	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/wtf/text/StringImpl.h	2012-08-14 23:25:58 UTC (rev 125620)
@@ -345,7 +345,7 @@
     {
         ASSERT(!hasHash());
         // Multiple clients assume that StringHasher is the canonical string hash function.
-        ASSERT(hash == (is8Bit() ? StringHasher::computeHash(m_data8, m_length) : StringHasher::computeHash(m_data16, m_length)));
+        ASSERT(hash == (is8Bit() ? StringHasher::computeHashAndMaskTop8Bits(m_data8, m_length) : StringHasher::computeHashAndMaskTop8Bits(m_data16, m_length)));
         ASSERT(!(hash & (s_flagMask << (8 * sizeof(hash) - s_flagCount)))); // Verify that enough high bits are empty.
         
         hash <<= s_flagCount;

Modified: branches/safari-536.26-branch/Source/WTF/wtf/text/StringStatics.cpp (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/wtf/text/StringStatics.cpp	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/wtf/text/StringStatics.cpp	2012-08-14 23:25:58 UTC (rev 125620)
@@ -63,9 +63,9 @@
 NEVER_INLINE unsigned StringImpl::hashSlowCase() const
 {
     if (is8Bit())
-        setHash(StringHasher::computeHash(m_data8, m_length));
+        setHash(StringHasher::computeHashAndMaskTop8Bits(m_data8, m_length));
     else
-        setHash(StringHasher::computeHash(m_data16, m_length));
+        setHash(StringHasher::computeHashAndMaskTop8Bits(m_data16, m_length));
     return existingHash();
 }
 

Modified: branches/safari-536.26-branch/Source/WTF/wtf/unicode/UTF8.cpp (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/wtf/unicode/UTF8.cpp	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/wtf/unicode/UTF8.cpp	2012-08-14 23:25:58 UTC (rev 125620)
@@ -356,7 +356,7 @@
     return result;
 }
 
-unsigned calculateStringHashAndLengthFromUTF8(const char* data, const char* dataEnd, unsigned& dataLength, unsigned& utf16Length)
+unsigned calculateStringHashAndLengthFromUTF8MaskingTop8Bits(const char* data, const char* dataEnd, unsigned& dataLength, unsigned& utf16Length)
 {
     if (!data)
         return 0;
@@ -404,7 +404,7 @@
             return 0;
     }
 
-    return stringHasher.hash();
+    return stringHasher.hashWithTop8BitsMasked();
 }
 
 bool equalUTF16WithUTF8(const UChar* a, const UChar* aEnd, const char* b, const char* bEnd)

Modified: branches/safari-536.26-branch/Source/WTF/wtf/unicode/UTF8.h (125619 => 125620)


--- branches/safari-536.26-branch/Source/WTF/wtf/unicode/UTF8.h	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WTF/wtf/unicode/UTF8.h	2012-08-14 23:25:58 UTC (rev 125620)
@@ -74,7 +74,7 @@
                     const UChar** sourceStart, const UChar* sourceEnd, 
                     char** targetStart, char* targetEnd, bool strict = true);
 
-    unsigned calculateStringHashAndLengthFromUTF8(const char* data, const char* dataEnd, unsigned& dataLength, unsigned& utf16Length);
+    unsigned calculateStringHashAndLengthFromUTF8MaskingTop8Bits(const char* data, const char* dataEnd, unsigned& dataLength, unsigned& utf16Length);
 
     bool equalUTF16WithUTF8(const UChar* a, const UChar* aEnd, const char* b, const char* bEnd);
 

Modified: branches/safari-536.26-branch/Source/WebCore/ChangeLog (125619 => 125620)


--- branches/safari-536.26-branch/Source/WebCore/ChangeLog	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WebCore/ChangeLog	2012-08-14 23:25:58 UTC (rev 125620)
@@ -1,3 +1,22 @@
+2012-08-14  Lucas Forschler  <[email protected]>
+
+    Merge r124268.
+
+    2012-07-31  Sam Weinig  <[email protected]>
+
+            Stop masking 8 bits off of the visited link hash. We need all the bits!
+            https://bugs.webkit.org/show_bug.cgi?id=92799
+
+            Reviewed by Anders Carlsson.
+
+            * loader/appcache/ApplicationCacheStorage.cpp:
+            (WebCore::urlHostHash):
+            * platform/network/blackberry/CredentialBackingStore.cpp:
+            (WebCore::hashCredentialInfo):
+            * plugins/blackberry/PluginPackageBlackBerry.cpp:
+            (WebCore::PluginPackage::hash):
+            Update for new function names.
+
 2012-08-13  Andy Estes  <[email protected]>
 
         <rdar://problem/12050793> Brahms: REGRESSION (r113584): Apple reseller website does not display correctly. (91452)
@@ -205221,3 +205240,4 @@
 .
 .
 .
+.

Modified: branches/safari-536.26-branch/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp (125619 => 125620)


--- branches/safari-536.26-branch/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2012-08-14 23:25:58 UTC (rev 125620)
@@ -92,7 +92,7 @@
     unsigned hostStart = url.hostStart();
     unsigned hostEnd = url.hostEnd();
     
-    return AlreadyHashed::avoidDeletedValue(StringHasher::computeHash(url.string().characters() + hostStart, hostEnd - hostStart));
+    return AlreadyHashed::avoidDeletedValue(StringHasher::computeHashAndMaskTop8Bits(url.string().characters() + hostStart, hostEnd - hostStart));
 }
 
 ApplicationCacheGroup* ApplicationCacheStorage::loadCacheGroup(const KURL& manifestURL)

Modified: branches/safari-536.26-branch/Source/WebCore/plugins/blackberry/PluginPackageBlackBerry.cpp (125619 => 125620)


--- branches/safari-536.26-branch/Source/WebCore/plugins/blackberry/PluginPackageBlackBerry.cpp	2012-08-14 23:21:57 UTC (rev 125619)
+++ branches/safari-536.26-branch/Source/WebCore/plugins/blackberry/PluginPackageBlackBerry.cpp	2012-08-14 23:25:58 UTC (rev 125620)
@@ -196,7 +196,7 @@
         m_path.impl()->hash()
     };
 
-    return StringHasher::computeHash(reinterpret_cast<const UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
+    return StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<const UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
 }
 
 bool PluginPackage::load()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to