Changeset 195141 in webkit
- Timestamp:
- Jan 15, 2016 12:01:42 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r195094 r195141 1 2016-01-15 Andreas Kling <akling@apple.com> 2 3 Fragmentation-free allocator for timeless and/or coupled allocations. 4 <https://webkit.org/b/152696> 5 6 Reviewed by Antti Koivisto. 7 8 Introduce BumpArena, a space-efficient memory allocator for situations where 9 you feel pretty confident betting on allocation lifetimes. 10 11 Basic design: 12 13 - Reserves 128MB range of memory at startup. 14 - Allocates 4kB-aligned blocks of 4kB from VM at a time. 15 - Bump-pointer allocates out of a block until it reaches end. 16 - Each allocation increments the ref-count of its block. 17 - Each deallocation decrements the ref-count of its block. 18 - Transparently falls back to fastMalloc()/fastFree() when needed. 19 20 Interface: 21 22 - BumpArena::create() 23 24 Create your very own BumpArena! 25 26 - BumpArena::allocate(BumpArena* arena, size_t size) 27 28 Allocates 'size' bytes of memory from 'arena'. 29 If 'arena' is null, falls back to fastMalloc(). 30 31 - BumpArena::deallocate(void* ptr) 32 33 If 'ptr' is BumpArena allocation, decrements block ref-count. 34 If 'ptr' is FastMalloc allocation, calls fastFree() on it. 35 36 - WTF_MAKE_BUMPARENA_ALLOCATED; 37 38 Macro that gives a class or struct custom operators new and delete 39 for allocation out of BumpArena. Just like WTF_MAKE_FAST_ALLOCATED; 40 41 Note that while the name of this patch says "fragmentation-free allocator" 42 it will only be fragmentation-free when used for appropriate things. 43 This is not meant to be a general-purpose allocator. Only use it for sets of 44 allocations that are known to die roughly at the same time. 45 46 BumpArena will never resume allocating from a block that has been filled, 47 so it's even more important than usual that everything gets deallocated. 48 49 BumpArena redirects allocations to FastMalloc in three cases: 50 51 - When invoked with a null BumpArena* 52 - When allocation request is larger than BumpArena's block size (4kB) 53 - When BumpArena has exhausted all of its pre-reserved VM. (128MB) 54 55 The VM allocator will eagerly return blocks of VM to the kernel by calling 56 madvise(). Average time spent in madvise is around 0.007ms on my box. 57 58 * WTF.vcxproj/WTF.vcxproj: 59 * WTF.vcxproj/WTF.vcxproj.filters: 60 * WTF.xcodeproj/project.pbxproj: 61 * wtf/BumpArena.cpp: Added. 62 (WTF::BumpArena::Block::capacity): 63 (WTF::BumpArena::Block::arena): 64 (WTF::BumpArena::Block::payloadStart): 65 (WTF::arenas): 66 (WTF::BumpArena::Block::Block): 67 (WTF::BumpArena::Block::~Block): 68 (WTF::BumpArena::Block::ref): 69 (WTF::BlockAllocator::BlockAllocator): 70 (WTF::BlockAllocator::isAllocation): 71 (WTF::blockAllocator): 72 (WTF::BlockAllocator::allocateBlock): 73 (WTF::BlockAllocator::deallocateBlock): 74 (WTF::BumpArena::Block::deref): 75 (WTF::BumpArena::Block::create): 76 (WTF::BumpArena::Block::dump): 77 (WTF::BumpArena::dump): 78 (WTF::BumpArena::create): 79 (WTF::BumpArena::BumpArena): 80 (WTF::BumpArena::~BumpArena): 81 (WTF::BumpArena::allocateSlow): 82 (WTF::BumpArena::allocate): 83 (WTF::BumpArena::deallocate): 84 (WTF::BumpArena::Block::blockFor): 85 (WTF::BumpArena::arenaFor): 86 * wtf/BumpArena.h: Added. 87 * wtf/CMakeLists.txt: 88 1 89 2016-01-15 Konstantin Tokarev <annulen@yandex.ru> 2 90 -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj
r194980 r195141 54 54 <ClCompile Include="..\wtf\Assertions.cpp" /> 55 55 <ClCompile Include="..\wtf\BitVector.cpp" /> 56 <ClCompile Include="..\wtf\BumpArena.cpp" /> 56 57 <ClCompile Include="..\wtf\CompilationThread.cpp" /> 57 58 <ClCompile Include="..\wtf\CryptographicUtilities.cpp" /> -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
r194980 r195141 119 119 </ClCompile> 120 120 <ClCompile Include="..\wtf\BitVector.cpp"> 121 <Filter>wtf</Filter> 122 </ClCompile> 123 <ClCompile Include="..\wtf\BumpArena.cpp"> 121 124 <Filter>wtf</Filter> 122 125 </ClCompile> -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r194980 r195141 288 288 A8A47487151A825B004123FF /* WTFThreadData.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4737B151A825B004123FF /* WTFThreadData.h */; }; 289 289 A8A4748C151A8264004123FF /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4748B151A8264004123FF /* config.h */; }; 290 AD9C50C11C3C1D5D005FBF1E /* BumpArena.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD9C50BF1C3C1D5D005FBF1E /* BumpArena.cpp */; }; 291 AD9C50C21C3C1D5D005FBF1E /* BumpArena.h in Headers */ = {isa = PBXBuildFile; fileRef = AD9C50C01C3C1D5D005FBF1E /* BumpArena.h */; settings = {ATTRIBUTES = (Private, ); }; }; 290 292 B38FD7BD168953E80065C969 /* FeatureDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = B38FD7BC168953E80065C969 /* FeatureDefines.h */; }; 291 293 C4F8A93719C65EB400B2B15D /* Stopwatch.h in Headers */ = {isa = PBXBuildFile; fileRef = C4F8A93619C65EB400B2B15D /* Stopwatch.h */; }; … … 601 603 A8A4737B151A825B004123FF /* WTFThreadData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFThreadData.h; sourceTree = "<group>"; }; 602 604 A8A4748B151A8264004123FF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; }; 605 AD9C50BF1C3C1D5D005FBF1E /* BumpArena.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BumpArena.cpp; sourceTree = "<group>"; }; 606 AD9C50C01C3C1D5D005FBF1E /* BumpArena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BumpArena.h; sourceTree = "<group>"; }; 603 607 B38FD7BC168953E80065C969 /* FeatureDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeatureDefines.h; sourceTree = "<group>"; }; 604 608 C4F8A93619C65EB400B2B15D /* Stopwatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stopwatch.h; sourceTree = "<group>"; }; … … 758 762 0F93274A1C17F4B700CF6564 /* Box.h */, 759 763 0F4570441BE834410062A629 /* BubbleSort.h */, 764 AD9C50BF1C3C1D5D005FBF1E /* BumpArena.cpp */, 765 AD9C50C01C3C1D5D005FBF1E /* BumpArena.h */, 760 766 A8A47267151A825A004123FF /* BumpPointerAllocator.h */, 761 767 EB95E1EF161A72410089A2F5 /* ByteOrder.h */, … … 1262 1268 A8A4743F151A825B004123FF /* StringHash.h in Headers */, 1263 1269 A748745417A0BDAE00FA04CB /* StringHashDumpContext.h in Headers */, 1270 AD9C50C21C3C1D5D005FBF1E /* BumpArena.h in Headers */, 1264 1271 A8A47441151A825B004123FF /* StringImpl.h in Headers */, 1265 1272 A8A47442151A825B004123FF /* StringOperators.h in Headers */, … … 1405 1412 9BC70F05176C379D00101DEC /* AtomicStringTable.cpp in Sources */, 1406 1413 1469419D16EAB10A0024E146 /* AutodrainedPoolMac.mm in Sources */, 1414 AD9C50C11C3C1D5D005FBF1E /* BumpArena.cpp in Sources */, 1407 1415 8134013815B092FD001FF0B8 /* Base64.cpp in Sources */, 1408 1416 A8A473A8151A825B004123FF /* bignum-dtoa.cc in Sources */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r194980 r195141 8 8 Bitmap.h 9 9 BubbleSort.h 10 BumpArena.h 10 11 BumpPointerAllocator.h 11 12 ByteOrder.h … … 154 155 Atomics.cpp 155 156 BitVector.cpp 157 BumpArena.cpp 156 158 CompilationThread.cpp 157 159 CryptographicUtilities.cpp -
trunk/Source/WebCore/ChangeLog
r195132 r195141 1 2016-01-15 Andreas Kling <akling@apple.com> 2 3 Use BumpArena for style sheet object tree. 4 <https://webkit.org/b/152696> 5 6 Reviewed by Antti Koivisto. 7 8 Give each StyleSheetContents its own BumpArena, and plumb it down through CSSParser 9 to allocate StyleRule, StyleProperties and CSSSelectorList's selector arrays there. 10 11 This basically means that most objects that make up a given style sheet will end up 12 in one (or a few) contiguous region(s) of memory, instead of being scattered all 13 over the malloc heap. 14 15 In the common case (no CSSOM manipulation), the lifetimes of these objects are very 16 predictable: everything tends to die when the StyleSheetContents dies. 17 This dramatically improves space-efficiency in those cases, and allows us to return 18 contiguous chunks of memory to the system once a style sheet is no longer needed. 19 20 One-off CSS parses that don't work within a StyleSheetContents context will have 21 their StyleRules & co allocated through FastMalloc just like before. 22 23 Bonus: give SelectorQueryCache a dedicated BumpArena as well, since it has very 24 predictable lifetime. 25 26 * css/CSSGrammar.y.in: 27 * css/CSSKeyframesRule.h: 28 (WebCore::StyleRuleKeyframes::create): 29 * css/CSSParser.cpp: 30 (WebCore::CSSParser::createStyleProperties): 31 (WebCore::CSSParser::createMediaRule): 32 (WebCore::CSSParser::createSupportsRule): 33 (WebCore::CSSParser::createKeyframesRule): 34 (WebCore::CSSParser::setArena): 35 (WebCore::CSSParser::arena): 36 (WebCore::CSSParser::createStyleRule): 37 (WebCore::CSSParser::createFontFaceRule): 38 (WebCore::CSSParser::createPageRule): 39 (WebCore::CSSParser::createRegionRule): 40 (WebCore::CSSParser::createViewportRule): 41 * css/CSSParser.h: 42 * css/CSSParserValues.cpp: 43 (WebCore::CSSParserSelector::parsePseudoElementCueFunctionSelector): 44 (WebCore::CSSParserSelector::adoptSelectorVector): 45 * css/CSSParserValues.h: 46 * css/CSSSelectorList.cpp: 47 (WebCore::CSSSelectorList::CSSSelectorList): 48 (WebCore::CSSSelectorList::adoptSelectorVector): 49 (WebCore::CSSSelectorList::deleteSelectors): 50 * css/CSSSelectorList.h: 51 * css/StyleProperties.cpp: 52 (WebCore::ImmutableStyleProperties::create): 53 (WebCore::StyleProperties::immutableCopyIfNeeded): 54 * css/StyleProperties.h: 55 * css/StyleRule.cpp: 56 (WebCore::StyleRule::create): 57 (WebCore::StyleRule::splitIntoMultipleRulesWithMaximumSelectorComponentCount): 58 (WebCore::StyleRuleRegion::StyleRuleRegion): 59 * css/StyleRule.h: 60 (WebCore::StyleRule::create): 61 (WebCore::StyleRule::parserAdoptSelectorVector): 62 (WebCore::StyleRuleFontFace::create): 63 (WebCore::StyleRulePage::create): 64 (WebCore::StyleRulePage::parserAdoptSelectorVector): 65 (WebCore::StyleRuleMedia::create): 66 (WebCore::StyleRuleSupports::create): 67 (WebCore::StyleRuleRegion::create): 68 (WebCore::StyleRuleViewport::create): 69 * css/StyleSheetContents.cpp: 70 (WebCore::StyleSheetContents::StyleSheetContents): 71 (WebCore::StyleSheetContents::parseAuthorStyleSheet): 72 (WebCore::StyleSheetContents::parseStringAtPosition): 73 * css/StyleSheetContents.h: 74 * dom/SelectorQuery.cpp: 75 (WebCore::SelectorQueryCache::SelectorQueryCache): 76 (WebCore::SelectorQueryCache::add): 77 * dom/SelectorQuery.h: 78 * svg/SVGFontFaceElement.cpp: 79 (WebCore::SVGFontFaceElement::SVGFontFaceElement): 80 1 81 2016-01-15 Dave Hyatt <hyatt@apple.com> 2 82 -
trunk/Source/WebCore/css/CSSGrammar.y.in
r194980 r195141 404 404 if ($4) { 405 405 if (parser->m_selectorListForParseSelector) 406 parser->m_selectorListForParseSelector->adoptSelectorVector( *$4);406 parser->m_selectorListForParseSelector->adoptSelectorVector(parser->arena(), *$4); 407 407 parser->recycleSelectorVector(std::unique_ptr<Vector<std::unique_ptr<CSSParserSelector>>>($4)); 408 408 } … … 1354 1354 // used by ::cue(:past/:future) 1355 1355 | ':' ':' CUEFUNCTION maybe_space simple_selector_list maybe_space ')' { 1356 $$ = CSSParserSelector::parsePseudoElementCueFunctionSelector( $3, $5);1356 $$ = CSSParserSelector::parsePseudoElementCueFunctionSelector(parser->arena(), $3, $5); 1357 1357 } 1358 1358 #endif … … 1367 1367 auto selector = std::make_unique<CSSParserSelector>(); 1368 1368 selector->setMatch(CSSSelector::PseudoClass); 1369 selector->adoptSelectorVector( *std::unique_ptr<Vector<std::unique_ptr<CSSParserSelector>>>($4));1369 selector->adoptSelectorVector(parser->arena(), *std::unique_ptr<Vector<std::unique_ptr<CSSParserSelector>>>($4)); 1370 1370 selector->setPseudoClassValue($2); 1371 1371 if (selector->pseudoClassType() == CSSSelector::PseudoClassAny) … … 1378 1378 auto selector = std::make_unique<CSSParserSelector>(); 1379 1379 selector->setMatch(CSSSelector::PseudoClass); 1380 selector->adoptSelectorVector( *std::unique_ptr<Vector<std::unique_ptr<CSSParserSelector>>>($4));1380 selector->adoptSelectorVector(parser->arena(), *std::unique_ptr<Vector<std::unique_ptr<CSSParserSelector>>>($4)); 1381 1381 selector->setPseudoClassValue($2); 1382 1382 if (selector->pseudoClassType() == CSSSelector::PseudoClassMatches) … … 1428 1428 selector->setPseudoClassValue($2); 1429 1429 if (ending) 1430 selector->adoptSelectorVector( *ending);1430 selector->adoptSelectorVector(parser->arena(), *ending); 1431 1431 CSSSelector::PseudoClassType pseudoClassType = selector->pseudoClassType(); 1432 1432 if (pseudoClassType == CSSSelector::PseudoClassNthChild || pseudoClassType == CSSSelector::PseudoClassNthLastChild) … … 1443 1443 selector->setPseudoClassValue($2); 1444 1444 if (ending) 1445 selector->adoptSelectorVector( *ending);1445 selector->adoptSelectorVector(parser->arena(), *ending); 1446 1446 CSSSelector::PseudoClassType pseudoClassType = selector->pseudoClassType(); 1447 1447 if (pseudoClassType == CSSSelector::PseudoClassNthChild || pseudoClassType == CSSSelector::PseudoClassNthLastChild) … … 1458 1458 selector->setPseudoClassValue($2); 1459 1459 if (ending) 1460 selector->adoptSelectorVector( *ending);1460 selector->adoptSelectorVector(parser->arena(), *ending); 1461 1461 CSSSelector::PseudoClassType pseudoClassType = selector->pseudoClassType(); 1462 1462 if (pseudoClassType == CSSSelector::PseudoClassNthChild || pseudoClassType == CSSSelector::PseudoClassNthLastChild) … … 1512 1512 selector->setMatch(CSSSelector::PseudoClass); 1513 1513 selector->setPseudoClassValue($2); 1514 selector->adoptSelectorVector( *list);1514 selector->adoptSelectorVector(parser->arena(), *list); 1515 1515 if (selector->pseudoClassType() == CSSSelector::PseudoClassNot) 1516 1516 $$ = selector.release(); -
trunk/Source/WebCore/css/CSSKeyframesRule.h
r194980 r195141 41 41 class StyleRuleKeyframes : public StyleRuleBase { 42 42 public: 43 static Ref<StyleRuleKeyframes> create( ) { return adoptRef(*new StyleRuleKeyframes()); }43 static Ref<StyleRuleKeyframes> create(BumpArena* arena) { return adoptRef(*new (arena) StyleRuleKeyframes); } 44 44 45 45 ~StyleRuleKeyframes(); -
trunk/Source/WebCore/css/CSSParser.cpp
r194980 r195141 1645 1645 results.remove(0, unusedEntries); 1646 1646 1647 return ImmutableStyleProperties::create( results.data(), results.size(), m_context.mode);1647 return ImmutableStyleProperties::create(arena(), results.data(), results.size(), m_context.mode); 1648 1648 } 1649 1649 … … 12702 12702 // To comply with w3c test suite expectation, create an empty media query 12703 12703 // even when it is syntactically incorrect. 12704 rule = StyleRuleMedia::create( MediaQuerySet::create(), emptyRules);12704 rule = StyleRuleMedia::create(arena(), MediaQuerySet::create(), emptyRules); 12705 12705 } else 12706 rule = StyleRuleMedia::create( media, rules ? *rules : emptyRules);12706 rule = StyleRuleMedia::create(arena(), media, rules ? *rules : emptyRules); 12707 12707 processAndAddNewRuleToSourceTreeIfNeeded(); 12708 12708 return rule; … … 12730 12730 12731 12731 if (rules) 12732 rule = StyleRuleSupports::create( conditionText, conditionIsSupported, *rules);12732 rule = StyleRuleSupports::create(arena(), conditionText, conditionIsSupported, *rules); 12733 12733 else { 12734 12734 RuleList emptyRules; 12735 rule = StyleRuleSupports::create( conditionText, conditionIsSupported, emptyRules);12735 rule = StyleRuleSupports::create(arena(), conditionText, conditionIsSupported, emptyRules); 12736 12736 } 12737 12737 … … 12842 12842 std::unique_ptr<Vector<RefPtr<StyleKeyframe>>> keyframes = WTFMove(popKeyframes); 12843 12843 m_allowImportRules = m_allowNamespaceDeclarations = false; 12844 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create( );12844 RefPtr<StyleRuleKeyframes> rule = StyleRuleKeyframes::create(arena()); 12845 12845 for (size_t i = 0; i < keyframes->size(); ++i) 12846 12846 rule->parserAppendKeyframe(keyframes->at(i)); … … 12850 12850 } 12851 12851 12852 void CSSParser::setArena(BumpArena& arena) 12853 { 12854 m_arena = &arena; 12855 } 12856 12857 BumpArena* CSSParser::arena() 12858 { 12859 return m_arena.get(); 12860 } 12861 12852 12862 RefPtr<StyleRuleBase> CSSParser::createStyleRule(Vector<std::unique_ptr<CSSParserSelector>>* selectors) 12853 12863 { … … 12856 12866 m_allowImportRules = false; 12857 12867 m_allowNamespaceDeclarations = false; 12858 rule = StyleRule::create( m_lastSelectorLineNumber, createStyleProperties());12859 rule->parserAdoptSelectorVector( *selectors);12868 rule = StyleRule::create(arena(), m_lastSelectorLineNumber, createStyleProperties()); 12869 rule->parserAdoptSelectorVector(arena(), *selectors); 12860 12870 processAndAddNewRuleToSourceTreeIfNeeded(); 12861 12871 } else … … 12880 12890 } 12881 12891 } 12882 RefPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create( createStyleProperties());12892 RefPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create(arena(), createStyleProperties()); 12883 12893 clearProperties(); 12884 12894 processAndAddNewRuleToSourceTreeIfNeeded(); … … 12964 12974 RefPtr<StyleRulePage> rule; 12965 12975 if (pageSelector) { 12966 rule = StyleRulePage::create( createStyleProperties());12976 rule = StyleRulePage::create(arena(), createStyleProperties()); 12967 12977 Vector<std::unique_ptr<CSSParserSelector>> selectorVector; 12968 12978 selectorVector.append(WTFMove(pageSelector)); 12969 rule->parserAdoptSelectorVector( selectorVector);12979 rule->parserAdoptSelectorVector(arena(), selectorVector); 12970 12980 processAndAddNewRuleToSourceTreeIfNeeded(); 12971 12981 } else … … 12999 13009 m_allowImportRules = m_allowNamespaceDeclarations = false; 13000 13010 13001 RefPtr<StyleRuleRegion> regionRule = StyleRuleRegion::create( regionSelector, *rules);13011 RefPtr<StyleRuleRegion> regionRule = StyleRuleRegion::create(arena(), regionSelector, *rules); 13002 13012 13003 13013 if (isExtractingSourceData()) … … 13273 13283 m_allowImportRules = m_allowNamespaceDeclarations = false; 13274 13284 13275 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create( createStyleProperties());13285 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create(arena(), createStyleProperties()); 13276 13286 clearProperties(); 13277 13287 -
trunk/Source/WebCore/css/CSSParser.h
r194980 r195141 37 37 #include "WebKitCSSFilterValue.h" 38 38 #include <memory> 39 #include <wtf/BumpArena.h> 39 40 #include <wtf/HashMap.h> 40 41 #include <wtf/HashSet.h> … … 115 116 WEBCORE_EXPORT ~CSSParser(); 116 117 118 void setArena(BumpArena&); 119 117 120 void parseSheet(StyleSheetContents*, const String&, const TextPosition&, RuleSourceDataList*, bool logErrors); 118 121 RefPtr<StyleRuleBase> parseRule(StyleSheetContents*, const String&); … … 398 401 CSSParserContext m_context; 399 402 403 BumpArena* arena(); 404 RefPtr<BumpArena> m_arena; 400 405 bool m_important; 401 406 CSSPropertyID m_id; -
trunk/Source/WebCore/css/CSSParserValues.cpp
r194980 r195141 215 215 216 216 #if ENABLE(VIDEO_TRACK) 217 CSSParserSelector* CSSParserSelector::parsePseudoElementCueFunctionSelector( const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* parsedSelectorVector)217 CSSParserSelector* CSSParserSelector::parsePseudoElementCueFunctionSelector(BumpArena* arena, const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* parsedSelectorVector) 218 218 { 219 219 ASSERT_UNUSED(functionIdentifier, String(functionIdentifier) == "cue("); … … 227 227 selector->m_selector->setMatch(CSSSelector::PseudoElement); 228 228 selector->m_selector->setPseudoElementType(CSSSelector::PseudoElementCue); 229 selector->adoptSelectorVector( *selectorVector);229 selector->adoptSelectorVector(arena, *selectorVector); 230 230 return selector.release(); 231 231 } … … 280 280 } 281 281 282 void CSSParserSelector::adoptSelectorVector( Vector<std::unique_ptr<CSSParserSelector>>& selectorVector)282 void CSSParserSelector::adoptSelectorVector(BumpArena* arena, Vector<std::unique_ptr<CSSParserSelector>>& selectorVector) 283 283 { 284 284 auto selectorList = std::make_unique<CSSSelectorList>(); 285 selectorList->adoptSelectorVector( selectorVector);285 selectorList->adoptSelectorVector(arena, selectorVector); 286 286 m_selector->setSelectorList(WTFMove(selectorList)); 287 287 } -
trunk/Source/WebCore/css/CSSParserValues.h
r194980 r195141 25 25 #include "CSSValueKeywords.h" 26 26 #include "CSSValueList.h" 27 #include <wtf/BumpArena.h> 27 28 #include <wtf/text/AtomicString.h> 28 29 #include <wtf/text/AtomicStringHash.h> … … 212 213 static CSSParserSelector* parsePagePseudoSelector(const CSSParserString& pseudoTypeString); 213 214 static CSSParserSelector* parsePseudoElementSelector(CSSParserString& pseudoTypeString); 214 static CSSParserSelector* parsePseudoElementCueFunctionSelector( const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* selectorVector);215 static CSSParserSelector* parsePseudoElementCueFunctionSelector(BumpArena*, const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* selectorVector); 215 216 static CSSParserSelector* parsePseudoClassAndCompatibilityElementSelector(CSSParserString& pseudoTypeString); 216 217 … … 229 230 void setForPage() { m_selector->setForPage(); } 230 231 231 void adoptSelectorVector( Vector<std::unique_ptr<CSSParserSelector>>& selectorVector);232 void adoptSelectorVector(BumpArena*, Vector<std::unique_ptr<CSSParserSelector>>& selectorVector); 232 233 void setLangArgumentList(const Vector<CSSParserString>& stringVector); 233 234 -
trunk/Source/WebCore/css/CSSSelectorList.cpp
r194980 r195141 38 38 ASSERT_WITH_SECURITY_IMPLICATION(otherComponentCount); 39 39 40 m_selectorArray = reinterpret_cast<CSSSelector*>( fastMalloc(sizeof(CSSSelector) * otherComponentCount));40 m_selectorArray = reinterpret_cast<CSSSelector*>(BumpArena::allocate(BumpArena::arenaFor(other.m_selectorArray), sizeof(CSSSelector) * otherComponentCount)); 41 41 for (unsigned i = 0; i < otherComponentCount; ++i) 42 42 new (NotNull, &m_selectorArray[i]) CSSSelector(other.m_selectorArray[i]); … … 50 50 } 51 51 52 void CSSSelectorList::adoptSelectorVector( Vector<std::unique_ptr<CSSParserSelector>>& selectorVector)52 void CSSSelectorList::adoptSelectorVector(BumpArena* arena, Vector<std::unique_ptr<CSSParserSelector>>& selectorVector) 53 53 { 54 54 ASSERT_WITH_SECURITY_IMPLICATION(!selectorVector.isEmpty()); … … 61 61 } 62 62 ASSERT(flattenedSize); 63 m_selectorArray = reinterpret_cast<CSSSelector*>( fastMalloc(sizeof(CSSSelector) * flattenedSize));63 m_selectorArray = reinterpret_cast<CSSSelector*>(BumpArena::allocate(arena, sizeof(CSSSelector) * flattenedSize)); 64 64 size_t arrayIndex = 0; 65 65 for (size_t i = 0; i < selectorVector.size(); ++i) { … … 120 120 s->~CSSSelector(); 121 121 } 122 fastFree(selectorArray);122 BumpArena::deallocate(selectorArray); 123 123 } 124 124 -
trunk/Source/WebCore/css/CSSSelectorList.h
r194980 r195141 29 29 #include "CSSSelector.h" 30 30 #include <memory> 31 #include <wtf/BumpArena.h> 31 32 32 33 namespace WebCore { … … 43 44 ~CSSSelectorList() { deleteSelectors(); } 44 45 45 void adoptSelectorVector( Vector<std::unique_ptr<CSSParserSelector>>& selectorVector);46 void adoptSelectorVector(BumpArena*, Vector<std::unique_ptr<CSSParserSelector>>&); 46 47 void adoptSelectorArray(CSSSelector* selectors) { ASSERT(!m_selectorArray); m_selectorArray = selectors; } 47 48 -
trunk/Source/WebCore/css/StyleProperties.cpp
r194980 r195141 56 56 } 57 57 58 Ref<ImmutableStyleProperties> ImmutableStyleProperties::create( const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode)59 { 60 void* slot = WTF::fastMalloc(sizeForImmutableStylePropertiesWithPropertyCount(count));58 Ref<ImmutableStyleProperties> ImmutableStyleProperties::create(BumpArena* arena, const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode) 59 { 60 void* slot = BumpArena::allocate(arena, sizeForImmutableStylePropertiesWithPropertyCount(count)); 61 61 return adoptRef(*new (NotNull, slot) ImmutableStyleProperties(properties, count, cssParserMode)); 62 62 } … … 67 67 return downcast<ImmutableStyleProperties>(const_cast<StyleProperties&>(*this)); 68 68 const MutableStyleProperties& mutableThis = downcast<MutableStyleProperties>(*this); 69 return ImmutableStyleProperties::create( mutableThis.m_propertyVector.data(), mutableThis.m_propertyVector.size(), cssParserMode());69 return ImmutableStyleProperties::create(BumpArena::arenaFor(this), mutableThis.m_propertyVector.data(), mutableThis.m_propertyVector.size(), cssParserMode()); 70 70 } 71 71 -
trunk/Source/WebCore/css/StyleProperties.h
r194980 r195141 30 30 #include "CSSValueKeywords.h" 31 31 #include <memory> 32 #include <wtf/BumpArena.h> 32 33 #include <wtf/ListHashSet.h> 33 34 #include <wtf/TypeCasts.h> … … 47 48 class StyleSheetContents; 48 49 49 class StyleProperties : public RefCounted<StyleProperties> { 50 class StyleProperties : public WTF::RefCountedBase { 51 WTF_MAKE_BUMPARENA_ALLOCATED; 50 52 friend class PropertyReference; 51 53 public: … … 162 164 public: 163 165 WEBCORE_EXPORT ~ImmutableStyleProperties(); 164 static Ref<ImmutableStyleProperties> create( const CSSProperty* properties, unsigned count, CSSParserMode);166 static Ref<ImmutableStyleProperties> create(BumpArena*, const CSSProperty* properties, unsigned count, CSSParserMode); 165 167 166 168 unsigned propertyCount() const { return m_arraySize; } -
trunk/Source/WebCore/css/StyleRule.cpp
r194980 r195141 220 220 } 221 221 222 Ref<StyleRule> StyleRule::create( int sourceLine, const Vector<const CSSSelector*>& selectors, Ref<StyleProperties>&& properties)222 Ref<StyleRule> StyleRule::create(BumpArena* arena, int sourceLine, const Vector<const CSSSelector*>& selectors, Ref<StyleProperties>&& properties) 223 223 { 224 224 ASSERT_WITH_SECURITY_IMPLICATION(!selectors.isEmpty()); 225 CSSSelector* selectorListArray = reinterpret_cast<CSSSelector*>( fastMalloc(sizeof(CSSSelector) * selectors.size()));225 CSSSelector* selectorListArray = reinterpret_cast<CSSSelector*>(BumpArena::allocate(arena, sizeof(CSSSelector) * selectors.size())); 226 226 for (unsigned i = 0; i < selectors.size(); ++i) 227 227 new (NotNull, &selectorListArray[i]) CSSSelector(*selectors.at(i)); 228 228 selectorListArray[selectors.size() - 1].setLastInSelectorList(); 229 auto rule = StyleRule::create( sourceLine, WTFMove(properties));229 auto rule = StyleRule::create(arena, sourceLine, WTFMove(properties)); 230 230 rule.get().parserAdoptSelectorArray(selectorListArray); 231 231 return rule; … … 245 245 246 246 if (componentsInThisSelector.size() + componentsSinceLastSplit.size() > maxCount && !componentsSinceLastSplit.isEmpty()) { 247 rules.append(create( sourceLine(), componentsSinceLastSplit, const_cast<StyleProperties&>(m_properties.get())));247 rules.append(create(BumpArena::arenaFor(this), sourceLine(), componentsSinceLastSplit, const_cast<StyleProperties&>(m_properties.get()))); 248 248 componentsSinceLastSplit.clear(); 249 249 } … … 253 253 254 254 if (!componentsSinceLastSplit.isEmpty()) 255 rules.append(create( sourceLine(), componentsSinceLastSplit, const_cast<StyleProperties&>(m_properties.get())));255 rules.append(create(BumpArena::arenaFor(this), sourceLine(), componentsSinceLastSplit, const_cast<StyleProperties&>(m_properties.get()))); 256 256 257 257 return rules; … … 361 361 : StyleRuleGroup(Region, adoptRules) 362 362 { 363 m_selectorList.adoptSelectorVector( *selectors);363 m_selectorList.adoptSelectorVector(BumpArena::arenaFor(this), *selectors); 364 364 } 365 365 -
trunk/Source/WebCore/css/StyleRule.h
r194980 r195141 26 26 #include "MediaList.h" 27 27 #include "StyleProperties.h" 28 #include <wtf/BumpArena.h> 28 29 #include <wtf/RefPtr.h> 29 30 #include <wtf/TypeCasts.h> … … 38 39 39 40 class StyleRuleBase : public WTF::RefCountedBase { 40 WTF_MAKE_ FAST_ALLOCATED;41 WTF_MAKE_BUMPARENA_ALLOCATED; 41 42 public: 42 43 enum Type { … … 102 103 103 104 class StyleRule : public StyleRuleBase { 104 WTF_MAKE_FAST_ALLOCATED; 105 public: 106 static Ref<StyleRule> create(int sourceLine, Ref<StyleProperties>&& properties) 107 { 108 return adoptRef(*new StyleRule(sourceLine, WTFMove(properties))); 105 public: 106 static Ref<StyleRule> create(BumpArena* arena, int sourceLine, Ref<StyleProperties>&& properties) 107 { 108 return adoptRef(*new (arena) StyleRule(sourceLine, WTFMove(properties))); 109 109 } 110 110 … … 115 115 MutableStyleProperties& mutableProperties(); 116 116 117 void parserAdoptSelectorVector( Vector<std::unique_ptr<CSSParserSelector>>& selectors) { m_selectorList.adoptSelectorVector(selectors); }117 void parserAdoptSelectorVector(BumpArena* arena, Vector<std::unique_ptr<CSSParserSelector>>& selectors) { m_selectorList.adoptSelectorVector(arena, selectors); } 118 118 void wrapperAdoptSelectorList(CSSSelectorList& selectors) { m_selectorList = WTFMove(selectors); } 119 119 void parserAdoptSelectorArray(CSSSelector* selectors) { m_selectorList.adoptSelectorArray(selectors); } … … 129 129 StyleRule(const StyleRule&); 130 130 131 static Ref<StyleRule> create( int sourceLine, const Vector<const CSSSelector*>&, Ref<StyleProperties>&&);131 static Ref<StyleRule> create(BumpArena*, int sourceLine, const Vector<const CSSSelector*>&, Ref<StyleProperties>&&); 132 132 133 133 Ref<StyleProperties> m_properties; … … 137 137 class StyleRuleFontFace : public StyleRuleBase { 138 138 public: 139 static Ref<StyleRuleFontFace> create( Ref<StyleProperties>&& properties) { return adoptRef(*newStyleRuleFontFace(WTFMove(properties))); }139 static Ref<StyleRuleFontFace> create(BumpArena* arena, Ref<StyleProperties>&& properties) { return adoptRef(*new (arena) StyleRuleFontFace(WTFMove(properties))); } 140 140 141 141 ~StyleRuleFontFace(); … … 156 156 class StyleRulePage : public StyleRuleBase { 157 157 public: 158 static Ref<StyleRulePage> create( Ref<StyleProperties>&& properties) { return adoptRef(*newStyleRulePage(WTFMove(properties))); }158 static Ref<StyleRulePage> create(BumpArena* arena, Ref<StyleProperties>&& properties) { return adoptRef(*new (arena) StyleRulePage(WTFMove(properties))); } 159 159 160 160 ~StyleRulePage(); … … 164 164 MutableStyleProperties& mutableProperties(); 165 165 166 void parserAdoptSelectorVector( Vector<std::unique_ptr<CSSParserSelector>>& selectors) { m_selectorList.adoptSelectorVector(selectors); }166 void parserAdoptSelectorVector(BumpArena* arena, Vector<std::unique_ptr<CSSParserSelector>>& selectors) { m_selectorList.adoptSelectorVector(arena, selectors); } 167 167 void wrapperAdoptSelectorList(CSSSelectorList& selectors) { m_selectorList = WTFMove(selectors); } 168 168 … … 194 194 class StyleRuleMedia : public StyleRuleGroup { 195 195 public: 196 static Ref<StyleRuleMedia> create( PassRefPtr<MediaQuerySet> media, Vector<RefPtr<StyleRuleBase>>& adoptRules)197 { 198 return adoptRef(*new StyleRuleMedia(media, adoptRules));196 static Ref<StyleRuleMedia> create(BumpArena* arena, PassRefPtr<MediaQuerySet> media, Vector<RefPtr<StyleRuleBase>>& adoptRules) 197 { 198 return adoptRef(*new (arena) StyleRuleMedia(media, adoptRules)); 199 199 } 200 200 … … 212 212 class StyleRuleSupports : public StyleRuleGroup { 213 213 public: 214 static Ref<StyleRuleSupports> create( const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>& adoptRules)215 { 216 return adoptRef(*new StyleRuleSupports(conditionText, conditionIsSupported, adoptRules));214 static Ref<StyleRuleSupports> create(BumpArena* arena, const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>& adoptRules) 215 { 216 return adoptRef(*new (arena) StyleRuleSupports(conditionText, conditionIsSupported, adoptRules)); 217 217 } 218 218 … … 231 231 class StyleRuleRegion : public StyleRuleGroup { 232 232 public: 233 static Ref<StyleRuleRegion> create( Vector<std::unique_ptr<CSSParserSelector>>* selectors, Vector<RefPtr<StyleRuleBase>>& adoptRules)234 { 235 return adoptRef(*new StyleRuleRegion(selectors, adoptRules));233 static Ref<StyleRuleRegion> create(BumpArena* arena, Vector<std::unique_ptr<CSSParserSelector>>* selectors, Vector<RefPtr<StyleRuleBase>>& adoptRules) 234 { 235 return adoptRef(*new (arena) StyleRuleRegion(selectors, adoptRules)); 236 236 } 237 237 … … 250 250 class StyleRuleViewport : public StyleRuleBase { 251 251 public: 252 static Ref<StyleRuleViewport> create( Ref<StyleProperties>&& properties) { return adoptRef(*newStyleRuleViewport(WTFMove(properties))); }252 static Ref<StyleRuleViewport> create(BumpArena* arena, Ref<StyleProperties>&& properties) { return adoptRef(*new (arena) StyleRuleViewport(WTFMove(properties))); } 253 253 254 254 ~StyleRuleViewport(); -
trunk/Source/WebCore/css/StyleSheetContents.cpp
r194980 r195141 72 72 , m_isInMemoryCache(false) 73 73 , m_parserContext(context) 74 , m_arena(BumpArena::create()) 74 75 { 75 76 } … … 92 93 , m_isInMemoryCache(false) 93 94 , m_parserContext(o.m_parserContext) 95 , m_arena(BumpArena::create()) 94 96 { 95 97 ASSERT(o.isCacheable()); … … 314 316 315 317 CSSParser p(parserContext()); 318 p.setArena(m_arena.get()); 316 319 p.parseSheet(this, sheetText, TextPosition(), nullptr, true); 317 320 … … 335 338 { 336 339 CSSParser p(parserContext()); 340 p.setArena(m_arena.get()); 337 341 p.parseSheet(this, sheetText, textPosition, nullptr, createdByParser); 338 342 return true; -
trunk/Source/WebCore/css/StyleSheetContents.h
r194980 r195141 25 25 #include "CachePolicy.h" 26 26 #include "URL.h" 27 #include <wtf/BumpArena.h> 27 28 #include <wtf/HashMap.h> 28 29 #include <wtf/ListHashSet.h> … … 174 175 175 176 Vector<CSSStyleSheet*> m_clients; 177 178 Ref<BumpArena> m_arena; 176 179 }; 177 180 -
trunk/Source/WebCore/dom/SelectorQuery.cpp
r194980 r195141 610 610 } 611 611 612 SelectorQueryCache::SelectorQueryCache() 613 : m_arena(BumpArena::create()) 614 { 615 } 616 612 617 SelectorQuery* SelectorQueryCache::add(const String& selectors, Document& document, ExceptionCode& ec) 613 618 { … … 617 622 618 623 CSSParser parser(document); 624 parser.setArena(m_arena.get()); 619 625 CSSSelectorList selectorList; 620 626 parser.parseSelector(selectors, selectorList); -
trunk/Source/WebCore/dom/SelectorQuery.h
r194980 r195141 30 30 #include "NodeList.h" 31 31 #include "SelectorCompiler.h" 32 #include <wtf/BumpArena.h> 32 33 #include <wtf/HashMap.h> 33 34 #include <wtf/Vector.h> … … 133 134 134 135 public: 136 SelectorQueryCache(); 135 137 SelectorQuery* add(const String&, Document&, ExceptionCode&); 136 138 137 139 private: 138 140 HashMap<String, std::unique_ptr<SelectorQuery>> m_entries; 141 Ref<BumpArena> m_arena; 139 142 }; 140 143 -
trunk/Source/WebCore/svg/SVGFontFaceElement.cpp
r194980 r195141 50 50 inline SVGFontFaceElement::SVGFontFaceElement(const QualifiedName& tagName, Document& document) 51 51 : SVGElement(tagName, document) 52 , m_fontFaceRule(StyleRuleFontFace::create( MutableStyleProperties::create(CSSStrictMode)))52 , m_fontFaceRule(StyleRuleFontFace::create(nullptr, MutableStyleProperties::create(CSSStrictMode))) 53 53 , m_fontElement(nullptr) 54 54 {
Note: See TracChangeset
for help on using the changeset viewer.