Changeset 272622 in webkit


Ignore:
Timestamp:
Feb 9, 2021 4:38:15 PM (18 months ago)
Author:
rniwa@webkit.org
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:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r272618 r272622  
     12021-02-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reduce the overhead of HTMLDocumentParser in innerHTML setter
     4        https://bugs.webkit.org/show_bug.cgi?id=221596
     5
     6        Reviewed by Simon Fraser.
     7
     8        This patch reduces the overhead of HTMLDocumentParser for innerHTML.
     9        This appears to be ~0.5% Speedometer progression.
     10
     11        No new tests since there should be no observable behavior differences.
     12
     13        * dom/ScriptableDocumentParser.h:
     14        (WebCore::ScriptableDocumentParser:isWaitingForScripts): Removed since this abstract
     15        virtual function is only used in HTMLDocumentParser.
     16        * html/FTPDirectoryDocument.cpp:
     17        (WebCore::FTPDirectoryDocument::isWaitingForScripts): Removed. There are no scripts
     18        in ftp directory document but there is no need to override it here.
     19        * html/parser/HTMLDocumentParser.cpp:
     20        (WebCore::HTMLDocumentParser::pumpTokenizer): Exit early when we're parsing a fragment
     21        to avoid accessing the scheduler, preloader, and document loader for various things
     22        since they're all irrelevant for fragment parsing.
     23        (WebCore::HTMLDocumentParser::isWaitingForScripts const): Return false immediately when
     24        parsing a document fragment as a fast path.
     25        * html/parser/HTMLDocumentParser.h:
     26        * xml/parser/XMLDocumentParser.cpp:
     27        (WebCore::XMLDocumentParser::isWaitingForScripts const): Removed. Unused.
     28        * xml/parser/XMLDocumentParser.h:
     29
    1302021-02-09  Chris Dumez  <cdumez@apple.com>
    231
  • trunk/Source/WebCore/dom/ScriptableDocumentParser.h

    r212614 r272622  
    3939    virtual bool isExecutingScript() const { return false; }
    4040
    41     virtual bool isWaitingForScripts() const = 0;
    42 
    4341    virtual TextPosition textPosition() const = 0;
    4442
  • trunk/Source/WebCore/html/FTPDirectoryDocument.cpp

    r268114 r272622  
    6262    void finish() override;
    6363
    64     // FIXME: Why do we need this?
    65     bool isWaitingForScripts() const override { return false; }
    66 
    6764    void checkBuffer(int len = 10)
    6865    {
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r268700 r272622  
    327327    ASSERT(refCount() >= 1);
    328328
    329     if (isStopped())
     329    if (isStopped() || isParsingFragment())
    330330        return;
    331331
     
    516516bool HTMLDocumentParser::isWaitingForScripts() const
    517517{
     518    if (isParsingFragment()) {
     519        // HTMLTreeBuilder may have a parser blocking script element but we ignore them during fragment parsing.
     520        ASSERT(!m_scriptRunner || !m_scriptRunner->hasParserBlockingScript());
     521        return false;
     522    }
    518523    // When the TreeBuilder encounters a </script> tag, it returns to the HTMLDocumentParser
    519524    // where the script is transfered from the treebuilder to the script runner.
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.h

    r257763 r272622  
    8383    void prepareToStopParsing() final;
    8484    void stopParsing() final;
    85     bool isWaitingForScripts() const override;
     85    bool isWaitingForScripts() const;
    8686    bool isExecutingScript() const final;
    8787    bool hasScriptsWaitingForStylesheets() const final;
  • trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp

    r262003 r272622  
    245245}
    246246
    247 bool XMLDocumentParser::isWaitingForScripts() const
    248 {
    249     return m_pendingScript;
    250 }
    251 
    252247void XMLDocumentParser::pauseParsing()
    253248{
  • trunk/Source/WebCore/xml/parser/XMLDocumentParser.h

    r252230 r272622  
    9595    void append(RefPtr<StringImpl>&&) final;
    9696    void finish() final;
    97     bool isWaitingForScripts() const final;
    9897    void stopParsing() final;
    9998    void detach() final;
Note: See TracChangeset for help on using the changeset viewer.