Changeset 37789 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Oct 22, 2008, 2:06:30 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-22 Cameron Zwarich <[email protected]>

Reviewed by Geoff Garen.

Bug 21803: Fuse op_jfalse with op_eq_null and op_neq_null
<https://bugs.webkit.org/show_bug.cgi?id=21803>

Fuse op_jfalse with op_eq_null and op_neq_null to make the new opcodes
op_jeq_null and op_jneq_null.

This is a 2.6% speedup on the V8 Raytrace benchmark, and strangely also
a 4.7% speedup on the V8 Arguments benchmark, even though it uses
neither of the two new opcodes.

  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass):
  • VM/CodeBlock.cpp: (JSC::CodeBlock::dump):
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitJumpIfTrue): (JSC::CodeGenerator::emitJumpIfFalse):
  • VM/Machine.cpp: (JSC::Machine::privateExecute):
  • VM/Opcode.h:
Location:
trunk/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r37783 r37789  
     12008-10-22  Cameron Zwarich  <[email protected]>
     2
     3        Reviewed by Geoff Garen.
     4
     5        Bug 21803: Fuse op_jfalse with op_eq_null and op_neq_null
     6        <https://bugs.webkit.org/show_bug.cgi?id=21803>
     7
     8        Fuse op_jfalse with op_eq_null and op_neq_null to make the new opcodes
     9        op_jeq_null and op_jneq_null.
     10
     11        This is a 2.6% speedup on the V8 Raytrace benchmark, and strangely also
     12        a 4.7% speedup on the V8 Arguments benchmark, even though it uses
     13        neither of the two new opcodes.
     14
     15        * VM/CTI.cpp:
     16        (JSC::CTI::privateCompileMainPass):
     17        * VM/CodeBlock.cpp:
     18        (JSC::CodeBlock::dump):
     19        * VM/CodeGenerator.cpp:
     20        (JSC::CodeGenerator::emitJumpIfTrue):
     21        (JSC::CodeGenerator::emitJumpIfFalse):
     22        * VM/Machine.cpp:
     23        (JSC::Machine::privateExecute):
     24        * VM/Opcode.h:
     25
    1262008-10-22  Darin Fisher  <[email protected]>
    227
  • trunk/JavaScriptCore/VM/CTI.cpp

    r37730 r37789  
    15751575            break;
    15761576        };
     1577        case op_jeq_null: {
     1578            unsigned src = instruction[i + 1].u.operand;
     1579            unsigned target = instruction[i + 2].u.operand;
     1580
     1581            emitGetArg(src, X86::eax);
     1582            m_jit.testl_i32r(JSImmediate::TagMask, X86::eax);
     1583            X86Assembler::JmpSrc isImmediate = m_jit.emitUnlinkedJnz();
     1584
     1585            m_jit.movl_mr(OBJECT_OFFSET(JSCell, m_structureID), X86::eax, X86::ecx);
     1586            m_jit.testl_i32m(MasqueradesAsUndefined, OBJECT_OFFSET(StructureID, m_typeInfo.m_flags), X86::ecx);
     1587            m_jit.setnz_r(X86::eax);
     1588
     1589            X86Assembler::JmpSrc wasNotImmediate = m_jit.emitUnlinkedJmp();
     1590
     1591            m_jit.link(isImmediate, m_jit.label());
     1592
     1593            m_jit.movl_i32r(~JSImmediate::ExtendedTagBitUndefined, X86::ecx);
     1594            m_jit.andl_rr(X86::eax, X86::ecx);
     1595            m_jit.cmpl_i32r(JSImmediate::FullTagTypeNull, X86::ecx);
     1596            m_jit.sete_r(X86::eax);
     1597
     1598            m_jit.link(wasNotImmediate, m_jit.label());
     1599
     1600            m_jit.movzbl_rr(X86::eax, X86::eax);
     1601            m_jit.cmpl_i32r(0, X86::eax);
     1602            m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJnz(), i + 2 + target));           
     1603
     1604            i += 3;
     1605            break;
     1606        };
     1607        case op_jneq_null: {
     1608            unsigned src = instruction[i + 1].u.operand;
     1609            unsigned target = instruction[i + 2].u.operand;
     1610
     1611            emitGetArg(src, X86::eax);
     1612            m_jit.testl_i32r(JSImmediate::TagMask, X86::eax);
     1613            X86Assembler::JmpSrc isImmediate = m_jit.emitUnlinkedJnz();
     1614
     1615            m_jit.movl_mr(OBJECT_OFFSET(JSCell, m_structureID), X86::eax, X86::ecx);
     1616            m_jit.testl_i32m(MasqueradesAsUndefined, OBJECT_OFFSET(StructureID, m_typeInfo.m_flags), X86::ecx);
     1617            m_jit.setz_r(X86::eax);
     1618
     1619            X86Assembler::JmpSrc wasNotImmediate = m_jit.emitUnlinkedJmp();
     1620
     1621            m_jit.link(isImmediate, m_jit.label());
     1622
     1623            m_jit.movl_i32r(~JSImmediate::ExtendedTagBitUndefined, X86::ecx);
     1624            m_jit.andl_rr(X86::eax, X86::ecx);
     1625            m_jit.cmpl_i32r(JSImmediate::FullTagTypeNull, X86::ecx);
     1626            m_jit.setne_r(X86::eax);
     1627
     1628            m_jit.link(wasNotImmediate, m_jit.label());
     1629
     1630            m_jit.movzbl_rr(X86::eax, X86::eax);
     1631            m_jit.cmpl_i32r(0, X86::eax);
     1632            m_jmpTable.append(JmpTable(m_jit.emitUnlinkedJnz(), i + 2 + target));           
     1633
     1634            i += 3;
     1635            break;
     1636        }
    15771637        case op_post_inc: {
    15781638            int srcDst = instruction[i + 2].u.operand;
  • trunk/JavaScriptCore/VM/CodeBlock.cpp

    r37730 r37789  
    738738            break;
    739739        }
     740        case op_jeq_null: {
     741            printConditionalJump(begin, it, location, "jeq_null");
     742            break;
     743        }
     744        case op_jneq_null: {
     745            printConditionalJump(begin, it, location, "jneq_null");
     746            break;
     747        }
    740748        case op_jnless: {
    741749            int r0 = (++it)->u.operand;
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r37755 r37789  
    547547            return target;
    548548        }
     549    } else if (m_lastOpcodeID == op_eq_null && target->isForwardLabel()) {
     550        int dstIndex;
     551        int srcIndex;
     552
     553        retrieveLastUnaryOp(dstIndex, srcIndex);
     554
     555        if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) {
     556            rewindUnaryOp();
     557            emitOpcode(op_jeq_null);
     558            instructions().append(srcIndex);
     559            instructions().append(target->offsetFrom(instructions().size()));
     560            return target;
     561        }
     562    } else if (m_lastOpcodeID == op_neq_null && target->isForwardLabel()) {
     563        int dstIndex;
     564        int srcIndex;
     565
     566        retrieveLastUnaryOp(dstIndex, srcIndex);
     567
     568        if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) {
     569            rewindUnaryOp();
     570            emitOpcode(op_jneq_null);
     571            instructions().append(srcIndex);
     572            instructions().append(target->offsetFrom(instructions().size()));
     573            return target;
     574        }
    549575    }
    550576
     
    586612            instructions().append(target->offsetFrom(instructions().size()));
    587613            return target;
    588         }       
     614        }
     615    } else if (m_lastOpcodeID == op_eq_null) {
     616        int dstIndex;
     617        int srcIndex;
     618
     619        retrieveLastUnaryOp(dstIndex, srcIndex);
     620
     621        if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) {
     622            rewindUnaryOp();
     623            emitOpcode(op_jneq_null);
     624            instructions().append(srcIndex);
     625            instructions().append(target->offsetFrom(instructions().size()));
     626            return target;
     627        }
     628    } else if (m_lastOpcodeID == op_neq_null) {
     629        int dstIndex;
     630        int srcIndex;
     631
     632        retrieveLastUnaryOp(dstIndex, srcIndex);
     633
     634        if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) {
     635            rewindUnaryOp();
     636            emitOpcode(op_jeq_null);
     637            instructions().append(srcIndex);
     638            instructions().append(target->offsetFrom(instructions().size()));
     639            return target;
     640        }
    589641    }
    590642
  • trunk/JavaScriptCore/VM/Machine.cpp

    r37781 r37789  
    30333033        NEXT_OPCODE;
    30343034    }
     3035    BEGIN_OPCODE(op_jeq_null) {
     3036        /* jeq_null src(r) target(offset)
     3037
     3038           Jumps to offset target from the current instruction, if and
     3039           only if register src is null.
     3040        */
     3041        int src = (++vPC)->u.operand;
     3042        int target = (++vPC)->u.operand;
     3043        JSValuePtr srcValue = callFrame[src].jsValue(callFrame);
     3044
     3045        if (srcValue->isUndefinedOrNull() || (!JSImmediate::isImmediate(srcValue) && srcValue->asCell()->structureID()->typeInfo().masqueradesAsUndefined())) {
     3046            vPC += target;
     3047            NEXT_OPCODE;
     3048        }
     3049
     3050        ++vPC;
     3051        NEXT_OPCODE;
     3052    }
     3053    BEGIN_OPCODE(op_jneq_null) {
     3054        /* jneq_null src(r) target(offset)
     3055
     3056           Jumps to offset target from the current instruction, if and
     3057           only if register src is not null.
     3058        */
     3059        int src = (++vPC)->u.operand;
     3060        int target = (++vPC)->u.operand;
     3061        JSValuePtr srcValue = callFrame[src].jsValue(callFrame);
     3062
     3063        if (!srcValue->isUndefinedOrNull() || (!JSImmediate::isImmediate(srcValue) && !srcValue->asCell()->structureID()->typeInfo().masqueradesAsUndefined())) {
     3064            vPC += target;
     3065            NEXT_OPCODE;
     3066        }
     3067
     3068        ++vPC;
     3069        NEXT_OPCODE;
     3070    }
    30353071    BEGIN_OPCODE(op_loop_if_less) {
    30363072        /* loop_if_less src1(r) src2(r) target(offset)
  • trunk/JavaScriptCore/VM/Opcode.h

    r37730 r37789  
    124124        macro(op_jtrue) \
    125125        macro(op_jfalse) \
     126        macro(op_jeq_null) \
     127        macro(op_jneq_null) \
    126128        macro(op_jnless) \
    127129        macro(op_jmp_scopes) \
Note: See TracChangeset for help on using the changeset viewer.