Title: [195173] trunk/Source/WebCore
- Revision
- 195173
- Author
- [email protected]
- Date
- 2016-01-16 12:37:25 -0800 (Sat, 16 Jan 2016)
Log Message
Give RuleSet a BumpArena and start using it for RuleDataVectors.
<https://webkit.org/b/153169>
Reviewed by Antti Koivisto.
Since RuleSet only supports appending rules and doesn't need to worry about removing them,
it's a great candidate for BumpArena optimizations.
Give each RuleSet its own BumpArena and teach them how to allocate RuleDataVector objects
out of them.
There are more things that can be done here, ideally all the sub-allocations inside RuleSet
that happen via e.g Vector and HashMap would also come out of the BumpArena.
* css/RuleSet.cpp:
(WebCore::RuleSet::RuleSet):
(WebCore::RuleSet::addToRuleSet):
(WebCore::RuleSet::copyShadowPseudoElementRulesFrom):
* css/RuleSet.h:
(WebCore::RuleSet::RuleDataVector::create):
(WebCore::RuleSet::RuleSet): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (195172 => 195173)
--- trunk/Source/WebCore/ChangeLog 2016-01-16 19:07:34 UTC (rev 195172)
+++ trunk/Source/WebCore/ChangeLog 2016-01-16 20:37:25 UTC (rev 195173)
@@ -1,3 +1,27 @@
+2016-01-16 Andreas Kling <[email protected]>
+
+ Give RuleSet a BumpArena and start using it for RuleDataVectors.
+ <https://webkit.org/b/153169>
+
+ Reviewed by Antti Koivisto.
+
+ Since RuleSet only supports appending rules and doesn't need to worry about removing them,
+ it's a great candidate for BumpArena optimizations.
+
+ Give each RuleSet its own BumpArena and teach them how to allocate RuleDataVector objects
+ out of them.
+
+ There are more things that can be done here, ideally all the sub-allocations inside RuleSet
+ that happen via e.g Vector and HashMap would also come out of the BumpArena.
+
+ * css/RuleSet.cpp:
+ (WebCore::RuleSet::RuleSet):
+ (WebCore::RuleSet::addToRuleSet):
+ (WebCore::RuleSet::copyShadowPseudoElementRulesFrom):
+ * css/RuleSet.h:
+ (WebCore::RuleSet::RuleDataVector::create):
+ (WebCore::RuleSet::RuleSet): Deleted.
+
2016-01-16 Simon Fraser <[email protected]>
Fix flakiness of displaylists/layer-dispay-list.html
Modified: trunk/Source/WebCore/css/RuleSet.cpp (195172 => 195173)
--- trunk/Source/WebCore/css/RuleSet.cpp 2016-01-16 19:07:34 UTC (rev 195172)
+++ trunk/Source/WebCore/css/RuleSet.cpp 2016-01-16 20:37:25 UTC (rev 195173)
@@ -183,13 +183,18 @@
features.uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(), ruleData.hasDocumentSecurityOrigin()));
}
+RuleSet::RuleSet()
+ : m_arena(WTF::BumpArena::create())
+{
+}
+
void RuleSet::addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map, const RuleData& ruleData)
{
if (!key)
return;
auto& rules = map.add(key, nullptr).iterator->value;
if (!rules)
- rules = std::make_unique<RuleDataVector>();
+ rules = RuleDataVector::create(m_arena.get());
rules->append(ruleData);
}
@@ -399,7 +404,7 @@
void RuleSet::copyShadowPseudoElementRulesFrom(const RuleSet& other)
{
for (auto& keyValuePair : other.m_shadowPseudoElementRules)
- m_shadowPseudoElementRules.add(keyValuePair.key, std::make_unique<RuleDataVector>(*keyValuePair.value));
+ m_shadowPseudoElementRules.add(keyValuePair.key, RuleDataVector::create(m_arena.get(), *keyValuePair.value));
#if ENABLE(VIDEO_TRACK)
// FIXME: We probably shouldn't treat WebVTT as author stylable user agent shadow tree.
Modified: trunk/Source/WebCore/css/RuleSet.h (195172 => 195173)
--- trunk/Source/WebCore/css/RuleSet.h 2016-01-16 19:07:34 UTC (rev 195172)
+++ trunk/Source/WebCore/css/RuleSet.h 2016-01-16 20:37:25 UTC (rev 195173)
@@ -25,6 +25,7 @@
#include "RuleFeature.h"
#include "SelectorCompiler.h"
#include "StyleRule.h"
+#include <wtf/BumpArena.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
@@ -158,7 +159,19 @@
RuleSet();
- typedef Vector<RuleData, 1> RuleDataVector;
+ class RuleDataVector : public Vector<RuleData, 1> {
+ WTF_MAKE_BUMPARENA_ALLOCATED;
+ public:
+ static std::unique_ptr<RuleDataVector> create(BumpArena& arena)
+ {
+ return std::unique_ptr<RuleDataVector>(new (&arena) RuleDataVector);
+ }
+ static std::unique_ptr<RuleDataVector> create(BumpArena& arena, const RuleDataVector& other)
+ {
+ return std::unique_ptr<RuleDataVector>(new (&arena) RuleDataVector(other));
+ }
+ };
+
typedef HashMap<AtomicStringImpl*, std::unique_ptr<RuleDataVector>> AtomRuleMap;
void addRulesFromSheet(StyleSheetContents&, const MediaQueryEvaluator&, StyleResolver* = 0);
@@ -213,18 +226,13 @@
RuleDataVector m_focusPseudoClassRules;
RuleDataVector m_universalRules;
Vector<StyleRulePage*> m_pageRules;
- unsigned m_ruleCount;
- bool m_autoShrinkToFitEnabled;
+ unsigned m_ruleCount { 0 };
+ bool m_autoShrinkToFitEnabled { true };
RuleFeatureSet m_features;
Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets;
+ Ref<BumpArena> m_arena;
};
-inline RuleSet::RuleSet()
- : m_ruleCount(0)
- , m_autoShrinkToFitEnabled(true)
-{
-}
-
inline const RuleSet::RuleDataVector* RuleSet::tagRules(AtomicStringImpl* key, bool isHTMLName) const
{
const AtomRuleMap* tagRules;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes