Title: [272622] trunk/Source/WebCore
- Revision
- 272622
- Author
- [email protected]
- Date
- 2021-02-09 16:38:15 -0800 (Tue, 09 Feb 2021)
Log Message
Reduce the overhead of HTMLDocumentParser in innerHTML setter
https://bugs.webkit.org/show_bug.cgi?id=221596
Reviewed by Simon Fraser.
This patch reduces the overhead of HTMLDocumentParser for innerHTML.
This appears to be ~0.5% Speedometer progression.
No new tests since there should be no observable behavior differences.
* dom/ScriptableDocumentParser.h:
(WebCore::ScriptableDocumentParser:isWaitingForScripts): Removed since this abstract
virtual function is only used in HTMLDocumentParser.
* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocument::isWaitingForScripts): Removed. There are no scripts
in ftp directory document but there is no need to override it here.
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::pumpTokenizer): Exit early when we're parsing a fragment
to avoid accessing the scheduler, preloader, and document loader for various things
since they're all irrelevant for fragment parsing.
(WebCore::HTMLDocumentParser::isWaitingForScripts const): Return false immediately when
parsing a document fragment as a fast path.
* html/parser/HTMLDocumentParser.h:
* xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::isWaitingForScripts const): Removed. Unused.
* xml/parser/XMLDocumentParser.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (272621 => 272622)
--- trunk/Source/WebCore/ChangeLog 2021-02-10 00:34:26 UTC (rev 272621)
+++ trunk/Source/WebCore/ChangeLog 2021-02-10 00:38:15 UTC (rev 272622)
@@ -1,3 +1,32 @@
+2021-02-09 Ryosuke Niwa <[email protected]>
+
+ Reduce the overhead of HTMLDocumentParser in innerHTML setter
+ https://bugs.webkit.org/show_bug.cgi?id=221596
+
+ Reviewed by Simon Fraser.
+
+ This patch reduces the overhead of HTMLDocumentParser for innerHTML.
+ This appears to be ~0.5% Speedometer progression.
+
+ No new tests since there should be no observable behavior differences.
+
+ * dom/ScriptableDocumentParser.h:
+ (WebCore::ScriptableDocumentParser:isWaitingForScripts): Removed since this abstract
+ virtual function is only used in HTMLDocumentParser.
+ * html/FTPDirectoryDocument.cpp:
+ (WebCore::FTPDirectoryDocument::isWaitingForScripts): Removed. There are no scripts
+ in ftp directory document but there is no need to override it here.
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::pumpTokenizer): Exit early when we're parsing a fragment
+ to avoid accessing the scheduler, preloader, and document loader for various things
+ since they're all irrelevant for fragment parsing.
+ (WebCore::HTMLDocumentParser::isWaitingForScripts const): Return false immediately when
+ parsing a document fragment as a fast path.
+ * html/parser/HTMLDocumentParser.h:
+ * xml/parser/XMLDocumentParser.cpp:
+ (WebCore::XMLDocumentParser::isWaitingForScripts const): Removed. Unused.
+ * xml/parser/XMLDocumentParser.h:
+
2021-02-09 Chris Dumez <[email protected]>
Rename SecurityOrigin's canAccess() to isSameOriginDomain() to match HTML specification naming
Modified: trunk/Source/WebCore/dom/ScriptableDocumentParser.h (272621 => 272622)
--- trunk/Source/WebCore/dom/ScriptableDocumentParser.h 2021-02-10 00:34:26 UTC (rev 272621)
+++ trunk/Source/WebCore/dom/ScriptableDocumentParser.h 2021-02-10 00:38:15 UTC (rev 272622)
@@ -38,8 +38,6 @@
// _javascript_ document.open() call right now, or it should be ignored.
virtual bool isExecutingScript() const { return false; }
- virtual bool isWaitingForScripts() const = 0;
-
virtual TextPosition textPosition() const = 0;
virtual bool hasScriptsWaitingForStylesheets() const { return false; }
Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (272621 => 272622)
--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2021-02-10 00:34:26 UTC (rev 272621)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp 2021-02-10 00:38:15 UTC (rev 272622)
@@ -61,9 +61,6 @@
void append(RefPtr<StringImpl>&&) override;
void finish() override;
- // FIXME: Why do we need this?
- bool isWaitingForScripts() const override { return false; }
-
void checkBuffer(int len = 10)
{
if ((m_dest - m_buffer) > m_size - len) {
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (272621 => 272622)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2021-02-10 00:34:26 UTC (rev 272621)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2021-02-10 00:38:15 UTC (rev 272622)
@@ -326,7 +326,7 @@
// function should be holding a RefPtr to this to ensure we weren't deleted.
ASSERT(refCount() >= 1);
- if (isStopped())
+ if (isStopped() || isParsingFragment())
return;
if (shouldResume)
@@ -515,6 +515,11 @@
bool HTMLDocumentParser::isWaitingForScripts() const
{
+ if (isParsingFragment()) {
+ // HTMLTreeBuilder may have a parser blocking script element but we ignore them during fragment parsing.
+ ASSERT(!m_scriptRunner || !m_scriptRunner->hasParserBlockingScript());
+ return false;
+ }
// When the TreeBuilder encounters a </script> tag, it returns to the HTMLDocumentParser
// where the script is transfered from the treebuilder to the script runner.
// The script runner will hold the script until its loaded and run. During
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (272621 => 272622)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2021-02-10 00:34:26 UTC (rev 272621)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2021-02-10 00:38:15 UTC (rev 272622)
@@ -82,7 +82,7 @@
bool processingData() const final;
void prepareToStopParsing() final;
void stopParsing() final;
- bool isWaitingForScripts() const override;
+ bool isWaitingForScripts() const;
bool isExecutingScript() const final;
bool hasScriptsWaitingForStylesheets() const final;
void executeScriptsWaitingForStylesheets() final;
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp (272621 => 272622)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp 2021-02-10 00:34:26 UTC (rev 272621)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp 2021-02-10 00:38:15 UTC (rev 272622)
@@ -244,11 +244,6 @@
resumeParsing();
}
-bool XMLDocumentParser::isWaitingForScripts() const
-{
- return m_pendingScript;
-}
-
void XMLDocumentParser::pauseParsing()
{
ASSERT(!m_parserPaused);
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.h (272621 => 272622)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.h 2021-02-10 00:34:26 UTC (rev 272621)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.h 2021-02-10 00:38:15 UTC (rev 272622)
@@ -94,7 +94,6 @@
void insert(SegmentedString&&) final;
void append(RefPtr<StringImpl>&&) final;
void finish() final;
- bool isWaitingForScripts() const final;
void stopParsing() final;
void detach() final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes