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


Ignore:
Timestamp:
Oct 10, 2014, 12:03:20 PM (11 years ago)
Author:
[email protected]
Message:

Various arguments optimisations in codegen fail to account for arguments being in lexical record
https://bugs.webkit.org/show_bug.cgi?id=137617

Reviewed by Michael Saboff.

Rework the way we track |arguments| references so that we don't try
to use the |arguments| reference on the stack if it's not safe.

To do this without nuking performance it was necessary to update
the parser to track modification of the |arguments| reference
itself.

  • bytecode/CodeBlock.cpp:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::willResolveToArguments):
(JSC::BytecodeGenerator::uncheckedLocalArgumentsRegister):
(JSC::BytecodeGenerator::emitCall):
(JSC::BytecodeGenerator::emitConstruct):
(JSC::BytecodeGenerator::emitEnumeration):
(JSC::BytecodeGenerator::uncheckedRegisterForArguments): Deleted.

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::hasSafeLocalArgumentsRegister):

  • bytecompiler/NodesCodegen.cpp:

(JSC::BracketAccessorNode::emitBytecode):
(JSC::DotAccessorNode::emitBytecode):
(JSC::getArgumentByVal):
(JSC::CallFunctionCallDotNode::emitBytecode):
(JSC::ApplyFunctionCallDotNode::emitBytecode):
(JSC::ArrayPatternNode::emitDirectBinding):

  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::Frame::existingArguments):

  • parser/Nodes.h:

(JSC::ScopeNode::modifiesArguments):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseInner):

  • parser/Parser.h:

(JSC::Scope::getCapturedVariables):

  • parser/ParserModes.h:
Location:
trunk/Source/JavaScriptCore/parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r172717 r174606  
    14411441        bool usesArguments() const { return (m_features & ArgumentsFeature) && !(m_features & ShadowsArgumentsFeature); }
    14421442        bool modifiesParameter() const { return m_features & ModifiedParameterFeature; }
     1443        bool modifiesArguments() const { return m_features & (EvalFeature | ModifiedArgumentsFeature); }
    14431444        bool isStrictMode() const { return m_features & StrictModeFeature; }
    14441445        void setUsesArguments() { m_features |= ArgumentsFeature; }
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r173026 r174606  
    272272    IdentifierSet capturedVariables;
    273273    bool modifiedParameter = false;
    274     scope->getCapturedVariables(capturedVariables, modifiedParameter);
     274    bool modifiedArguments = false;
     275    scope->getCapturedVariables(capturedVariables, modifiedParameter, modifiedArguments);
    275276   
    276277    CodeFeatures features = context.features();
     
    281282    if (modifiedParameter)
    282283        features |= ModifiedParameterFeature;
    283    
     284    if (modifiedArguments)
     285        features |= ModifiedArgumentsFeature;
    284286    Vector<RefPtr<StringImpl>> closedVariables;
    285287    if (m_parsingBuiltin) {
     
    293295            if (scope->hasDeclaredParameter(Identifier(m_vm, variable.get())))
    294296                continue;
     297
     298            if (variable == m_vm->propertyNames->arguments.impl())
     299                continue;
     300
    295301            closedVariables.append(variable);
    296302        }
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r173026 r174606  
    280280    }
    281281
    282     void getCapturedVariables(IdentifierSet& capturedVariables, bool& modifiedParameter)
     282    void getCapturedVariables(IdentifierSet& capturedVariables, bool& modifiedParameter, bool& modifiedArguments)
    283283    {
    284284        if (m_needsFullActivation || m_usesEval) {
     
    293293        }
    294294        modifiedParameter = false;
     295        if (shadowsArguments())
     296            modifiedArguments = true;
    295297        if (m_declaredParameters.size()) {
    296298            IdentifierSet::iterator end = m_writtenVariables.end();
    297299            for (IdentifierSet::iterator ptr = m_writtenVariables.begin(); ptr != end; ++ptr) {
     300                if (*ptr == m_vm->propertyNames->arguments.impl())
     301                    modifiedArguments = true;
    298302                if (!m_declaredParameters.contains(*ptr))
    299303                    continue;
  • trunk/Source/JavaScriptCore/parser/ParserModes.h

    r167313 r174606  
    7676const CodeFeatures ShadowsArgumentsFeature = 1 << 6;
    7777const CodeFeatures ModifiedParameterFeature = 1 << 7;
     78const CodeFeatures ModifiedArgumentsFeature = 1 << 8;
    7879
    7980const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature;
Note: See TracChangeset for help on using the changeset viewer.