2008-10-07 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Oct 2008 03:46:34 +0000 (03:46 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Oct 2008 03:46:34 +0000 (03:46 +0000)
commit25e6865a7d47e151d3fb4c67d70d2e6633f48690
treece4014048f91dd59cb806f9dcdd7b62e95266b15
parent62ffd0bb958a84f47a13b1a0c02642cb5fc027e2
2008-10-07  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Mark Rowe.

        - optimize away multiplication by constant 1.0

        2.3% speedup on v8 RayTrace benchmark

        Apparently it's not uncommon for JavaScript code to multiply by
        constant 1.0 in the mistaken belief that this converts integer to
        floating point and that there is any operational difference.

        * VM/CTI.cpp:
        (JSC::CTI::privateCompileMainPass): Optimize to_jsnumber for
        case where parameter is already number.
        (JSC::CTI::privateCompileSlowCases): ditto
        * VM/Machine.cpp:
        (JSC::Machine::privateExecute): ditto
        * kjs/grammar.y:
        (makeMultNode): Transform as follows:
        +FOO * BAR ==> FOO * BAR
        FOO * +BAR ==> FOO * BAR
        FOO * 1 ==> +FOO
        1 * FOO ==> +FOO
        (makeDivNode): Transform as follows:
        +FOO / BAR ==> FOO / BAR
        FOO / +BAR ==> FOO / BAR
        (makeSubNode): Transform as follows:
        +FOO - BAR ==> FOO - BAR
        FOO - +BAR ==> FOO - BAR
        * kjs/nodes.h:
        (JSC::ExpressionNode::stripUnaryPlus): Helper for above
        grammar.y changes
        (JSC::UnaryPlusNode::stripUnaryPlus): ditto

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37405 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JavaScriptCore/ChangeLog
JavaScriptCore/VM/CTI.cpp
JavaScriptCore/VM/Machine.cpp
JavaScriptCore/kjs/grammar.y
JavaScriptCore/kjs/nodes.h