Changeset 123582 in webkit
- Timestamp:
- Jul 25, 2012 12:22:48 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r123560 r123582 1 2012-07-24 Benjamin Poulain <bpoulain@apple.com> && Joseph Pecoraro <pecoraro@apple.com> 2 3 QualifiedName's HashSet should be big enough to hold at least all the static names 4 https://bugs.webkit.org/show_bug.cgi?id=91891 5 6 Reviewed by Darin Adler. 7 8 Add a static struct to compute the HashTable capacity for any given size at compile time. 9 This allow us to create HashTraits giving the minimumSize without hardcoding the values. 10 11 * wtf/HashTable.h: 12 (OneifyLowBits): 13 (UpperPowerOfTwoBound): 14 (HashTableCapacityForSize): Compute the HashTable capacity at compile time. 15 1 16 2012-07-24 Michael Saboff <msaboff@apple.com> 2 17 -
trunk/Source/WTF/wtf/HashTable.h
r123559 r123582 504 504 mutable OwnPtr<Stats> m_stats; 505 505 #endif 506 }; 507 508 // Set all the bits to one after the most significant bit: 00110101010 -> 00111111111. 509 template<unsigned size> struct OneifyLowBits; 510 template<> 511 struct OneifyLowBits<0> { 512 static const unsigned value = 0; 513 }; 514 template<unsigned number> 515 struct OneifyLowBits { 516 static const unsigned value = number | OneifyLowBits<(number >> 1)>::value; 517 }; 518 // Compute the first power of two integer that is an upper bound of the parameter 'number'. 519 template<unsigned number> 520 struct UpperPowerOfTwoBound { 521 static const unsigned value = (OneifyLowBits<number - 1>::value + 1) * 2; 522 }; 523 524 // Because power of two numbers are the limit of maxLoad, their capacity is twice the 525 // UpperPowerOfTwoBound, or 4 times their values. 526 template<unsigned size, bool isPowerOfTwo> struct HashTableCapacityForSizeSplitter; 527 template<unsigned size> 528 struct HashTableCapacityForSizeSplitter<size, true> { 529 static const unsigned value = size * 4; 530 }; 531 template<unsigned size> 532 struct HashTableCapacityForSizeSplitter<size, false> { 533 static const unsigned value = UpperPowerOfTwoBound<size>::value; 534 }; 535 536 // HashTableCapacityForSize computes the upper power of two capacity to hold the size parameter. 537 // This is done at compile time to initialize the HashTraits. 538 template<unsigned size> 539 struct HashTableCapacityForSize { 540 static const unsigned value = HashTableCapacityForSizeSplitter<size, !(size & (size - 1))>::value; 541 COMPILE_ASSERT(size > 0, HashTableNonZeroMinimumCapacity); 542 COMPILE_ASSERT(!static_cast<int>(value >> 31), HashTableNoCapacityOverflow); 543 COMPILE_ASSERT(value > (2 * size), HashTableCapacityHoldsContentSize); 506 544 }; 507 545 -
trunk/Source/WebCore/ChangeLog
r123581 r123582 1 2012-07-24 Benjamin Poulain <bpoulain@apple.com> && Joseph Pecoraro <pecoraro@apple.com> 2 3 QualifiedName's HashSet should be big enough to hold at least all the static names 4 https://bugs.webkit.org/show_bug.cgi?id=91891 5 6 Reviewed by Darin Adler. 7 8 QualifiedName's table has a standard size of 64 buckets. When initializing WebKit, 9 we create 850 static QualifiedName for the standard names (HTMLNames, SVGNames etc). 10 11 The small base size forces us to grow and rehash the table several time on startup. 12 13 This patch solves the issue by defining the initial table size to the minimum size that 14 can hold all the static QualifiedName. 15 16 * dom/QualifiedName.cpp: 17 (QualifiedNameHashTraits): 18 * dom/make_names.pl: 19 (printNamesHeaderFile): 20 1 21 2012-07-24 Kwang Yul Seo <skyul@company100.net> 2 22 -
trunk/Source/WebCore/dom/QualifiedName.cpp
r112555 r123582 27 27 28 28 #include "QualifiedName.h" 29 #include "HTMLNames.h" 30 #include "XLinkNames.h" 31 #include "XMLNSNames.h" 32 #include "XMLNames.h" 29 33 #include <wtf/Assertions.h> 30 34 #include <wtf/HashSet.h> 31 35 #include <wtf/StaticConstructors.h> 32 36 37 #if ENABLE(MATHML) 38 #include "MathMLNames.h" 39 #endif 40 41 #if ENABLE(SVG) 42 #include "SVGNames.h" 43 #endif 44 33 45 namespace WebCore { 34 46 35 typedef HashSet<QualifiedName::QualifiedNameImpl*, QualifiedNameHash> QNameSet; 47 static const int staticQualifiedNamesCount = HTMLNames::HTMLTagsCount + HTMLNames::HTMLAttrsCount 48 #if ENABLE(MATHML) 49 + MathMLNames::MathMLTagsCount + MathMLNames::MathMLAttrsCount 50 #endif 51 #if ENABLE(SVG) 52 + SVGNames::SVGTagsCount + SVGNames::SVGAttrsCount 53 #endif 54 + XLinkNames::XLinkAttrsCount 55 + XMLNSNames::XMLNSAttrsCount 56 + XMLNames::XMLAttrsCount; 57 58 struct QualifiedNameHashTraits : public HashTraits<QualifiedName::QualifiedNameImpl*> { 59 static const int minimumTableSize = WTF::HashTableCapacityForSize<staticQualifiedNamesCount>::value; 60 }; 61 62 typedef HashSet<QualifiedName::QualifiedNameImpl*, QualifiedNameHash, QualifiedNameHashTraits> QNameSet; 36 63 37 64 struct QNameComponentsTranslator { -
trunk/Source/WebCore/dom/make_names.pl
r120168 r123582 601 601 602 602 if (keys %allTags) { 603 print F "const unsigned $parameters{namespace}TagsCount = ", scalar(keys %allTags), ";\n"; 603 604 print F "WebCore::QualifiedName** get$parameters{namespace}Tags(size_t* size);\n"; 604 605 } 605 606 606 607 if (keys %allAttrs) { 608 print F "const unsigned $parameters{namespace}AttrsCount = ", scalar(keys %allAttrs), ";\n"; 607 609 print F "WebCore::QualifiedName** get$parameters{namespace}Attrs(size_t* size);\n"; 608 610 } -
trunk/Tools/ChangeLog
r123580 r123582 1 2012-07-24 Benjamin Poulain <bpoulain@apple.com> && Joseph Pecoraro <pecoraro@apple.com> 2 3 QualifiedName's HashSet should be big enough to hold at least all the static names 4 https://bugs.webkit.org/show_bug.cgi?id=91891 5 6 Reviewed by Darin Adler. 7 8 Add a test for WTF::hashTableCapacityForSize. 9 10 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 11 * TestWebKitAPI/Tests/WTF/HashSet.cpp: Added. 12 (InitialCapacityTestHashTraits): 13 (TestWebKitAPI::testInitialCapacity): 14 (TestWebKitAPI::generateTestCapacityUpToSize): 15 (TestWebKitAPI::TEST): 16 1 17 2012-07-24 Adam Barth <abarth@webkit.org> 2 18 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r122683 r123582 22 22 1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */; }; 23 23 261516D615B0E60500A2C201 /* SetAndUpdateCacheModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = 261516D515B0E60500A2C201 /* SetAndUpdateCacheModel.mm */; }; 24 26B2DFF915BDE599004F691D /* HashSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B2DFF815BDE599004F691D /* HashSet.cpp */; }; 24 25 26DF5A5E15A29BAA003689C2 /* CancelLoadFromResourceLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26DF5A5D15A29BAA003689C2 /* CancelLoadFromResourceLoadDelegate.mm */; }; 25 26 26DF5A6315A2A27E003689C2 /* CancelLoadFromResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */; }; … … 246 247 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundleControllerMac.mm; sourceTree = "<group>"; }; 247 248 261516D515B0E60500A2C201 /* SetAndUpdateCacheModel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SetAndUpdateCacheModel.mm; sourceTree = "<group>"; }; 249 26B2DFF815BDE599004F691D /* HashSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HashSet.cpp; path = WTF/HashSet.cpp; sourceTree = "<group>"; }; 248 250 26DF5A5D15A29BAA003689C2 /* CancelLoadFromResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelLoadFromResourceLoadDelegate.mm; sourceTree = "<group>"; }; 249 251 26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = CancelLoadFromResourceLoadDelegate.html; sourceTree = "<group>"; }; … … 621 623 1AA9E55714980A9900001A8A /* Functional.cpp */, 622 624 0BCD833414857CE400EA2003 /* HashMap.cpp */, 625 26B2DFF815BDE599004F691D /* HashSet.cpp */, 623 626 81B50192140F232300D9EB58 /* StringBuilder.cpp */, 624 627 C01363C713C3997300EF3964 /* StringOperators.cpp */, … … 946 949 261516D615B0E60500A2C201 /* SetAndUpdateCacheModel.mm in Sources */, 947 950 A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */, 951 26B2DFF915BDE599004F691D /* HashSet.cpp in Sources */, 948 952 ); 949 953 runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset
for help on using the changeset viewer.