Changeset 74428 in webkit for trunk/JavaScriptCore/parser/Nodes.h


Ignore:
Timestamp:
Dec 21, 2010, 2:54:14 PM (14 years ago)
Author:
[email protected]
Message:

2010-12-21 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

ASSERTION FAILED: base->index() == m_codeBlock->argumentsRegister() while loading taobao.com
https://bugs.webkit.org/show_bug.cgi?id=49006

This problem was caused by having a parameter named 'arguments'.
The fix is to treat parameters named 'arguments' as shadowing
the actual arguments property, and so logically turn the function
into one that doesn't "use" arguments.

This required a bit of fiddling in the parser to ensure we correctly
propagate the 'feature' of shadowing is set correctly.

  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::createArgumentsIfNecessary): Change assertion to an early return as we may now reference a property named 'arguments' without being in a function that has the ArgumentsFeature
  • parser/JSParser.cpp: (JSC::JSParser::Scope::Scope): (JSC::JSParser::Scope::declareParameter): (JSC::JSParser::Scope::shadowsArguments): (JSC::JSParser::parseProgram): (JSC::JSParser::parseFormalParameters): (JSC::JSParser::parseFunctionInfo):
  • parser/Nodes.h: (JSC::ScopeNode::usesArguments):

2010-12-21 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

ASSERTION FAILED: base->index() == m_codeBlock->argumentsRegister() while loading taobao.com
https://bugs.webkit.org/show_bug.cgi?id=49006

Add new tests to cover the cases of a parameter named arguments being used.
Also correct a couple of existing (incorrect) tests.

  • fast/js/arguments-expected.txt:
  • fast/js/script-tests/arguments.js: (argumentsVarUndefined): (argumentsConstUndefined): (shadowedArgumentsLength): (shadowedArgumentsCallee): (shadowedArgumentsIndex):
File:
1 edited

Legend:

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

    r71878 r74428  
    5959    const CodeFeatures ThisFeature = 1 << 6;
    6060    const CodeFeatures StrictModeFeature = 1 << 7;
    61     const CodeFeatures AllFeatures = EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature;
     61    const CodeFeatures ShadowsArgumentsFeature = 1 << 8;
     62   
     63   
     64    const CodeFeatures AllFeatures = EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature;
    6265
    6366    enum Operator {
     
    14101413
    14111414        bool usesEval() const { return m_features & EvalFeature; }
    1412         bool usesArguments() const { return m_features & ArgumentsFeature; }
     1415        bool usesArguments() const { return (m_features & ArgumentsFeature) && !(m_features & ShadowsArgumentsFeature); }
    14131416        bool isStrictMode() const { return m_features & StrictModeFeature; }
    14141417        void setUsesArguments() { m_features |= ArgumentsFeature; }
Note: See TracChangeset for help on using the changeset viewer.