[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
barraclough at apple.com
barraclough at apple.com
Thu Apr 8 00:54:07 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit 8423ddaeb90daf819cc8d40bd58728aaff973530
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 5 01:24:48 2010 +0000
JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=33163
Add string hashing functions to WTF.
Use WTF's string hashing functions from UStringImpl.
Reviewed by Sam Weinig, additional coding by Mark Rowe.
* GNUmakefile.am:
* JavaScriptCore.exp:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/UStringImpl.cpp:
* runtime/UStringImpl.h:
(JSC::UStringImpl::computeHash):
* wtf/HashFunctions.h:
* wtf/StringHashFunctions.h: Added.
(WTF::stringHash):
JavaScriptGlue: Add a forwarding header so that StringHashFunctions.h can be found.
Reviewed by Sam Weinig.
* ForwardingHeaders/wtf/StringHashFunctions.h: Added.
WebCore: https://bugs.webkit.org/show_bug.cgi?id=33163
Use WTF's string hashing functions from StringImpl.
Patch by Mark Rowe <mrowe at apple.com> on 2010-01-04
Reviewed by Sam Weinig.
* ForwardingHeaders/wtf/StringHashFunctions.h: Added.
* platform/text/StringHash.h:
* platform/text/StringImpl.h:
(WebCore::StringImpl::computeHash):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52776 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 5917038..9b8147e 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-01-04 Gavin Barraclough <barraclough at apple.com>
+
+ Reviewed by Sam Weinig, additional coding by Mark Rowe.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33163
+ Add string hashing functions to WTF.
+ Use WTF's string hashing functions from UStringImpl.
+
+ * GNUmakefile.am:
+ * JavaScriptCore.exp:
+ * JavaScriptCore.gypi:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * runtime/UStringImpl.cpp:
+ * runtime/UStringImpl.h:
+ (JSC::UStringImpl::computeHash):
+ * wtf/HashFunctions.h:
+ * wtf/StringHashFunctions.h: Added.
+ (WTF::stringHash):
+
2010-01-04 Dmitry Titov <dimich at chromium.org>
Not reviewed, attempt to fix ARM bulid.
diff --git a/JavaScriptCore/GNUmakefile.am b/JavaScriptCore/GNUmakefile.am
index e34e6c1..55a2d99 100644
--- a/JavaScriptCore/GNUmakefile.am
+++ b/JavaScriptCore/GNUmakefile.am
@@ -227,7 +227,6 @@ javascriptcore_sources += \
JavaScriptCore/wtf/ByteArray.cpp \
JavaScriptCore/wtf/ByteArray.h \
JavaScriptCore/wtf/CrossThreadRefCounted.h \
- JavaScriptCore/wtf/OwnFastMallocPtr.h \
JavaScriptCore/wtf/CurrentTime.cpp \
JavaScriptCore/wtf/CurrentTime.h \
JavaScriptCore/wtf/DateMath.cpp \
@@ -254,6 +253,7 @@ javascriptcore_sources += \
JavaScriptCore/wtf/Noncopyable.h \
JavaScriptCore/wtf/NotFound.h \
JavaScriptCore/wtf/OwnArrayPtr.h \
+ JavaScriptCore/wtf/OwnFastMallocPtr.h \
JavaScriptCore/wtf/OwnPtr.h \
JavaScriptCore/wtf/OwnPtrCommon.h \
JavaScriptCore/wtf/PassOwnPtr.h \
@@ -273,12 +273,13 @@ javascriptcore_sources += \
JavaScriptCore/wtf/SegmentedVector.h \
JavaScriptCore/wtf/StdLibExtras.h \
JavaScriptCore/wtf/StringExtras.h \
+ JavaScriptCore/wtf/StringHashFunctions.h \
JavaScriptCore/wtf/TCPackedCache.h \
JavaScriptCore/wtf/TCPageMap.h \
JavaScriptCore/wtf/TCSpinLock.h \
JavaScriptCore/wtf/ThreadSpecific.h \
- JavaScriptCore/wtf/Threading.h \
JavaScriptCore/wtf/Threading.cpp \
+ JavaScriptCore/wtf/Threading.h \
JavaScriptCore/wtf/ThreadingPthreads.cpp \
JavaScriptCore/wtf/TypeTraits.cpp \
JavaScriptCore/wtf/TypeTraits.h \
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 30b174c..4a87e4e 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -103,8 +103,6 @@ __ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE
__ZN3JSC11JSByteArray15createStructureENS_7JSValueE
__ZN3JSC11JSByteArrayC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEPNS3_9ByteArrayEPKNS_9ClassInfoE
__ZN3JSC11ParserArena5resetEv
-__ZN3JSC11UStringImpl11computeHashEPKci
-__ZN3JSC11UStringImpl11computeHashEPKti
__ZN3JSC11UStringImpl12sharedBufferEv
__ZN3JSC11UStringImpl6s_nullE
__ZN3JSC11UStringImpl7destroyEv
diff --git a/JavaScriptCore/JavaScriptCore.gypi b/JavaScriptCore/JavaScriptCore.gypi
index 8ed1e3a..c31cfce 100644
--- a/JavaScriptCore/JavaScriptCore.gypi
+++ b/JavaScriptCore/JavaScriptCore.gypi
@@ -398,8 +398,6 @@
'wtf/PassRefPtr.h',
'wtf/Platform.h',
'wtf/PtrAndFlags.h',
- 'wtf/qt/MainThreadQt.cpp',
- 'wtf/qt/ThreadingQt.cpp',
'wtf/RandomNumber.cpp',
'wtf/RandomNumber.h',
'wtf/RandomNumberSeed.h',
@@ -412,7 +410,10 @@
'wtf/SegmentedVector.h',
'wtf/StdLibExtras.h',
'wtf/StringExtras.h',
+ 'wtf/StringHashFunctions.h',
'wtf/TCPackedCache.h',
+ 'wtf/qt/MainThreadQt.cpp',
+ 'wtf/qt/ThreadingQt.cpp',
'wtf/TCPageMap.h',
'wtf/TCSpinLock.h',
'wtf/TCSystemAlloc.cpp',
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index e692c60..eee2c5d 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -61,7 +61,6 @@ EXPORTS
?collate at Collator@WTF@@QBE?AW4Result at 12@PB_WI0I at Z
?collectAllGarbage at Heap@JSC@@QAEXXZ
?computeHash at UStringImpl@JSC@@SAIPB_WH at Z
- ?computeHash at UStringImpl@JSC@@SAIPBDH at Z
?configurable at PropertyDescriptor@JSC@@QBE_NXZ
?construct at JSC@@YAPAVJSObject at 1@PAVExecState at 1@VJSValue at 1@W4ConstructType at 1@ABTConstructData at 1@ABVArgList at 1@@Z
?constructArray at JSC@@YAPAVJSArray at 1@PAVExecState at 1@ABVArgList at 1@@Z
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 0f1d3e9..a114866 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -187,6 +187,7 @@
5D53726F0E1C54880021E549 /* Tracing.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D53726E0E1C54880021E549 /* Tracing.h */; };
5D5D8AB60E0D0A7200F9C692 /* jsc in Copy Into Framework */ = {isa = PBXBuildFile; fileRef = 932F5BE10822A1C700736975 /* jsc */; };
5D5D8AD10E0D0EBE00F9C692 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */; };
+ 5D63E9AD10F2BD6E00FC8AE9 /* StringHashFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D63E9AC10F2BD6E00FC8AE9 /* StringHashFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
5D6A566B0F05995500266145 /* Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D6A566A0F05995500266145 /* Threading.cpp */; };
5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */ = {isa = PBXBuildFile; fileRef = F692A8540255597D01FF60F7 /* create_hash_table */; settings = {ATTRIBUTES = (); }; };
6507D29E0E871E5E00D7D896 /* JSTypeInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6507D2970E871E4A00D7D896 /* JSTypeInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -675,6 +676,7 @@
5D53726E0E1C54880021E549 /* Tracing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tracing.h; sourceTree = "<group>"; };
5D53727D0E1C55EC0021E549 /* TracingDtrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TracingDtrace.h; sourceTree = "<group>"; };
5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libedit.dylib; path = /usr/lib/libedit.dylib; sourceTree = "<absolute>"; };
+ 5D63E9AC10F2BD6E00FC8AE9 /* StringHashFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringHashFunctions.h; sourceTree = "<group>"; };
5D6A566A0F05995500266145 /* Threading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Threading.cpp; sourceTree = "<group>"; };
5DA479650CFBCF56009328A0 /* TCPackedCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCPackedCache.h; sourceTree = "<group>"; };
5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MallocZoneSupport.h; sourceTree = "<group>"; };
@@ -1363,6 +1365,7 @@
969A07290ED1CE6900F1F681 /* SegmentedVector.h */,
FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */,
E11D51750B2E798D0056C188 /* StringExtras.h */,
+ 5D63E9AC10F2BD6E00FC8AE9 /* StringHashFunctions.h */,
5DA479650CFBCF56009328A0 /* TCPackedCache.h */,
6541BD6E08E80A17002CBEE7 /* TCPageMap.h */,
6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */,
@@ -2039,6 +2042,7 @@
8698BB3910D86BAF00D8D01B /* UStringImpl.h in Headers */,
14035DB110DBFB2A00FFFFE7 /* WeakGCPtr.h in Headers */,
865F408810E7D56300947361 /* APIShims.h in Headers */,
+ 5D63E9AD10F2BD6E00FC8AE9 /* StringHashFunctions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/JavaScriptCore/runtime/UStringImpl.cpp b/JavaScriptCore/runtime/UStringImpl.cpp
index fa9abe6..4288624 100644
--- a/JavaScriptCore/runtime/UStringImpl.cpp
+++ b/JavaScriptCore/runtime/UStringImpl.cpp
@@ -81,97 +81,4 @@ void UStringImpl::destroy()
delete this;
}
-// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
-// or anything like that.
-const unsigned PHI = 0x9e3779b9U;
-
-// Paul Hsieh's SuperFastHash
-// http://www.azillionmonkeys.com/qed/hash.html
-unsigned UStringImpl::computeHash(const UChar* s, int len)
-{
- unsigned l = len;
- uint32_t hash = PHI;
- uint32_t tmp;
-
- int rem = l & 1;
- l >>= 1;
-
- // Main loop
- for (; l > 0; l--) {
- hash += s[0];
- tmp = (s[1] << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- s += 2;
- hash += hash >> 11;
- }
-
- // Handle end case
- if (rem) {
- hash += s[0];
- hash ^= hash << 11;
- hash += hash >> 17;
- }
-
- // Force "avalanching" of final 127 bits
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // this avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked
- if (hash == 0)
- hash = 0x80000000;
-
- return hash;
-}
-
-// Paul Hsieh's SuperFastHash
-// http://www.azillionmonkeys.com/qed/hash.html
-unsigned UStringImpl::computeHash(const char* s, int l)
-{
- // This hash is designed to work on 16-bit chunks at a time. But since the normal case
- // (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they
- // were 16-bit chunks, which should give matching results
-
- uint32_t hash = PHI;
- uint32_t tmp;
-
- size_t rem = l & 1;
- l >>= 1;
-
- // Main loop
- for (; l > 0; l--) {
- hash += static_cast<unsigned char>(s[0]);
- tmp = (static_cast<unsigned char>(s[1]) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- s += 2;
- hash += hash >> 11;
- }
-
- // Handle end case
- if (rem) {
- hash += static_cast<unsigned char>(s[0]);
- hash ^= hash << 11;
- hash += hash >> 17;
- }
-
- // Force "avalanching" of final 127 bits
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // this avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked
- if (hash == 0)
- hash = 0x80000000;
-
- return hash;
-}
-
}
diff --git a/JavaScriptCore/runtime/UStringImpl.h b/JavaScriptCore/runtime/UStringImpl.h
index e6c91a0..d19ff4c 100644
--- a/JavaScriptCore/runtime/UStringImpl.h
+++ b/JavaScriptCore/runtime/UStringImpl.h
@@ -26,11 +26,12 @@
#ifndef UStringImpl_h
#define UStringImpl_h
+#include <limits>
#include <wtf/CrossThreadRefCounted.h>
#include <wtf/OwnFastMallocPtr.h>
#include <wtf/PossiblyNull.h>
+#include <wtf/StringHashFunctions.h>
#include <wtf/unicode/Unicode.h>
-#include <limits>
namespace JSC {
@@ -160,9 +161,9 @@ public:
memcpy(destination, source, numCharacters * sizeof(UChar));
}
- static unsigned computeHash(const UChar*, int length);
- static unsigned computeHash(const char*, int length);
- static unsigned computeHash(const char* s) { return computeHash(s, strlen(s)); }
+ static unsigned computeHash(const UChar* s, int length) { ASSERT(length >= 0); return WTF::stringHash(s, length); }
+ static unsigned computeHash(const char* s, int length) { ASSERT(length >= 0); return WTF::stringHash(s, length); }
+ static unsigned computeHash(const char* s) { return WTF::stringHash(s); }
static UStringImpl& null() { return *s_null; }
static UStringImpl& empty() { return *s_empty; }
diff --git a/JavaScriptCore/wtf/HashFunctions.h b/JavaScriptCore/wtf/HashFunctions.h
index 13afb72..2c66a2d 100644
--- a/JavaScriptCore/wtf/HashFunctions.h
+++ b/JavaScriptCore/wtf/HashFunctions.h
@@ -173,9 +173,6 @@ namespace WTF {
template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr<P> > Hash; };
template<typename T, typename U> struct DefaultHash<std::pair<T, U> > { typedef PairHash<T, U> Hash; };
-
- // Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
- static const unsigned stringHashingStartValue = 0x9e3779b9U;
} // namespace WTF
diff --git a/JavaScriptCore/wtf/StringHashFunctions.h b/JavaScriptCore/wtf/StringHashFunctions.h
new file mode 100644
index 0000000..703182c
--- /dev/null
+++ b/JavaScriptCore/wtf/StringHashFunctions.h
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef WTF_StringHashFunctions_h
+#define WTF_StringHashFunctions_h
+
+#include <wtf/unicode/Unicode.h>
+
+namespace WTF {
+
+// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
+static const unsigned stringHashingStartValue = 0x9e3779b9U;
+
+// stringHash methods based on Paul Hsieh's SuperFastHash.
+// http://www.azillionmonkeys.com/qed/hash.html
+// char* data is interpreted as latin-encoded (zero extended to 16 bits).
+
+inline unsigned stringHash(const UChar* data, unsigned length)
+{
+ unsigned hash = WTF::stringHashingStartValue;
+ unsigned rem = length & 1;
+ length >>= 1;
+
+ // Main loop
+ for (; length > 0; length--) {
+ hash += data[0];
+ unsigned tmp = (data[1] << 11) ^ hash;
+ hash = (hash << 16) ^ tmp;
+ data += 2;
+ hash += hash >> 11;
+ }
+
+ // Handle end case
+ if (rem) {
+ hash += data[0];
+ hash ^= hash << 11;
+ hash += hash >> 17;
+ }
+
+ // Force "avalanching" of final 127 bits
+ hash ^= hash << 3;
+ hash += hash >> 5;
+ hash ^= hash << 2;
+ hash += hash >> 15;
+ hash ^= hash << 10;
+
+ // this avoids ever returning a hash code of 0, since that is used to
+ // signal "hash not computed yet", using a value that is likely to be
+ // effectively the same as 0 when the low bits are masked
+ if (hash == 0)
+ hash = 0x80000000;
+
+ return hash;
+}
+
+inline unsigned stringHash(const char* data, unsigned length)
+{
+ unsigned hash = WTF::stringHashingStartValue;
+ unsigned rem = length & 1;
+ length >>= 1;
+
+ // Main loop
+ for (; length > 0; length--) {
+ hash += static_cast<unsigned char>(data[0]);
+ unsigned tmp = (static_cast<unsigned char>(data[1]) << 11) ^ hash;
+ hash = (hash << 16) ^ tmp;
+ data += 2;
+ hash += hash >> 11;
+ }
+
+ // Handle end case
+ if (rem) {
+ hash += static_cast<unsigned char>(data[0]);
+ hash ^= hash << 11;
+ hash += hash >> 17;
+ }
+
+ // Force "avalanching" of final 127 bits
+ hash ^= hash << 3;
+ hash += hash >> 5;
+ hash ^= hash << 2;
+ hash += hash >> 15;
+ hash ^= hash << 10;
+
+ // this avoids ever returning a hash code of 0, since that is used to
+ // signal "hash not computed yet", using a value that is likely to be
+ // effectively the same as 0 when the low bits are masked
+ if (hash == 0)
+ hash = 0x80000000;
+
+ return hash;
+}
+
+inline unsigned stringHash(const char* data)
+{
+ unsigned hash = WTF::stringHashingStartValue;
+
+ // Main loop
+ for (;;) {
+ unsigned char b0 = data[0];
+ if (!b0)
+ break;
+ unsigned char b1 = data[1];
+ if (!b1) {
+ hash += b0;
+ hash ^= hash << 11;
+ hash += hash >> 17;
+ break;
+ }
+ hash += b0;
+ unsigned tmp = (b1 << 11) ^ hash;
+ hash = (hash << 16) ^ tmp;
+ data += 2;
+ hash += hash >> 11;
+ }
+
+ // Force "avalanching" of final 127 bits.
+ hash ^= hash << 3;
+ hash += hash >> 5;
+ hash ^= hash << 2;
+ hash += hash >> 15;
+ hash ^= hash << 10;
+
+ // This avoids ever returning a hash code of 0, since that is used to
+ // signal "hash not computed yet", using a value that is likely to be
+ // effectively the same as 0 when the low bits are masked.
+ if (hash == 0)
+ hash = 0x80000000;
+
+ return hash;
+}
+
+} // namespace WTF
+
+#endif // WTF_StringHashFunctions_h
diff --git a/JavaScriptGlue/ChangeLog b/JavaScriptGlue/ChangeLog
index ab24d98..c1366a1 100644
--- a/JavaScriptGlue/ChangeLog
+++ b/JavaScriptGlue/ChangeLog
@@ -1,3 +1,11 @@
+2010-01-04 Gavin Barraclough <barraclough at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Add a forwarding header so that StringHashFunctions.h can be found.
+
+ * ForwardingHeaders/wtf/StringHashFunctions.h: Added.
+
2010-01-04 Dan Bernstein <mitz at apple.com>
Reviewed by Ada Chan and Mark Rowe.
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/StringHashFunctions.h b/JavaScriptGlue/ForwardingHeaders/wtf/StringHashFunctions.h
new file mode 100644
index 0000000..e903ddd
--- /dev/null
+++ b/JavaScriptGlue/ForwardingHeaders/wtf/StringHashFunctions.h
@@ -0,0 +1 @@
+#include <JavaScriptCore/StringHashFunctions.h>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 07d9595..ad13ad7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-01-04 Mark Rowe <mrowe at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33163
+ Use WTF's string hashing functions from StringImpl.
+
+ * ForwardingHeaders/wtf/StringHashFunctions.h: Added.
+ * platform/text/StringHash.h:
+ * platform/text/StringImpl.h:
+ (WebCore::StringImpl::computeHash):
+
+<<<<<<< .mine
+2010-01-04 Gavin Barraclough <barraclough at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33163
+ Use WTF's string hashing functions from StringImpl.
+
+ * ForwardingHeaders/wtf/StringHashFunctions.h: Added.
+ * platform/text/StringHash.h:
+ * platform/text/StringImpl.h:
+ (WebCore::StringImpl::computeHash):
+
+=======
2010-01-04 Jon Honeycutt <jhoneycutt at apple.com>
MSAA: <select> elements should broadcast value change events
@@ -61,6 +87,7 @@
* WebCore.vcproj/WebCore.vcproj:
* inspector/front-end/InspectorControllerStub.js: Removed.
+>>>>>>> .r52775
2010-01-04 Kevin Ollivier <kevino at theolliviers.com>
[wx] Build fix, add a couple include dirs to the build.
diff --git a/WebCore/ForwardingHeaders/wtf/StringHashFunctions.h b/WebCore/ForwardingHeaders/wtf/StringHashFunctions.h
new file mode 100644
index 0000000..72c1194
--- /dev/null
+++ b/WebCore/ForwardingHeaders/wtf/StringHashFunctions.h
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_StringHashFunctions_h
+#define WebCore_FWD_StringHashFunctions_h
+#include <JavaScriptCore/StringHashFunctions.h>
+#endif
diff --git a/WebCore/platform/text/StringHash.h b/WebCore/platform/text/StringHash.h
index 6e5cd9e..e6c548a 100644
--- a/WebCore/platform/text/StringHash.h
+++ b/WebCore/platform/text/StringHash.h
@@ -24,8 +24,8 @@
#include "AtomicString.h"
#include "PlatformString.h"
-#include <wtf/HashFunctions.h>
#include <wtf/HashTraits.h>
+#include <wtf/StringHashFunctions.h>
#include <wtf/unicode/Unicode.h>
namespace WebCore {
diff --git a/WebCore/platform/text/StringImpl.h b/WebCore/platform/text/StringImpl.h
index b454463..f7a9d06 100644
--- a/WebCore/platform/text/StringImpl.h
+++ b/WebCore/platform/text/StringImpl.h
@@ -29,6 +29,7 @@
#include <wtf/OwnFastMallocPtr.h>
#include <wtf/PtrAndFlags.h>
#include <wtf/RefCounted.h>
+#include <wtf/StringHashFunctions.h>
#include <wtf/Vector.h>
#include <wtf/unicode/Unicode.h>
@@ -102,8 +103,8 @@ public:
unsigned hash() { if (m_hash == 0) m_hash = computeHash(m_data, m_length); return m_hash; }
unsigned existingHash() const { ASSERT(m_hash); return m_hash; }
- static unsigned computeHash(const UChar*, unsigned len);
- static unsigned computeHash(const char*);
+ inline static unsigned computeHash(const UChar* data, unsigned length) { return WTF::stringHash(data, length); }
+ inline static unsigned computeHash(const char* data) { return WTF::stringHash(data); }
// Returns a StringImpl suitable for use on another thread.
PassRefPtr<StringImpl> crossThreadString();
@@ -213,91 +214,6 @@ inline bool equalIgnoringCase(const char* a, const UChar* b, unsigned length) {
bool equalIgnoringNullity(StringImpl*, StringImpl*);
-// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
-// or anything like that.
-const unsigned phi = 0x9e3779b9U;
-
-// Paul Hsieh's SuperFastHash
-// http://www.azillionmonkeys.com/qed/hash.html
-inline unsigned StringImpl::computeHash(const UChar* data, unsigned length)
-{
- unsigned hash = phi;
-
- // Main loop.
- for (unsigned pairCount = length >> 1; pairCount; pairCount--) {
- hash += data[0];
- unsigned tmp = (data[1] << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- data += 2;
- hash += hash >> 11;
- }
-
- // Handle end case.
- if (length & 1) {
- hash += data[0];
- hash ^= hash << 11;
- hash += hash >> 17;
- }
-
- // Force "avalanching" of final 127 bits.
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // This avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked.
- hash |= !hash << 31;
-
- return hash;
-}
-
-// Paul Hsieh's SuperFastHash
-// http://www.azillionmonkeys.com/qed/hash.html
-inline unsigned StringImpl::computeHash(const char* data)
-{
- // This hash is designed to work on 16-bit chunks at a time. But since the normal case
- // (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they
- // were 16-bit chunks, which should give matching results
-
- unsigned hash = phi;
-
- // Main loop
- for (;;) {
- unsigned char b0 = data[0];
- if (!b0)
- break;
- unsigned char b1 = data[1];
- if (!b1) {
- hash += b0;
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
- }
- hash += b0;
- unsigned tmp = (b1 << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- data += 2;
- hash += hash >> 11;
- }
-
- // Force "avalanching" of final 127 bits.
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // This avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked.
- hash |= !hash << 31;
-
- return hash;
-}
-
static inline bool isSpaceOrNewline(UChar c)
{
// Use isASCIISpace() for basic Latin-1.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list