Changeset 143845 in webkit


Ignore:
Timestamp:
Feb 23, 2013 10:37:50 AM (11 years ago)
Author:
abarth@webkit.org
Message:

Threaded HTML parser should pass fast/parser/parser-yield-timing.html
https://bugs.webkit.org/show_bug.cgi?id=110647

Reviewed by Eric Seidel.

Previously, the threaded HTML parser would run for an arbitrary amount
of time without yielding after speculation succeeded. This might be the
cause of the good DOMContentLoaded numbers.

Note: This patch also demonstrates that the ParseHTML_max numbers
aren't correct currently because they're measuring the interior of this
loop instead of all the time spent in the loop. We should move the
instrumentation in a followup patch.

  • html/parser/HTMLDocumentParser.cpp:

(WebCore::HTMLDocumentParser::resumeParsingAfterYield):
(WebCore::HTMLDocumentParser::pumpPendingSpeculations):
(WebCore):
(WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):

  • html/parser/HTMLDocumentParser.h:

(HTMLDocumentParser):

  • html/parser/HTMLParserScheduler.cpp:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143844 r143845  
     12013-02-23  Adam Barth  <abarth@webkit.org>
     2
     3        Threaded HTML parser should pass fast/parser/parser-yield-timing.html
     4        https://bugs.webkit.org/show_bug.cgi?id=110647
     5
     6        Reviewed by Eric Seidel.
     7
     8        Previously, the threaded HTML parser would run for an arbitrary amount
     9        of time without yielding after speculation succeeded. This might be the
     10        cause of the good DOMContentLoaded numbers.
     11
     12        Note: This patch also demonstrates that the ParseHTML_max numbers
     13        aren't correct currently because they're measuring the interior of this
     14        loop instead of all the time spent in the loop. We should move the
     15        instrumentation in a followup patch.
     16
     17         * html/parser/HTMLDocumentParser.cpp:
     18        (WebCore::HTMLDocumentParser::resumeParsingAfterYield):
     19        (WebCore::HTMLDocumentParser::pumpPendingSpeculations):
     20        (WebCore):
     21        (WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):
     22        * html/parser/HTMLDocumentParser.h:
     23        (HTMLDocumentParser):
     24        * html/parser/HTMLParserScheduler.cpp:
     25
    1262013-02-23  Martin Robinson  <mrobinson@igalia.com>
    227
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r143828 r143845  
    241241void HTMLDocumentParser::resumeParsingAfterYield()
    242242{
    243     ASSERT(!m_haveBackgroundParser);
    244 
    245243    // pumpTokenizer can cause this parser to be detached from the Document,
    246244    // but we need to ensure it isn't deleted yet.
    247245    RefPtr<HTMLDocumentParser> protect(this);
     246
     247#if ENABLE(THREADED_HTML_PARSER)
     248    if (m_haveBackgroundParser) {
     249        pumpPendingSpeculations();
     250        return;
     251    }
     252#endif
    248253
    249254    // We should never be here unless we can pump immediately.  Call pumpTokenizer()
     
    356361void HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk> chunk)
    357362{
     363    // ASSERT that this object is both attached to the Document and protected.
     364    ASSERT(refCount() >= 2);
    358365    ASSERT(shouldUseThreading());
    359366
     
    393400
    394401    checkForSpeculationFailure();
     402}
     403
     404void HTMLDocumentParser::pumpPendingSpeculations()
     405{
     406    // FIXME: Share this constant with the parser scheduler.
     407    const double parserTimeLimit = 0.500;
     408
     409    // ASSERT that this object is both attached to the Document and protected.
     410    ASSERT(refCount() >= 2);
     411
     412    // FIXME: Pass in current input length.
     413    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), 0, lineNumber().zeroBasedInt());
     414
     415    double startTime = currentTime();
     416
     417    while (!m_speculations.isEmpty()) {
     418        processParsedChunkFromBackgroundParser(m_speculations.takeFirst());
     419
     420        if (isWaitingForScripts() || isStopped())
     421            break;
     422
     423        if (currentTime() - startTime > parserTimeLimit && !m_speculations.isEmpty()) {
     424            m_parserScheduler->scheduleForResume();
     425            break;
     426        }
     427    }
     428
     429    InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
    395430}
    396431
     
    796831        // but we need to ensure it isn't deleted yet.
    797832        RefPtr<HTMLDocumentParser> protect(this);
    798 
    799         // FIXME: Pass in current input length.
    800         InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), 0, lineNumber().zeroBasedInt());
    801 
    802         while (!m_speculations.isEmpty()) {
    803             processParsedChunkFromBackgroundParser(m_speculations.takeFirst());
    804             if (isWaitingForScripts() || isStopped())
    805                 break;
    806         }
    807 
    808         InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
    809 
     833        pumpPendingSpeculations();
    810834        return;
    811835    }
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.h

    r143797 r143845  
    143143    void didFailSpeculation(PassOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>);
    144144    void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>);
     145    void pumpPendingSpeculations();
    145146#endif
    146147
  • trunk/Source/WebCore/html/parser/HTMLParserScheduler.cpp

    r142378 r143845  
    3838
    3939// defaultParserTimeLimit is the seconds the parser will run in one write() call
    40 // before yielding.  Inline <script> execution can cause it to excede the limit.
     40// before yielding. Inline <script> execution can cause it to exceed the limit.
    4141// FIXME: We would like this value to be 0.2.
    4242static const double defaultParserTimeLimit = 0.500;
Note: See TracChangeset for help on using the changeset viewer.