Changeset 95877 in webkit for trunk/Source/JavaScriptCore/parser


Ignore:
Timestamp:
Sep 23, 2011, 3:59:18 PM (14 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: Strict mode does not work in non-trivial nested functions.
https://bugs.webkit.org/show_bug.cgi?id=68740

Reviewed by Oliver Hunt.

Function-info caching does not preserve all state that it should.

  • parser/JSParser.cpp:

(JSC::JSParser::Scope::saveFunctionInfo):
(JSC::JSParser::Scope::restoreFunctionInfo):
(JSC::JSParser::parseFunctionInfo):

  • parser/SourceProviderCacheItem.h:

LayoutTests: [email protected]>

Strict mode does not work in non-trivial nested functions.
https://bugs.webkit.org/show_bug.cgi?id=68740

Reviewed by Oliver Hunt.

Function-info caching does not preserve all state that it should.

  • fast/js/nested-functions-expected.txt: Added.
  • fast/js/nested-functions.html: Added.
  • fast/js/script-tests/nested-functions.js: Added.

(runTests.test1):
(runTests.test2):
(runTests.test3):
(runTests):

Location:
trunk/Source/JavaScriptCore/parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/JSParser.cpp

    r90535 r95877  
    753753            ASSERT(m_isFunction);
    754754            info->usesEval = m_usesEval;
     755            info->strictMode = m_strictMode;
     756            info->needsFullActivation = m_needsFullActivation;
    755757            copyCapturedVariablesToVector(m_writtenVariables, info->writtenVariables);
    756758            copyCapturedVariablesToVector(m_usedVariables, info->usedVariables);
     
    761763            ASSERT(m_isFunction);
    762764            m_usesEval = info->usesEval;
     765            m_strictMode = info->strictMode;
     766            m_needsFullActivation = info->needsFullActivation;
    763767            unsigned size = info->usedVariables.size();
    764768            for (unsigned i = 0; i < size; ++i)
     
    16091613    bodyStartLine = tokenLine();
    16101614
     1615    // If we know about this function already, we can use the cached info and skip the parser to the end of the function.
    16111616    if (const SourceProviderCacheItem* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) {
    1612         // If we know about this function already, we can use the cached info and skip the parser to the end of the function.
    1613         body = context.createFunctionBody(strictMode());
     1617        // If we're in a strict context, the cached function info must say it was strict too.
     1618        ASSERT(!strictMode() || cachedInfo->strictMode);
     1619        body = context.createFunctionBody(cachedInfo->strictMode);
    16141620
    16151621        functionScope->restoreFunctionInfo(cachedInfo);
  • trunk/Source/JavaScriptCore/parser/SourceProviderCacheItem.h

    r76611 r95877  
    6060    int closeBracePos;
    6161    bool usesEval;
     62    bool strictMode;
     63    bool needsFullActivation;
    6264    Vector<RefPtr<StringImpl> > usedVariables;
    6365    Vector<RefPtr<StringImpl> > writtenVariables;
Note: See TracChangeset for help on using the changeset viewer.