Changeset 139950 in webkit


Ignore:
Timestamp:
Jan 16, 2013 6:55:35 PM (11 years ago)
Author:
abarth@webkit.org
Message:

Introduce BackgroundHTMLParser for parsing HTML on a background thread
https://bugs.webkit.org/show_bug.cgi?id=107083

Reviewed by Eric Seidel.

This patch contains a basic version of an HTML parser that runs on a
background thread. The parser passes the majority of the tests in
fast/parser and a large number of the subtests in html5lib.

Notably absent from this early version of the parser is speculation
(which will eventually replace preload scanning) and atomization (which
we suspect will be important for performance). Our plan is to introduce
those elements in subsequent patches.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • html/parser/BackgroundHTMLParser.cpp: Added.

(WebCore):
(WebCore::checkThatTokensAreSafeToSendToAnotherThread):
(WebCore::parserMap):
(WebCore::ParserMap::backgroundParsers):
(WebCore::ParserMap::mainThreadParsers):
(WebCore::BackgroundHTMLParser::BackgroundHTMLParser):
(WebCore::BackgroundHTMLParser::append):
(WebCore::BackgroundHTMLParser::continueParsing):
(WebCore::BackgroundHTMLParser::finish):
(WebCore::BackgroundHTMLParser::pumpTokenizer):
(TokenDelivery):
(WebCore::TokenDelivery::execute):
(WebCore::BackgroundHTMLParser::sendTokensToMainThread):
(WebCore::BackgroundHTMLParser::createPartial):
(WebCore::BackgroundHTMLParser::stopPartial):
(WebCore::BackgroundHTMLParser::appendPartial):
(WebCore::BackgroundHTMLParser::continuePartial):
(WebCore::BackgroundHTMLParser::finishPartial):

  • html/parser/BackgroundHTMLParser.h: Added.

(WebCore):
(BackgroundHTMLParser):
(WebCore::BackgroundHTMLParser::create):
(ParserMap):
(WebCore::ParserMap::identifierForParser):

  • html/parser/HTMLDocumentParser.cpp:

(WebCore):
(WebCore::HTMLDocumentParser::didReceiveTokensFromBackgroundParser):

  • html/parser/HTMLDocumentParser.h:

(WebCore):
(HTMLDocumentParser):

