Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JSC] Introduce wyhash to StringImpl
https://bugs.webkit.org/show_bug.cgi?id=260147 rdar://113860312 Reviewed by Yusuke Suzuki. StringImpl::hashSlowCase() is one of the hottest functions when running JetStream2. However, the existing hash function is slow for large string since it's based on incremental hashing of each character. This patch introduces wyhash[1] (hashing data in bulks) to StringImpl with OSS approval (ID OSS-16203), since wyhash provides the best hash score without quality issues according to SMhasher[2]. In this patch: 1. Rename previous StringHasher.h to SuperFastHash.h. 2. Use SuperFastHash for small strings and wyhash for large strings in order to gain best performances on JetStream2. [1] https://github.com/wangyi-fudan/wyhash [2] https://github.com/rurban/smhasher * Source/JavaScriptCore/create_hash_table: * Source/JavaScriptCore/runtime/JSCBytecodeCacheVersion.cpp.in: * Source/JavaScriptCore/runtime/JSCell.cpp: (JSC::reportZappedCellAndCrash): * Source/JavaScriptCore/runtime/TemplateObjectDescriptor.h: (JSC::TemplateObjectDescriptor::calculateHash): * Source/JavaScriptCore/tools/JSDollarVM.cpp: * Source/JavaScriptCore/tools/VMInspector.cpp: (JSC::VMInspector::dumpSubspaceHashes): * Source/JavaScriptCore/yarr/hasher.py: (stringHash): (finalizeAndMaskTop8Bits): (superFastHash): (wyhash): (wyhash.add64): (wyhash.multi64): (wyhash.wymum): (wyhash.wymix): (wyhash.convert32BitTo64Bit): (wyhash.convert16BitTo32Bit): (wyhash.c2i): (wyhash.wyr8): (wyhash.wyr4): (wyhash.wyr2): (ceilingToPowerOf2): (createHashTable): * Source/WTF/WTF.xcodeproj/project.pbxproj: * Source/WTF/wtf/CMakeLists.txt: * Source/WTF/wtf/Hasher.h: * Source/WTF/wtf/text/CString.cpp: (WTF::CString::hash const): * Source/WTF/wtf/text/StringHash.h: (WTF::ASCIICaseInsensitiveHash::hash): * Source/WTF/wtf/text/StringHasher.h: (WTF::StringHasher::StringHasher): (WTF::StringHasher::finalize): (WTF::StringHasher::finalizeAndMaskTop8Bits): (WTF::StringHasher::addCharactersAssumingAligned): Deleted. (WTF::StringHasher::addCharacter): Deleted. (WTF::StringHasher::addCharacters): Deleted. (WTF::StringHasher::hashWithTop8BitsMasked const): Deleted. (WTF::StringHasher::hash const): Deleted. (WTF::StringHasher::computeHashAndMaskTop8Bits): Deleted. (WTF::StringHasher::computeHash): Deleted. (WTF::StringHasher::computeLiteralHash): Deleted. (WTF::StringHasher::computeLiteralHashAndMaskTop8Bits): Deleted. (WTF::StringHasher::calculateWithRemainingLastCharacter): Deleted. (WTF::StringHasher::calculateWithTwoCharacters): Deleted. (WTF::StringHasher::computeHashImpl): Deleted. (WTF::StringHasher::processPendingCharacter const): Deleted. * Source/WTF/wtf/text/StringHasherInlines.h: Added. (WTF::StringHasher::computeHashAndMaskTop8Bits): (WTF::StringHasher::computeLiteralHashAndMaskTop8Bits): (WTF::StringHasher::addCharacter): (WTF::StringHasher::hashWithTop8BitsMasked): * Source/WTF/wtf/text/StringImpl.h: * Source/WTF/wtf/text/SuperFastHash.h: Copied from Source/WTF/wtf/text/StringHasher.h. (WTF::SuperFastHash::addCharactersAssumingAligned): (WTF::SuperFastHash::addCharacter): (WTF::SuperFastHash::addCharacters): (WTF::SuperFastHash::hashWithTop8BitsMasked const): (WTF::SuperFastHash::hash const): (WTF::SuperFastHash::computeHashAndMaskTop8Bits): (WTF::SuperFastHash::computeHash): (WTF::SuperFastHash::computeLiteralHash): (WTF::SuperFastHash::computeLiteralHashAndMaskTop8Bits): (WTF::SuperFastHash::calculateWithRemainingLastCharacter): (WTF::SuperFastHash::calculateWithTwoCharacters): (WTF::SuperFastHash::computeHashImpl): (WTF::SuperFastHash::processPendingCharacter const): * Source/WTF/wtf/text/WYHash.h: Added. (WTF::WYHash::computeHashAndMaskTop8Bits): (WTF::WYHash::wyrot): (WTF::WYHash::wymum): (WTF::WYHash::wymix): (WTF::WYHash::Reader16Bit::hasDefaultConverter): (WTF::WYHash::Reader16Bit::convert): (WTF::WYHash::Reader16Bit::wyr3): (WTF::WYHash::Reader16Bit::wyr4WithConvert): (WTF::WYHash::Reader16Bit::wyr4): (WTF::WYHash::Reader16Bit::wyr8WithConvert): (WTF::WYHash::Reader16Bit::wyr8): (WTF::WYHash::Reader8Bit::hasDefaultConverter): (WTF::WYHash::Reader8Bit::convert): (WTF::WYHash::Reader8Bit::wyr3): (WTF::WYHash::Reader8Bit::wyr4WithConvert): (WTF::WYHash::Reader8Bit::wyr4): (WTF::WYHash::Reader8Bit::wyr8WithConvert): (WTF::WYHash::Reader8Bit::wyr8): (WTF::WYHash::initSeed): (WTF::WYHash::consume24Characters): (WTF::WYHash::handleEndCase): (WTF::WYHash::handleGreaterThan8CharactersCase): (WTF::WYHash::hash): (WTF::WYHash::computeHashImpl): * Source/WTF/wtf/unicode/UTF8Conversion.cpp: (WTF::Unicode::calculateStringHashAndLengthFromUTF8MaskingTop8Bits): * Source/WebCore/bindings/scripts/Hasher.pm: (finalizeAndMaskTop8Bits): (superFastHash): (uint64_add): (uint64_multi): (GenerateHashValue): Deleted. * Source/WebCore/contentextensions/DFAMinimizer.cpp: * Source/WebCore/contentextensions/HashableActionList.h: (WebCore::ContentExtensions::HashableActionList::HashableActionList): * Source/WebCore/platform/SharedStringHash.cpp: (WebCore::computeSharedStringHashInline): * Source/WebCore/platform/graphics/WidthCache.h: (WebCore::WidthCache::SmallStringKey::SmallStringKey): * Tools/TestWebKitAPI/CMakeLists.txt: * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WTF/StringHasher.cpp: (TestWebKitAPI::TEST): * Tools/TestWebKitAPI/Tests/WTF/SuperFastHash.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/StringHasher.cpp. (TestWebKitAPI::TEST): * Tools/TestWebKitAPI/Tests/WTF/WYHash.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/266929@main
- Loading branch information