Changeset 37405 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


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/VM/CTI.cpp

    r37388 r37405  
    17681768        }
    17691769        case op_to_jsnumber: {
    1770             emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx);
    1771             emitCall(i, Machine::cti_op_to_jsnumber);
     1770            emitGetArg(instruction[i + 2].u.operand, X86::eax);
     1771           
     1772            m_jit.testl_i32r(JSImmediate::TagBitTypeInteger, X86::eax);
     1773            X86Assembler::JmpSrc wasImmediate = m_jit.emitUnlinkedJnz();
     1774
     1775            m_jit.movl_mr(OBJECT_OFFSET(JSCell, m_structureID), X86::eax, X86::ecx);
     1776            m_jit.cmpl_i32m(NumberType, OBJECT_OFFSET(StructureID, m_typeInfo.m_type), X86::ecx);
     1777           
     1778            m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i));
     1779           
     1780            m_jit.link(wasImmediate, m_jit.label());
     1781
    17721782            emitPutResult(instruction[i + 1].u.operand);
    17731783            i += 3;
     
    25192529            break;
    25202530        }
     2531        case op_to_jsnumber: {
     2532            m_jit.link(iter->from, m_jit.label());
     2533
     2534            emitPutArg(X86::eax, 0);
     2535            emitCall(i, Machine::cti_op_to_jsnumber);
     2536
     2537            emitPutResult(instruction[i + 1].u.operand);
     2538            i += 3;
     2539            break;
     2540        }
    25212541
    25222542        default:
Note: See TracChangeset for help on using the changeset viewer.