Changeset 37405 in webkit for trunk/JavaScriptCore/kjs/nodes.h


Ignore:
Timestamp:
Oct 7, 2008, 8:46:34 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-07 Maciej Stachowiak <[email protected]>

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.h

    r37326 r37405  
    227227        virtual bool isDotAccessorNode() const JSC_FAST_CALL { return false; }
    228228
     229        virtual ExpressionNode* stripUnaryPlus() { return this; }
     230
    229231        ResultType resultDescriptor() const JSC_FAST_CALL { return m_resultDesc; }
    230232
     
    11791181        {
    11801182        }
     1183
     1184        virtual ExpressionNode* stripUnaryPlus() { return m_expr.get(); }
    11811185
    11821186        virtual OpcodeID opcode() const JSC_FAST_CALL { return op_to_jsnumber; }
Note: See TracChangeset for help on using the changeset viewer.