Ignore:
Timestamp:
Aug 6, 2013, 2:20:10 PM (12 years ago)
Author:
[email protected]
Message:

Delay Arguments creation in strict mode
https://bugs.webkit.org/show_bug.cgi?id=119505

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Make use of the write tracking performed by the parser to
allow us to know if we're modifying the parameters to a function.
Then use that information to make strict mode function opt out
of eager arguments creation.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::createArgumentsIfNecessary):
(JSC::BytecodeGenerator::emitReturn):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::shouldTearOffArgumentsEagerly):

  • parser/Nodes.h:

(JSC::ScopeNode::modifiesParameter):

  • parser/Parser.cpp:

(JSC::::parseInner):

  • parser/Parser.h:

(JSC::Scope::declareParameter):
(JSC::Scope::getCapturedVariables):
(JSC::Parser::declareWrite):

  • parser/ParserModes.h:

LayoutTests:

Add performance testcase for lazy creation of arguments in strict mode

  • fast/js/regress/delay-tear-off-arguments-strictmode-expected.txt: Added.
  • fast/js/regress/delay-tear-off-arguments-strictmode.html: Added.
  • fast/js/regress/script-tests/delay-tear-off-arguments-strictmode.js: Added.

(bar):

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r153477 r153763  
    239239        emitInitLazyRegister(unmodifiedArgumentsRegister);
    240240       
    241         if (m_codeBlock->isStrictMode()) {
     241        if (shouldTearOffArgumentsEagerly()) {
    242242            emitOpcode(op_create_arguments);
    243243            instructions().append(argumentsRegister->index());
     
    269269    }
    270270
    271     if (capturesAnyArgumentByName && !codeBlock->isStrictMode()) {
     271    if (capturesAnyArgumentByName && !shouldTearOffArgumentsEagerly()) {
    272272        size_t parameterCount = m_symbolTable->parameterCount();
    273273        OwnArrayPtr<SlowArgument> slowArguments = adoptArrayPtr(new SlowArgument[parameterCount]);
     
    15601560        return;
    15611561
    1562     // If we're in strict mode we tear off the arguments on function
    1563     // entry, so there's no need to check if we need to create them
    1564     // now
    1565     if (m_codeBlock->isStrictMode())
     1562    if (shouldTearOffArgumentsEagerly())
    15661563        return;
    15671564
     
    17501747    }
    17511748
    1752     if (m_codeBlock->usesArguments() && m_codeBlock->numParameters() != 1 && !m_codeBlock->isStrictMode()) {
     1749    if (m_codeBlock->usesArguments() && m_codeBlock->numParameters() != 1 && !isStrictMode()) {
    17531750        emitOpcode(op_tear_off_arguments);
    17541751        instructions().append(m_codeBlock->argumentsRegister());
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r153477 r153763  
    555555        }
    556556
     557        bool shouldTearOffArgumentsEagerly()
     558        {
     559            return m_codeType == FunctionCode && isStrictMode() && m_scopeNode->modifiesParameter();
     560        }
     561
    557562        RegisterID* emitThrowExpressionTooDeepException();
    558563
Note: See TracChangeset for help on using the changeset viewer.