Title: [144407] trunk/Source/WebCore
- Revision
- 144407
- Author
- [email protected]
- Date
- 2013-02-28 18:12:54 -0800 (Thu, 28 Feb 2013)
Log Message
The threaded HTML parser shouldn't need to invalidate the speculation buffer on every document.write
https://bugs.webkit.org/show_bug.cgi?id=111130
Reviewed by Eric Seidel.
Previously, the threaded HTML parser always invalidated its speculation
buffer when it received a document.write. That means we performed
poorly on web sites that contained document.write calls early in the
page.
This patch teaches the HTMLDocumentParser that we don't need to discard
the speculation buffer in the common case of starting and ending in the
DataState.
* html/parser/BackgroundHTMLParser.cpp:
(WebCore::BackgroundHTMLParser::sendTokensToMainThread):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::checkForSpeculationFailure):
(WebCore::HTMLDocumentParser::didFailSpeculation):
* html/parser/HTMLDocumentParser.h:
(WebCore):
(ParsedChunk):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (144406 => 144407)
--- trunk/Source/WebCore/ChangeLog 2013-03-01 02:11:42 UTC (rev 144406)
+++ trunk/Source/WebCore/ChangeLog 2013-03-01 02:12:54 UTC (rev 144407)
@@ -1,3 +1,28 @@
+2013-02-28 Adam Barth <[email protected]>
+
+ The threaded HTML parser shouldn't need to invalidate the speculation buffer on every document.write
+ https://bugs.webkit.org/show_bug.cgi?id=111130
+
+ Reviewed by Eric Seidel.
+
+ Previously, the threaded HTML parser always invalidated its speculation
+ buffer when it received a document.write. That means we performed
+ poorly on web sites that contained document.write calls early in the
+ page.
+
+ This patch teaches the HTMLDocumentParser that we don't need to discard
+ the speculation buffer in the common case of starting and ending in the
+ DataState.
+
+ * html/parser/BackgroundHTMLParser.cpp:
+ (WebCore::BackgroundHTMLParser::sendTokensToMainThread):
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::checkForSpeculationFailure):
+ (WebCore::HTMLDocumentParser::didFailSpeculation):
+ * html/parser/HTMLDocumentParser.h:
+ (WebCore):
+ (ParsedChunk):
+
2013-02-28 Eberhard Graether <[email protected]>
WebInspector: Switch hide element shortcut in ElementsPanel to use a selector
Modified: trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp (144406 => 144407)
--- trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp 2013-03-01 02:11:42 UTC (rev 144406)
+++ trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp 2013-03-01 02:12:54 UTC (rev 144407)
@@ -279,6 +279,7 @@
OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentParser::ParsedChunk);
chunk->tokens = m_pendingTokens.release();
chunk->preloads.swap(m_pendingPreloads);
+ chunk->tokenizerState = m_tokenizer->state();
chunk->inputCheckpoint = m_input.createCheckpoint();
chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint();
callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser, m_parser, chunk.release()));
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (144406 => 144407)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-03-01 02:11:42 UTC (rev 144406)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-03-01 02:12:54 UTC (rev 144407)
@@ -332,16 +332,24 @@
{
if (!m_tokenizer)
return;
- // FIXME: If the tokenizer is in the same state as when we started this function,
- // then we haven't necessarily failed our speculation.
+ if (!m_currentChunk)
+ return;
+ // Currently we're only smart enough to reuse the speculation buffer if the tokenizer
+ // both starts and ends in the DataState. That state is simplest because the HTMLToken
+ // is always in the Uninitialized state. We should consider whether we can reuse the
+ // speculation buffer in other states, but we'd likely need to do something more
+ // sophisticated with the HTMLToken.
+ if (m_currentChunk->tokenizerState == HTMLTokenizer::DataState && m_tokenizer->state() == HTMLTokenizer::DataState && m_input.current().isEmpty()) {
+ ASSERT(m_token->isUninitialized());
+ m_tokenizer.clear();
+ m_token.clear();
+ return;
+ }
didFailSpeculation(m_token.release(), m_tokenizer.release());
}
void HTMLDocumentParser::didFailSpeculation(PassOwnPtr<HTMLToken> token, PassOwnPtr<HTMLTokenizer> tokenizer)
{
- if (!m_currentChunk)
- return;
-
m_weakFactory.revokeAll();
m_speculations.clear();
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (144406 => 144407)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-03-01 02:11:42 UTC (rev 144406)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-03-01 02:12:54 UTC (rev 144407)
@@ -36,6 +36,7 @@
#include "HTMLScriptRunnerHost.h"
#include "HTMLSourceTracker.h"
#include "HTMLToken.h"
+#include "HTMLTokenizer.h"
#include "ScriptableDocumentParser.h"
#include "SegmentedString.h"
#include "Timer.h"
@@ -54,7 +55,6 @@
class DocumentFragment;
class HTMLDocument;
class HTMLParserScheduler;
-class HTMLTokenizer;
class HTMLScriptRunner;
class HTMLTreeBuilder;
class HTMLResourcePreloader;
@@ -89,6 +89,7 @@
struct ParsedChunk {
OwnPtr<CompactHTMLTokenStream> tokens;
PreloadRequestStream preloads;
+ HTMLTokenizer::State tokenizerState;
HTMLInputCheckpoint inputCheckpoint;
TokenPreloadScannerCheckpoint preloadScannerCheckpoint;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes