Title: [272958] branches/safari-611-branch/Source/WebCore
Revision
272958
Author
repst...@apple.com
Date
2021-02-16 17:18:57 -0800 (Tue, 16 Feb 2021)

Log Message

Cherry-pick r272622. rdar://problem/74410599

    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:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272622 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (272957 => 272958)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-17 01:18:35 UTC (rev 272957)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-17 01:18:57 UTC (rev 272958)
@@ -1,5 +1,68 @@
 2021-02-16  Ruben Turcios  <rubent...@apple.com>
 
+        Cherry-pick r272622. rdar://problem/74410599
+
+    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:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-09  Ryosuke Niwa  <rn...@webkit.org>
+
+            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-16  Ruben Turcios  <rubent...@apple.com>
+
         Cherry-pick r272602. rdar://problem/74409444
 
     [LFC][IFC] Disable BIDI processing for modern line layout

Modified: branches/safari-611-branch/Source/WebCore/dom/ScriptableDocumentParser.h (272957 => 272958)


--- branches/safari-611-branch/Source/WebCore/dom/ScriptableDocumentParser.h	2021-02-17 01:18:35 UTC (rev 272957)
+++ branches/safari-611-branch/Source/WebCore/dom/ScriptableDocumentParser.h	2021-02-17 01:18:57 UTC (rev 272958)
@@ -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: branches/safari-611-branch/Source/WebCore/html/FTPDirectoryDocument.cpp (272957 => 272958)


--- branches/safari-611-branch/Source/WebCore/html/FTPDirectoryDocument.cpp	2021-02-17 01:18:35 UTC (rev 272957)
+++ branches/safari-611-branch/Source/WebCore/html/FTPDirectoryDocument.cpp	2021-02-17 01:18:57 UTC (rev 272958)
@@ -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: branches/safari-611-branch/Source/WebCore/html/parser/HTMLDocumentParser.cpp (272957 => 272958)


--- branches/safari-611-branch/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2021-02-17 01:18:35 UTC (rev 272957)
+++ branches/safari-611-branch/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2021-02-17 01:18:57 UTC (rev 272958)
@@ -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: branches/safari-611-branch/Source/WebCore/html/parser/HTMLDocumentParser.h (272957 => 272958)


--- branches/safari-611-branch/Source/WebCore/html/parser/HTMLDocumentParser.h	2021-02-17 01:18:35 UTC (rev 272957)
+++ branches/safari-611-branch/Source/WebCore/html/parser/HTMLDocumentParser.h	2021-02-17 01:18:57 UTC (rev 272958)
@@ -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: branches/safari-611-branch/Source/WebCore/xml/parser/XMLDocumentParser.cpp (272957 => 272958)


--- branches/safari-611-branch/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2021-02-17 01:18:35 UTC (rev 272957)
+++ branches/safari-611-branch/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2021-02-17 01:18:57 UTC (rev 272958)
@@ -244,11 +244,6 @@
         resumeParsing();
 }
 
-bool XMLDocumentParser::isWaitingForScripts() const
-{
-    return m_pendingScript;
-}
-
 void XMLDocumentParser::pauseParsing()
 {
     ASSERT(!m_parserPaused);

Modified: branches/safari-611-branch/Source/WebCore/xml/parser/XMLDocumentParser.h (272957 => 272958)


--- branches/safari-611-branch/Source/WebCore/xml/parser/XMLDocumentParser.h	2021-02-17 01:18:35 UTC (rev 272957)
+++ branches/safari-611-branch/Source/WebCore/xml/parser/XMLDocumentParser.h	2021-02-17 01:18:57 UTC (rev 272958)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to