2008-10-01 Cameron Zwarich <zwarich@apple.com>
authorcwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Oct 2008 22:18:50 +0000 (22:18 +0000)
committercwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Oct 2008 22:18:50 +0000 (22:18 +0000)
commitd082d3f5e71936a945410471ccd7d98e5957a0d1
tree9096c2940ab516747de628570269a9669d4f1e2e
parent2f02912fd10252a3aa9b5107cce046f7f26d5894
2008-10-01  Cameron Zwarich  <zwarich@apple.com>

        Reviewed by Darin Adler.

        Bug 21123: using "arguments" in a function should not force creation of an activation object
        <https://bugs.webkit.org/show_bug.cgi?id=21123>

        Make the 'arguments' object not require a JSActivation. We store the
        'arguments' object in the OptionalCalleeArguments call frame slot. We
        need to be able to get the original 'arguments' object to tear it off
        when returning from a function, but 'arguments' may be assigned to in a
        number of ways.

        Therefore, we use the OptionalCalleeArguments slot when we want to get
        the original activation or we know that 'arguments' was not assigned a
        different value. When 'arguments' may have been assigned a new value,
        we use a new local variable that is initialized with 'arguments'. Since
        a function parameter named 'arguments' may overwrite the value of
        'arguments', we also need to be careful to look up 'arguments' in the
        symbol table, so we get the parameter named 'arguments' instead of the
        local variable that we have added for holding the 'arguments' object.

        This is a 19.1% win on the V8 Raytrace benchmark using the SunSpider
        harness, and a 20.7% win using the V8 harness. This amounts to a 6.5%
        total speedup on the V8 benchmark suite using the V8 harness.

        JavaScriptCore:

        * VM/CTI.cpp:
        (JSC::CTI::privateCompileMainPass):
        * VM/CodeBlock.h:
        * VM/CodeGenerator.cpp:
        (JSC::CodeGenerator::CodeGenerator):
        * VM/Machine.cpp:
        (JSC::Machine::unwindCallFrame):
        (JSC::Machine::privateExecute):
        (JSC::Machine::retrieveArguments):
        (JSC::Machine::cti_op_init_arguments):
        (JSC::Machine::cti_op_ret_activation_arguments):
        * VM/Machine.h:
        * VM/RegisterFile.h:
        (JSC::RegisterFile::):
        * kjs/Arguments.cpp:
        (JSC::Arguments::mark):
        (JSC::Arguments::fillArgList):
        (JSC::Arguments::getOwnPropertySlot):
        (JSC::Arguments::put):
        * kjs/Arguments.h:
        (JSC::Arguments::setRegisters):
        (JSC::Arguments::init):
        (JSC::Arguments::Arguments):
        (JSC::Arguments::copyRegisters):
        (JSC::JSActivation::copyRegisters):
        * kjs/JSActivation.cpp:
        (JSC::JSActivation::argumentsGetter):
        * kjs/JSActivation.h:
        (JSC::JSActivation::JSActivationData::JSActivationData):
        * kjs/grammar.y:
        * kjs/nodes.h:
        (JSC::ScopeNode::setUsesArguments):
        * masm/X86Assembler.h:
        (JSC::X86Assembler::):
        (JSC::X86Assembler::orl_mr):

        LayoutTests:

        * fast/js/arguments-expected.txt:
        * fast/js/function-dot-arguments-expected.txt:
        * fast/js/resources/arguments.js:
        * fast/js/resources/function-dot-arguments.js:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37160 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/VM/CTI.cpp
JavaScriptCore/VM/CodeBlock.h
JavaScriptCore/VM/CodeGenerator.cpp
JavaScriptCore/VM/Machine.cpp
JavaScriptCore/VM/Machine.h
JavaScriptCore/VM/RegisterFile.h
JavaScriptCore/kjs/Arguments.cpp
JavaScriptCore/kjs/Arguments.h
JavaScriptCore/kjs/JSActivation.cpp
JavaScriptCore/kjs/JSActivation.h
JavaScriptCore/kjs/grammar.y
JavaScriptCore/kjs/nodes.h
JavaScriptCore/masm/X86Assembler.h
LayoutTests/ChangeLog
LayoutTests/fast/js/arguments-expected.txt
LayoutTests/fast/js/function-dot-arguments-expected.txt
LayoutTests/fast/js/resources/arguments.js
LayoutTests/fast/js/resources/function-dot-arguments.js