Changeset 144498 in webkit
- Timestamp:
- Mar 1, 2013 1:53:26 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r144346 r144498 1 2013-03-01 Eric Seidel <eric@webkit.org> 2 3 Threaded HTML Parser has an extra copy of every byte from the network 4 https://bugs.webkit.org/show_bug.cgi?id=111135 5 6 Reviewed by Adam Barth. 7 8 The threaded html parser needs to accept ownership 9 of a string buffer. The easiest way to do this seemed 10 to be to use a PassRefPtr<StringImpl>, but there was no way 11 to generated one from a String (easily), so I added one. 12 13 * wtf/text/WTFString.h: 14 (WTF::String::releaseImpl): 15 1 16 2013-02-28 Oliver Hunt <oliver@apple.com> 2 17 -
trunk/Source/WTF/wtf/text/WTFString.h
r142894 r144498 168 168 169 169 StringImpl* impl() const { return m_impl.get(); } 170 PassRefPtr<StringImpl> releaseImpl() { return m_impl.release(); } 170 171 171 172 unsigned length() const -
trunk/Source/WebCore/ChangeLog
r144497 r144498 1 2013-03-01 Eric Seidel <eric@webkit.org> 2 3 Threaded HTML Parser has an extra copy of every byte from the network 4 https://bugs.webkit.org/show_bug.cgi?id=111135 5 6 Reviewed by Adam Barth. 7 8 Every LayoutTest executes this code in threaded parsing mode. 9 10 * dom/DecodedDataDocumentParser.cpp: 11 (WebCore::DecodedDataDocumentParser::appendBytes): 12 - Pass ownership of the decoded string to the parser. 13 (WebCore::DecodedDataDocumentParser::flush): 14 - Same. 15 * dom/DecodedDataDocumentParser.h: 16 (DecodedDataDocumentParser): 17 * dom/Document.cpp: 18 (WebCore::Document::setContent): 19 * dom/DocumentParser.h: 20 (DocumentParser): 21 * dom/RawDataDocumentParser.h: 22 (WebCore::RawDataDocumentParser::append): 23 * html/FTPDirectoryDocument.cpp: 24 (FTPDirectoryDocumentParser): 25 (WebCore::FTPDirectoryDocumentParser::append): 26 * html/parser/HTMLDocumentParser.cpp: 27 (WebCore::HTMLDocumentParser::append): 28 * html/parser/HTMLDocumentParser.h: 29 (HTMLDocumentParser): 30 * html/parser/HTMLViewSourceParser.cpp: 31 (WebCore::HTMLViewSourceParser::append): 32 * html/parser/HTMLViewSourceParser.h: 33 (HTMLViewSourceParser): 34 * html/parser/TextDocumentParser.cpp: 35 (WebCore::TextDocumentParser::append): 36 * html/parser/TextDocumentParser.h: 37 (TextDocumentParser): 38 * loader/DocumentWriter.cpp: 39 (WebCore::DocumentWriter::replaceDocument): 40 * xml/parser/XMLDocumentParser.cpp: 41 (WebCore::XMLDocumentParser::append): 42 * xml/parser/XMLDocumentParser.h: 43 (XMLDocumentParser): 44 * xml/parser/XMLDocumentParserLibxml2.cpp: 45 (WebCore::XMLDocumentParser::resumeParsing): 46 1 47 2013-03-01 David Hyatt <hyatt@apple.com> 2 48 -
trunk/Source/WebCore/dom/DecodedDataDocumentParser.cpp
r95901 r144498 48 48 49 49 writer->reportDataReceived(); 50 append(decoded );50 append(decoded.releaseImpl()); 51 51 } 52 52 … … 58 58 59 59 writer->reportDataReceived(); 60 append(remainingData );60 append(remainingData.releaseImpl()); 61 61 } 62 62 -
trunk/Source/WebCore/dom/DecodedDataDocumentParser.h
r95901 r144498 42 42 private: 43 43 // append is used by DocumentWriter::replaceDocument. 44 virtual void append( const SegmentedString&) = 0;44 virtual void append(PassRefPtr<StringImpl>) = 0; 45 45 46 46 // appendBytes and flush are used by DocumentWriter (the loader). -
trunk/Source/WebCore/dom/Document.cpp
r144413 r144498 1359 1359 { 1360 1360 open(); 1361 m_parser->append(content); 1361 // FIXME: This should probably use insert(), but that's (intentionally) 1362 // not implemented for the XML parser as it's normally synonymous with 1363 // document.write(). append() will end up yielding, but close() will 1364 // pump the tokenizer syncrhonously and finish the parse. 1365 m_parser->pinToMainThread(); 1366 m_parser->append(content.impl()); 1362 1367 close(); 1363 1368 } -
trunk/Source/WebCore/dom/DocumentParser.h
r144000 r144498 25 25 #define DocumentParser_h 26 26 27 #include <wtf/Forward.h> 27 28 #include <wtf/RefCounted.h> 28 29 … … 52 53 virtual void pinToMainThread() { } 53 54 54 // FIXME: append() should be private, but DocumentWriter::replaceDocument 55 // uses it for now. 56 virtual void append(const SegmentedString&) = 0; 55 // FIXME: append() should be private, but DocumentWriter::replaceDocument uses it for now. 56 // FIXME: This really should take a PassOwnPtr to signify that it expects to take 57 // ownership of the buffer. The parser expects the PassRefPtr to hold the only ref of the StringImpl. 58 virtual void append(PassRefPtr<StringImpl>) = 0; 57 59 58 60 virtual void finish() = 0; -
trunk/Source/WebCore/dom/RawDataDocumentParser.h
r140036 r144498 57 57 } 58 58 59 virtual void append( const SegmentedString&)59 virtual void append(PassRefPtr<StringImpl>) 60 60 { 61 61 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/html/FTPDirectoryDocument.cpp
r142271 r144498 58 58 } 59 59 60 virtual void append( const SegmentedString&);60 virtual void append(PassRefPtr<StringImpl>); 61 61 virtual void finish(); 62 62 … … 347 347 } 348 348 349 void FTPDirectoryDocumentParser::append(const SegmentedString& source) 350 { 349 void FTPDirectoryDocumentParser::append(PassRefPtr<StringImpl> inputSource) 350 { 351 String source(inputSource); 352 351 353 // Make sure we have the table element to append to by loading the template set in the pref, or 352 354 // creating a very basic document with the appropriate table -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp
r144407 r144498 655 655 #endif 656 656 657 void HTMLDocumentParser::append( const SegmentedString& source)657 void HTMLDocumentParser::append(PassRefPtr<StringImpl> inputSource) 658 658 { 659 659 if (isStopped()) … … 665 665 startBackgroundParser(); 666 666 667 HTMLParserThread::shared()->postTask(bind( 668 &BackgroundHTMLParser::append, m_backgroundParser, source.toString().isolatedCopy())); 667 ASSERT(inputSource->hasOneRef()); 668 Closure closure = bind(&BackgroundHTMLParser::append, m_backgroundParser, String(inputSource)); 669 // NOTE: Important that the String temporary is destroyed before we post the task 670 // otherwise the String could call deref() on a StringImpl now owned by the background parser. 671 // We would like to ASSERT(closure.arg3()->hasOneRef()) but sadly the args are private. 672 HTMLParserThread::shared()->postTask(closure); 669 673 return; 670 674 } … … 674 678 // but we need to ensure it isn't deleted yet. 675 679 RefPtr<HTMLDocumentParser> protect(this); 680 String source(inputSource); 676 681 677 682 if (m_preloadScanner) { -
trunk/Source/WebCore/html/parser/HTMLDocumentParser.h
r144407 r144498 99 99 protected: 100 100 virtual void insert(const SegmentedString&) OVERRIDE; 101 virtual void append( const SegmentedString&) OVERRIDE;101 virtual void append(PassRefPtr<StringImpl>) OVERRIDE; 102 102 virtual void finish() OVERRIDE; 103 103 -
trunk/Source/WebCore/html/parser/HTMLViewSourceParser.cpp
r142712 r144498 63 63 } 64 64 65 void HTMLViewSourceParser::append( const SegmentedString&input)65 void HTMLViewSourceParser::append(PassRefPtr<StringImpl> input) 66 66 { 67 m_input.appendToEnd( input);67 m_input.appendToEnd(String(input)); 68 68 pumpTokenizer(); 69 69 } -
trunk/Source/WebCore/html/parser/HTMLViewSourceParser.h
r140036 r144498 60 60 // DocumentParser 61 61 virtual void insert(const SegmentedString&); 62 virtual void append( const SegmentedString&);62 virtual void append(PassRefPtr<StringImpl>); 63 63 virtual void finish(); 64 64 -
trunk/Source/WebCore/html/parser/TextDocumentParser.cpp
r142641 r144498 45 45 } 46 46 47 void TextDocumentParser::append( const SegmentedString&text)47 void TextDocumentParser::append(PassRefPtr<StringImpl> text) 48 48 { 49 49 if (!m_haveInsertedFakePreElement) -
trunk/Source/WebCore/html/parser/TextDocumentParser.h
r95901 r144498 42 42 explicit TextDocumentParser(HTMLDocument*); 43 43 44 virtual void append( const SegmentedString&);44 virtual void append(PassRefPtr<StringImpl>); 45 45 void insertFakePreElement(); 46 46 -
trunk/Source/WebCore/loader/DocumentWriter.cpp
r144000 r144498 81 81 if (DocumentParser* parser = m_frame->document()->parser()) { 82 82 parser->pinToMainThread(); 83 parser->append(source); 83 // Because we're pinned to the main thread we don't need to worry about 84 // passing ownership of the source string. 85 parser->append(source.impl()); 84 86 } 85 87 } -
trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp
r144446 r144498 113 113 } 114 114 115 void XMLDocumentParser::append(const SegmentedString& source) 116 { 115 void XMLDocumentParser::append(PassRefPtr<StringImpl> inputSource) 116 { 117 SegmentedString source(inputSource); 117 118 if (m_sawXSLTransform || !m_sawFirstElement) 118 119 m_originalSourceForTransform.append(source); -
trunk/Source/WebCore/xml/parser/XMLDocumentParser.h
r144446 r144498 108 108 // From DocumentParser 109 109 virtual void insert(const SegmentedString&); 110 virtual void append( const SegmentedString&);110 virtual void append(PassRefPtr<StringImpl>); 111 111 virtual void finish(); 112 112 virtual bool isWaitingForScripts() const; -
trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
r144446 r144498 1445 1445 SegmentedString rest = m_pendingSrc; 1446 1446 m_pendingSrc.clear(); 1447 append(rest); 1447 // There is normally only one string left, so toString() shouldn't copy. 1448 // In any case, the XML parser runs on the main thread and it's OK if 1449 // the passed string has more than one reference. 1450 append(rest.toString().impl()); 1448 1451 1449 1452 // Finally, if finish() has been called and write() didn't result
Note: See TracChangeset
for help on using the changeset viewer.