Location:
trunk/Source/WebCore
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r139945 r139950  
    15271527    html/canvas/WebGLVertexArrayObjectOES.cpp
    15281528
     1529    html/parser/BackgroundHTMLParser.cpp
    15291530    html/parser/CSSPreloadScanner.cpp
    15301531    html/parser/CompactHTMLToken.cpp
  • trunk/Source/WebCore/ChangeLog

    r139946 r139950  
     12013-01-16  Adam Barth  <abarth@webkit.org>
     2
     3        Introduce BackgroundHTMLParser for parsing HTML on a background thread
     4        https://bugs.webkit.org/show_bug.cgi?id=107083
     5
     6        Reviewed by Eric Seidel.
     7
     8        This patch contains a basic version of an HTML parser that runs on a
     9        background thread. The parser passes the majority of the tests in
     10        fast/parser and a large number of the subtests in html5lib.
     11
     12        Notably absent from this early version of the parser is speculation
     13        (which will eventually replace preload scanning) and atomization (which
     14        we suspect will be important for performance). Our plan is to introduce
     15        those elements in subsequent patches.
     16
     17        * CMakeLists.txt:
     18        * GNUmakefile.list.am:
     19        * Target.pri:
     20        * WebCore.gypi:
     21        * WebCore.vcproj/WebCore.vcproj:
     22        * WebCore.xcodeproj/project.pbxproj:
     23        * html/parser/BackgroundHTMLParser.cpp: Added.
     24        (WebCore):
     25        (WebCore::checkThatTokensAreSafeToSendToAnotherThread):
     26        (WebCore::parserMap):
     27        (WebCore::ParserMap::backgroundParsers):
     28        (WebCore::ParserMap::mainThreadParsers):
     29        (WebCore::BackgroundHTMLParser::BackgroundHTMLParser):
     30        (WebCore::BackgroundHTMLParser::append):
     31        (WebCore::BackgroundHTMLParser::continueParsing):
     32        (WebCore::BackgroundHTMLParser::finish):
     33        (WebCore::BackgroundHTMLParser::pumpTokenizer):
     34        (TokenDelivery):
     35        (WebCore::TokenDelivery::execute):
     36        (WebCore::BackgroundHTMLParser::sendTokensToMainThread):
     37        (WebCore::BackgroundHTMLParser::createPartial):
     38        (WebCore::BackgroundHTMLParser::stopPartial):
     39        (WebCore::BackgroundHTMLParser::appendPartial):
     40        (WebCore::BackgroundHTMLParser::continuePartial):
     41        (WebCore::BackgroundHTMLParser::finishPartial):
     42        * html/parser/BackgroundHTMLParser.h: Added.
     43        (WebCore):
     44        (BackgroundHTMLParser):
     45        (WebCore::BackgroundHTMLParser::create):
     46        (ParserMap):
     47        (WebCore::ParserMap::identifierForParser):
     48        * html/parser/HTMLDocumentParser.cpp:
     49        (WebCore):
     50        (WebCore::HTMLDocumentParser::didReceiveTokensFromBackgroundParser):
     51        * html/parser/HTMLDocumentParser.h:
     52        (WebCore):
     53        (HTMLDocumentParser):
     54
    1552013-01-16  Donghyun Kim  <dhkim715@hotmail.com>
    256
  • trunk/Source/WebCore/GNUmakefile.list.am

    r139945 r139950  
    35313531        Source/WebCore/html/NumberInputType.cpp \
    35323532        Source/WebCore/html/NumberInputType.h \
     3533        Source/WebCore/html/parser/BackgroundHTMLParser.cpp \
     3534        Source/WebCore/html/parser/BackgroundHTMLParser.h \
    35333535        Source/WebCore/html/parser/CSSPreloadScanner.cpp \
    35343536        Source/WebCore/html/parser/CSSPreloadScanner.h \
  • trunk/Source/WebCore/Target.pri

    r139945 r139950  
    708708    html/canvas/CanvasStyle.cpp \
    709709    html/canvas/DataView.cpp \
     710    html/parser/BackgroundHTMLParser.cpp \
    710711    html/parser/CSSPreloadScanner.cpp \
    711712    html/parser/CompactHTMLToken.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r139945 r139950  
    33343334            'html/canvas/WebGLVertexArrayObjectOES.cpp',
    33353335            'html/canvas/WebGLVertexArrayObjectOES.h',
     3336            'html/parser/BackgroundHTMLParser.cpp',
     3337            'html/parser/BackgroundHTMLParser.h',
    33363338            'html/parser/CSSPreloadScanner.cpp',
    33373339            'html/parser/CSSPreloadScanner.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r139945 r139950  
    6453864538                                >
    6453964539                                <File
     64540                                        RelativePath="..\html\parser\BackgroundHTMLParser.cpp"
     64541                                        >
     64542                                </File>
     64543                                <File
     64544                                        RelativePath="..\html\parser\BackgroundHTMLParser.h"
     64545                                        >
     64546                                </File>
     64547                                <File
    6454064548                                        RelativePath="..\html\parser\CSSPreloadScanner.cpp"
    6454164549                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r139945 r139950  
    36253625                977B3862122883E900B81FF8 /* CSSPreloadScanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 977B3849122883E900B81FF8 /* CSSPreloadScanner.cpp */; };
    36263626                977B3863122883E900B81FF8 /* CSSPreloadScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B384A122883E900B81FF8 /* CSSPreloadScanner.h */; };
    3627                 977B3862122883E900B81FF9 /* CompactHTMLToken.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 977B3849122883E900B81FF9 /* CompactHTMLToken.cpp */; };
    3628                 977B3863122883E900B81FF9 /* CompactHTMLToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B384A122883E900B81FF9 /* CompactHTMLToken.h */; };
    36293627                977B3864122883E900B81FF8 /* HTMLConstructionSite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 977B384B122883E900B81FF8 /* HTMLConstructionSite.cpp */; };
    36303628                977B3865122883E900B81FF8 /* HTMLConstructionSite.h in Headers */ = {isa = PBXBuildFile; fileRef = 977B384C122883E900B81FF8 /* HTMLConstructionSite.h */; };
     
    36623660                978D07CC145A102E0096908D /* XPathException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 978D07CB145A102E0096908D /* XPathException.cpp */; };
    36633661                978D07CE145A10370096908D /* XMLHttpRequestException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 978D07CD145A10370096908D /* XMLHttpRequestException.cpp */; };
     3662                979DC03616A7992A00807794 /* CompactHTMLToken.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 979DC03316A7992100807794 /* CompactHTMLToken.cpp */; };
     3663                979DC03716A7992E00807794 /* CompactHTMLToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 979DC03416A7992100807794 /* CompactHTMLToken.h */; };
     3664                979DC03816A7993300807794 /* BackgroundHTMLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 979DC03216A7992100807794 /* BackgroundHTMLParser.h */; };
     3665                979DC03916A7993900807794 /* BackgroundHTMLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 979DC03116A7992100807794 /* BackgroundHTMLParser.cpp */; };
    36643666                979F43D31075E44A0000F83B /* NavigationScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 979F43D11075E44A0000F83B /* NavigationScheduler.cpp */; };
    36653667                979F43D41075E44A0000F83B /* NavigationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 979F43D21075E44A0000F83B /* NavigationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1100311005                977B3849122883E900B81FF8 /* CSSPreloadScanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSSPreloadScanner.cpp; path = parser/CSSPreloadScanner.cpp; sourceTree = "<group>"; };
    1100411006                977B384A122883E900B81FF8 /* CSSPreloadScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSPreloadScanner.h; path = parser/CSSPreloadScanner.h; sourceTree = "<group>"; };
    11005                 977B3849122883E900B81FF9 /* CompactHTMLToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompactHTMLToken.cpp; path = parser/CompactHTMLToken.cpp; sourceTree = "<group>"; };
    11006                 977B384A122883E900B81FF9 /* CompactHTMLToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactHTMLToken.h; path = parser/CompactHTMLToken.h; sourceTree = "<group>"; };
    1100711007                977B384B122883E900B81FF8 /* HTMLConstructionSite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLConstructionSite.cpp; path = parser/HTMLConstructionSite.cpp; sourceTree = "<group>"; };
    1100811008                977B384C122883E900B81FF8 /* HTMLConstructionSite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLConstructionSite.h; path = parser/HTMLConstructionSite.h; sourceTree = "<group>"; };
     
    1104211042                978D07CB145A102E0096908D /* XPathException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathException.cpp; sourceTree = "<group>"; };
    1104311043                978D07CD145A10370096908D /* XMLHttpRequestException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestException.cpp; sourceTree = "<group>"; };
     11044                979DC03116A7992100807794 /* BackgroundHTMLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BackgroundHTMLParser.cpp; path = parser/BackgroundHTMLParser.cpp; sourceTree = "<group>"; };
     11045                979DC03216A7992100807794 /* BackgroundHTMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BackgroundHTMLParser.h; path = parser/BackgroundHTMLParser.h; sourceTree = "<group>"; };
     11046                979DC03316A7992100807794 /* CompactHTMLToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompactHTMLToken.cpp; path = parser/CompactHTMLToken.cpp; sourceTree = "<group>"; };
     11047                979DC03416A7992100807794 /* CompactHTMLToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactHTMLToken.h; path = parser/CompactHTMLToken.h; sourceTree = "<group>"; };
    1104411048                979F43D11075E44A0000F83B /* NavigationScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationScheduler.cpp; sourceTree = "<group>"; };
    1104511049                979F43D21075E44A0000F83B /* NavigationScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationScheduler.h; sourceTree = "<group>"; };
     
    1853418538                        isa = PBXGroup;
    1853518539                        children = (
     18540                                979DC03116A7992100807794 /* BackgroundHTMLParser.cpp */,
     18541                                979DC03216A7992100807794 /* BackgroundHTMLParser.h */,
     18542                                979DC03316A7992100807794 /* CompactHTMLToken.cpp */,
     18543                                979DC03416A7992100807794 /* CompactHTMLToken.h */,
    1853618544                                977B3849122883E900B81FF8 /* CSSPreloadScanner.cpp */,
    1853718545                                977B384A122883E900B81FF8 /* CSSPreloadScanner.h */,
     
    2297922987                                51741D0F0B07259A00ED442C /* BackForwardList.h in Headers */,
    2298022988                                BCA8CA6011E4E6D100812FB7 /* BackForwardListImpl.h in Headers */,
     22989                                979DC03816A7993300807794 /* BackgroundHTMLParser.h in Headers */,
    2298122990                                BC124EE80C2641CD009E2349 /* BarInfo.h in Headers */,
    2298222991                                379E61CA126CA5C400B63E8D /* BaseButtonInputType.h in Headers */,
     
    2309523104                                BCDD454E1236C95C009A7985 /* ColumnInfo.h in Headers */,
    2309623105                                6550B6A2099DF0270090D781 /* Comment.h in Headers */,
     23106                                979DC03716A7992E00807794 /* CompactHTMLToken.h in Headers */,
    2309723107                                37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */,
    2309823108                                4A6A0C5C15232F2400B09C6E /* ComposedShadowTreeWalker.h in Headers */,
     
    2665626666                                BCA8C81F11E3D36900812FB7 /* BackForwardController.cpp in Sources */,
    2665726667                                BCA8CA5F11E4E6D100812FB7 /* BackForwardListImpl.cpp in Sources */,
     26668                                979DC03916A7993900807794 /* BackgroundHTMLParser.cpp in Sources */,
    2665826669                                BC124EE70C2641CD009E2349 /* BarInfo.cpp in Sources */,
    2665926670                                379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */,
     
    2674826759                                B27535770B053814002CE64F /* ColorMac.mm in Sources */,
    2674926760                                6550B6A1099DF0270090D781 /* Comment.cpp in Sources */,
     26761                                979DC03616A7992A00807794 /* CompactHTMLToken.cpp in Sources */,
    2675026762                                37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */,
    2675126763                                37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */,
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r139523 r139950  
    2727#include "HTMLDocumentParser.h"
    2828
     29#include "CompactHTMLToken.h"
    2930#include "ContentSecurityPolicy.h"
    3031#include "DocumentFragment.h"
     
    243244}
    244245
     246#if ENABLE(THREADED_HTML_PARSER)
     247
     248void HTMLDocumentParser::didReceiveTokensFromBackgroundParser(const Vector<CompactHTMLToken>& tokens)
     249{
     250    // FIXME: Actually consume the tokens.
     251}
     252
     253#endif // ENABLE(THREADED_HTML_PARSER)
     254
    245255void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
    246256{
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.h

    r139523 r139950  
    4242namespace WebCore {
    4343
     44class CompactHTMLToken;
    4445class Document;
    4546class DocumentFragment;
     
    7778    virtual void suspendScheduledTasks();
    7879    virtual void resumeScheduledTasks();
     80
     81#if ENABLE(THREADED_HTML_PARSER)
     82    void didReceiveTokensFromBackgroundParser(const Vector<CompactHTMLToken>&);
     83#endif
    7984
    8085protected:
Note: See TracChangeset for help on using the changeset viewer.