Ignore:
Timestamp:
Sep 10, 2012, 2:49:25 PM (13 years ago)
Author:
[email protected]
Message:

DFG misses arguments tear-off for function.arguments if 'arguments' is used
https://bugs.webkit.org/show_bug.cgi?id=96227

Reviewed by Gavin Barraclough.

Source/JavaScriptCore:

We've decided not to allow function.arguments to alias the local
'arguments' object, or a local var or function named 'arguments'.
Aliasing complicates the implementation (cf, this bug) and can produce
surprising behavior for web programmers.

Eliminating the aliasing has the side-effect of fixing this bug.

The compatibilty story: function.arguments is deprecated, was never
specified, and throws an exception in strict mode, so we expect it to
disappear over time. Firefox does not alias to 'arguments'; Chrome
does, but not if you use eval or with; IE does; Safari did.

  • dfg/DFGByteCodeParser.cpp: Noticed a little cleanup while verifying

this code. Use the CodeBlock method for better encapsulation.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::retrieveArgumentsFromVMCode): Behavior change: don't
alias.

  • tests/mozilla/js1_4/Functions/function-001.js:

(TestFunction_4): Updated test expectations for changed behavior.

LayoutTests:

New test, and updated expectations.

  • fast/js/script-tests/function-dot-arguments.js:
  • fast/js/function-dot-arguments-expected.txt: Updated for new behavior.
  • fast/js/dfg-tear-off-function-dot-arguments.html:
  • fast/js/script-tests/dfg-tear-off-function-dot-arguments.js: Added. New test for bug cited here.
  • fast/js/function-dot-arguments-identity-expected.txt:
  • fast/js/function-dot-arguments-identity.html: Added. New test for new behavior.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r128096 r128111  
    51065106        return jsNull();
    51075107
    5108     CodeBlock* codeBlock = functionCallFrame->someCodeBlockForPossiblyInlinedCode();
    5109     if (codeBlock->usesArguments()) {
    5110         ASSERT(codeBlock->codeType() == FunctionCode);
    5111         int argumentsRegister = codeBlock->argumentsRegister();
    5112         int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister);
    5113         if (JSValue arguments = functionCallFrame->uncheckedR(argumentsRegister).jsValue())
    5114             return arguments;
    5115         JSValue arguments = JSValue(Arguments::create(callFrame->globalData(), functionCallFrame));
    5116         functionCallFrame->r(argumentsRegister) = arguments;
    5117         functionCallFrame->r(realArgumentsRegister) = arguments;
    5118         return arguments;
    5119     }
    5120 
    51215108    Arguments* arguments = Arguments::create(functionCallFrame->globalData(), functionCallFrame);
    51225109    arguments->tearOff(functionCallFrame);
Note: See TracChangeset for help on using the changeset viewer.