Changeset 279365 in webkit
- Timestamp:
- Jun 29, 2021, 12:19:27 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 9 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/WTF.xcodeproj/project.pbxproj (modified) (2 diffs)
-
WTF/wtf/CMakeLists.txt (modified) (1 diff)
-
WTF/wtf/SystemMalloc.h (added)
-
WTF/wtf/Vector.h (modified) (3 diffs)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/style/RuleFeature.cpp (modified) (4 diffs)
-
WebCore/style/RuleFeature.h (modified) (4 diffs)
-
WebCore/style/RuleSet.h (modified) (4 diffs)
-
WebCore/style/StyleScopeRuleSets.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r279341 r279365 1 2021-06-29 Antti Koivisto <antti@apple.com> 2 3 Enable Probabilistic Guard Malloc for RuleData and RuleFeature vectors 4 https://bugs.webkit.org/show_bug.cgi?id=227446 5 6 Reviewed by Geoffrey Garen. 7 8 Add SystemMalloc type that can be used with containers like Vector and 9 ProbabilisticGuardMalloc alias for it on Mac/iOS platforms. 10 11 * WTF.xcodeproj/project.pbxproj: 12 * wtf/CMakeLists.txt: 13 * wtf/SystemMalloc.h: Added. 14 (WTF::SystemMalloc::malloc): 15 (WTF::SystemMalloc::tryMalloc): 16 (WTF::SystemMalloc::zeroedMalloc): 17 (WTF::SystemMalloc::tryZeroedMalloc): 18 (WTF::SystemMalloc::realloc): 19 (WTF::SystemMalloc::tryRealloc): 20 (WTF::SystemMalloc::free): 21 * wtf/Vector.h: 22 (WTF::Malloc>::appendVector): 23 24 Include all template parameters for the appendVector argument. 25 1 26 2021-06-28 Mikhail R. Gadelha <mikhail@igalia.com> 2 27 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r279339 r279365 761 761 E4A0AD381A96245500536DF6 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; }; 762 762 E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueCocoa.cpp; sourceTree = "<group>"; }; 763 E4D2AE4D268A4C7F00DFEA02 /* SystemMalloc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemMalloc.h; sourceTree = "<group>"; }; 763 764 EB2C86D8267B275C0052CB9A /* CPUTimePOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUTimePOSIX.cpp; sourceTree = "<group>"; }; 764 765 EB61EDC62409CCC0001EFE36 /* SystemTracingCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemTracingCocoa.cpp; sourceTree = "<group>"; }; … … 1293 1294 5597F82C1D94B9970066BC21 /* SynchronizedFixedQueue.h */, 1294 1295 E3E158251EADA53C004A079D /* SystemFree.h */, 1296 E4D2AE4D268A4C7F00DFEA02 /* SystemMalloc.h */, 1295 1297 0FB317C31C488001007E395A /* SystemTracing.h */, 1296 1298 DEF7FE5F22581AC800C15129 /* TaggedArrayStoragePtr.h */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r278891 r279365 265 265 SynchronizedFixedQueue.h 266 266 SystemFree.h 267 SystemMalloc.h 267 268 SystemTracing.h 268 269 TaggedArrayStoragePtr.h -
trunk/Source/WTF/wtf/Vector.h
r279051 r279365 785 785 template<typename U> ALWAYS_INLINE void append(const U* u, size_t size) { append<FailureAction::Crash>(u, size); } 786 786 template<typename U> ALWAYS_INLINE bool tryAppend(const U* u, size_t size) { return append<FailureAction::Report>(u, size); } 787 template<typename U, size_t otherCapacity > void appendVector(const Vector<U, otherCapacity>&);788 template<typename U, size_t otherCapacity > void appendVector(Vector<U, otherCapacity>&&);787 template<typename U, size_t otherCapacity, typename OtherOverflowHandler, size_t otherMinCapacity, typename OtherMalloc> void appendVector(const Vector<U, otherCapacity, OtherOverflowHandler, otherMinCapacity, OtherMalloc>&); 788 template<typename U, size_t otherCapacity, typename OtherOverflowHandler, size_t otherMinCapacity, typename OtherMalloc> void appendVector(Vector<U, otherCapacity, OtherOverflowHandler, otherMinCapacity, OtherMalloc>&&); 789 789 790 790 void insert(size_t position, ValueType&& value) { insert<ValueType>(position, std::forward<ValueType>(value)); } … … 1384 1384 1385 1385 template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity, typename Malloc> 1386 template<typename U, size_t otherCapacity >1387 inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity, Malloc>::appendVector(const Vector<U, otherCapacity >& val)1386 template<typename U, size_t otherCapacity, typename OtherOverflowHandler, size_t otherMinCapacity, typename OtherMalloc> 1387 inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity, Malloc>::appendVector(const Vector<U, otherCapacity, OtherOverflowHandler, otherMinCapacity, OtherMalloc>& val) 1388 1388 { 1389 1389 append(val.begin(), val.size()); … … 1391 1391 1392 1392 template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity, typename Malloc> 1393 template<typename U, size_t otherCapacity >1394 inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity, Malloc>::appendVector(Vector<U, otherCapacity >&& val)1393 template<typename U, size_t otherCapacity, typename OtherOverflowHandler, size_t otherMinCapacity, typename OtherMalloc> 1394 inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity, Malloc>::appendVector(Vector<U, otherCapacity, OtherOverflowHandler, otherMinCapacity, OtherMalloc>&& val) 1395 1395 { 1396 1396 size_t newSize = m_size + val.size(); -
trunk/Source/WebCore/ChangeLog
r279364 r279365 1 2021-06-29 Antti Koivisto <antti@apple.com> 2 3 Enable Probabilistic Guard Malloc for RuleData and RuleFeature vectors 4 https://bugs.webkit.org/show_bug.cgi?id=227446 5 6 Reviewed by Geoffrey Garen. 7 8 Help for catching a crash. 9 10 * style/RuleFeature.cpp: 11 (WebCore::Style::RuleFeatureSet::collectFeatures): 12 (WebCore::Style::RuleFeatureSet::add): 13 * style/RuleFeature.h: 14 * style/RuleSet.h: 15 * style/StyleScopeRuleSets.cpp: 16 (WebCore::Style::makeRuleSet): 17 (WebCore::Style::ensureInvalidationRuleSets): 18 1 19 2021-06-29 Martin Robinson <mrobinson@igalia.com> 2 20 -
trunk/Source/WebCore/style/RuleFeature.cpp
r278253 r279365 187 187 for (auto& nameAndMatch : selectorFeatures.classes) { 188 188 classRules.ensure(nameAndMatch.first, [] { 189 return makeUnique< Vector<RuleFeature>>();189 return makeUnique<RuleFeatureVector>(); 190 190 }).iterator->value->append({ ruleData, nameAndMatch.second }); 191 191 if (nameAndMatch.second == MatchElement::Host) … … 203 203 for (auto& keyAndMatch : selectorFeatures.pseudoClasses) { 204 204 pseudoClassRules.ensure(keyAndMatch.first, [] { 205 return makeUnique< Vector<RuleFeature>>();205 return makeUnique<RuleFeatureVector>(); 206 206 }).iterator->value->append({ ruleData, keyAndMatch.second }); 207 207 if (keyAndMatch.second == MatchElement::Host) … … 221 221 for (auto& keyValuePair : other.classRules) { 222 222 classRules.ensure(keyValuePair.key, [] { 223 return makeUnique< Vector<RuleFeature>>();223 return makeUnique<RuleFeatureVector>(); 224 224 }).iterator->value->appendVector(*keyValuePair.value); 225 225 } … … 235 235 for (auto& keyValuePair : other.pseudoClassRules) { 236 236 pseudoClassRules.ensure(keyValuePair.key, [] { 237 return makeUnique< Vector<RuleFeature>>();237 return makeUnique<RuleFeatureVector>(); 238 238 }).iterator->value->appendVector(*keyValuePair.value); 239 239 } -
trunk/Source/WebCore/style/RuleFeature.h
r278253 r279365 26 26 #include <wtf/HashMap.h> 27 27 #include <wtf/HashSet.h> 28 #include <wtf/SystemMalloc.h> 28 29 #include <wtf/text/AtomString.h> 29 30 #include <wtf/text/AtomStringHash.h> … … 39 40 enum class MatchElement : uint8_t { Subject, Parent, Ancestor, DirectSibling, IndirectSibling, AnySibling, ParentSibling, AncestorSibling, Host }; 40 41 constexpr unsigned matchElementCount = static_cast<unsigned>(MatchElement::Host) + 1; 42 43 #if HAVE(PROBABILISTIC_GUARD_MALLOC) 44 // Help finding rdar://77450900 45 using RuleMalloc = ProbabilisticGuardMalloc; 46 #else 47 using RuleMalloc = FastMalloc; 48 #endif 41 49 42 50 struct RuleFeature { … … 59 67 }; 60 68 69 using RuleFeatureVector = Vector<RuleFeature, 0, CrashOnOverflow, 16, RuleMalloc>; 70 61 71 struct RuleFeatureSet { 62 72 void add(const RuleFeatureSet&); … … 71 81 HashSet<AtomString> attributeLocalNamesInRules; 72 82 HashSet<AtomString> contentAttributeNamesInRules; 73 Vector<RuleFeature>siblingRules;74 Vector<RuleFeature>uncommonAttributeRules;83 RuleFeatureVector siblingRules; 84 RuleFeatureVector uncommonAttributeRules; 75 85 76 HashMap<AtomString, std::unique_ptr< Vector<RuleFeature>>> classRules;86 HashMap<AtomString, std::unique_ptr<RuleFeatureVector>> classRules; 77 87 HashMap<AtomString, std::unique_ptr<Vector<RuleFeatureWithInvalidationSelector>>> attributeRules; 78 HashMap<CSSSelector::PseudoClassType, std::unique_ptr< Vector<RuleFeature>>, WTF::IntHash<CSSSelector::PseudoClassType>, WTF::StrongEnumHashTraits<CSSSelector::PseudoClassType>> pseudoClassRules;88 HashMap<CSSSelector::PseudoClassType, std::unique_ptr<RuleFeatureVector>, WTF::IntHash<CSSSelector::PseudoClassType>, WTF::StrongEnumHashTraits<CSSSelector::PseudoClassType>> pseudoClassRules; 79 89 HashSet<AtomString> classesAffectingHost; 80 90 HashSet<AtomString> attributesAffectingHost; -
trunk/Source/WebCore/style/RuleSet.h
r279242 r279365 68 68 ~RuleSet(); 69 69 70 typedef Vector<RuleData, 1 > RuleDataVector;70 typedef Vector<RuleData, 1, CrashOnOverflow, 16, RuleMalloc> RuleDataVector; 71 71 typedef HashMap<AtomString, std::unique_ptr<RuleDataVector>> AtomRuleMap; 72 72 … … 74 74 Vector<Ref<const MediaQuerySet>> mediaQuerySets; 75 75 Vector<size_t> affectedRulePositions; 76 Vector<RuleFeature>ruleFeatures;76 RuleFeatureVector ruleFeatures; 77 77 bool requiresFullReset { false }; 78 78 bool result { true }; … … 88 88 Ref<const MediaQuerySet> set; 89 89 Vector<size_t> affectedRulePositions { }; 90 Vector<RuleFeature>ruleFeatures { };90 RuleFeatureVector ruleFeatures { }; 91 91 }; 92 92 Vector<DynamicContext> dynamicContextStack { }; … … 148 148 bool requiredFullReset { false }; 149 149 Vector<size_t> changedQueryIndexes { }; 150 Vector< const Vector<RuleFeature>*> ruleFeatures { };150 Vector<RuleFeatureVector*> ruleFeatures { }; 151 151 }; 152 152 CollectedMediaQueryChanges evaluateDynamicMediaQueryRules(const MediaQueryEvaluator&, size_t startIndex); -
trunk/Source/WebCore/style/StyleScopeRuleSets.cpp
r278253 r279365 118 118 } 119 119 120 static RefPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules)120 static RefPtr<RuleSet> makeRuleSet(const RuleFeatureVector& rules) 121 121 { 122 122 size_t size = rules.size(); … … 220 220 } 221 221 222 template<typename KeyType, typename RuleFeature Type, typename Hash, typename HashTraits>223 static Vector<InvalidationRuleSet>* ensureInvalidationRuleSets(const KeyType& key, HashMap<KeyType, std::unique_ptr<Vector<InvalidationRuleSet>>, Hash, HashTraits>& ruleSetMap, const HashMap<KeyType, std::unique_ptr< Vector<RuleFeatureType>>, Hash, HashTraits>& ruleFeatures)222 template<typename KeyType, typename RuleFeatureVectorType, typename Hash, typename HashTraits> 223 static Vector<InvalidationRuleSet>* ensureInvalidationRuleSets(const KeyType& key, HashMap<KeyType, std::unique_ptr<Vector<InvalidationRuleSet>>, Hash, HashTraits>& ruleSetMap, const HashMap<KeyType, std::unique_ptr<RuleFeatureVectorType>, Hash, HashTraits>& ruleFeatures) 224 224 { 225 225 return ruleSetMap.ensure(key, [&] () -> std::unique_ptr<Vector<InvalidationRuleSet>> { … … 231 231 std::array<Vector<const CSSSelector*>, matchElementCount> invalidationSelectorArray; 232 232 for (auto& feature : *features) { 233 RELEASE_ASSERT(feature.matchElement); 233 234 auto arrayIndex = static_cast<unsigned>(*feature.matchElement); 235 RELEASE_ASSERT(arrayIndex < matchElementArray.size()); 236 234 237 auto& ruleSet = matchElementArray[arrayIndex]; 235 238 if (!ruleSet) 236 239 ruleSet = RuleSet::create(); 237 240 ruleSet->addRule(*feature.styleRule, feature.selectorIndex, feature.selectorListIndex); 238 if constexpr (std::is_same< RuleFeatureType, RuleFeatureWithInvalidationSelector>::value) {241 if constexpr (std::is_same<typename RuleFeatureVectorType::ValueType, RuleFeatureWithInvalidationSelector>::value) { 239 242 if (feature.invalidationSelector) 240 243 invalidationSelectorArray[arrayIndex].append(feature.invalidationSelector);
Note:
See TracChangeset
for help on using the changeset viewer.