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


Ignore:
Timestamp:
Oct 8, 2008, 3:53:13 AM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Oliver Hunt.

Re-landing the following fix with the crashing bug in it fixed (r37405):


  • 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

    r37408 r37417  
    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            emitJumpSlowCaseIfNotJSCell(X86::eax, i);
     1776
     1777            m_jit.movl_mr(OBJECT_OFFSET(JSCell, m_structureID), X86::eax, X86::ecx);
     1778            m_jit.cmpl_i32m(NumberType, OBJECT_OFFSET(StructureID, m_typeInfo.m_type), X86::ecx);
     1779           
     1780            m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i));
     1781           
     1782            m_jit.link(wasImmediate, m_jit.label());
     1783
    17721784            emitPutResult(instruction[i + 1].u.operand);
    17731785            i += 3;
     
    25192531            break;
    25202532        }
     2533        case op_to_jsnumber: {
     2534            m_jit.link(iter->from, m_jit.label());
     2535            m_jit.link(iter->from, m_jit.label());
     2536
     2537            emitPutArg(X86::eax, 0);
     2538            emitCall(i, Machine::cti_op_to_jsnumber);
     2539
     2540            emitPutResult(instruction[i + 1].u.operand);
     2541            i += 3;
     2542            break;
     2543        }
    25212544
    25222545        default:
Note: See TracChangeset for help on using the changeset viewer.