Changeset 43363 in webkit for trunk/JavaScriptCore/jit/JIT.cpp


Ignore:
Timestamp:
May 7, 2009, 1:42:59 PM (16 years ago)
Author:
[email protected]
Message:

2009-05-07 Maciej Stachowiak <[email protected]>

Reviewed by Sam Weinig.


  • optimize various cases of branch-fused less


1% speedup on SunSpider overall
13% speedup on math-cordic

  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): op_loop_if_less: Optimize case of constant as first operand, just as case of constant as second operand. op_jnless: Factored out into compileFastArith_op_jnless. (JSC::JIT::privateCompileSlowCases): op_jnless: Factored out into compileFastArithSlow_op_jnless.
  • jit/JIT.h:
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_jnless): Factored out from main compile loop.
  • Generate inline code for comparison of constant immediate int as first operand to another immediate int, as for loop_if_less

(JSC::JIT::compileFastArithSlow_op_jnless):

  • Generate inline code for comparing two floating point numbers.
  • Generate code for both cases of comparing a floating point number to a constant immediate int.
  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): Fix dumping of op_jnless (tangentially related bugfix).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JIT.cpp

    r43362 r43363  
     1
    12/*
    23 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
     
    229230#endif
    230231                addJump(branch32(LessThan, regT0, Imm32(op2imm)), target + 3);
     232            } else if (isOperandConstantImmediateInt(op1)) {
     233                emitGetVirtualRegister(op2, regT1);
     234                emitJumpSlowCaseIfNotImmediateInteger(regT1);
     235#if USE(ALTERNATE_JSIMMEDIATE)
     236                int32_t op1imm = getConstantOperandImmediateInt(op1);
     237#else
     238                int32_t op1imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op1)));
     239#endif
     240                addJump(branch32(GreaterThan, regT1, Imm32(op1imm)), target + 3);
    231241            } else {
    232242                emitGetVirtualRegisters(op1, regT0, op2, regT1);
     
    614624        }
    615625        case op_jnless: {
    616             unsigned op1 = currentInstruction[1].u.operand;
    617             unsigned op2 = currentInstruction[2].u.operand;
    618626            unsigned target = currentInstruction[3].u.operand;
    619             if (isOperandConstantImmediateInt(op2)) {
    620                 emitGetVirtualRegister(op1, regT0);
    621                 emitJumpSlowCaseIfNotImmediateInteger(regT0);
    622 #if USE(ALTERNATE_JSIMMEDIATE)
    623                 int32_t op2imm = getConstantOperandImmediateInt(op2);
    624 #else
    625                 int32_t op2imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op2)));
    626 #endif
    627                 addJump(branch32(GreaterThanOrEqual, regT0, Imm32(op2imm)), target + 3);
    628             } else {
    629                 emitGetVirtualRegisters(op1, regT0, op2, regT1);
    630                 emitJumpSlowCaseIfNotImmediateInteger(regT0);
    631                 emitJumpSlowCaseIfNotImmediateInteger(regT1);
    632                 addJump(branch32(GreaterThanOrEqual, regT0, regT1), target + 3);
    633             }
     627            compileFastArith_op_jnless(currentInstruction[1].u.operand, currentInstruction[2].u.operand, target);
    634628            RECORD_JUMP_TARGET(target + 3);
    635629            NEXT_OPCODE(op_jnless);
     
    12361230        }
    12371231        case op_loop_if_less: {
     1232            unsigned op1 = currentInstruction[1].u.operand;
    12381233            unsigned op2 = currentInstruction[2].u.operand;
    12391234            unsigned target = currentInstruction[3].u.operand;
     
    12421237                emitPutJITStubArg(regT0, 1);
    12431238                emitPutJITStubArgFromVirtualRegister(op2, 2, regT2);
     1239                emitCTICall(JITStubs::cti_op_loop_if_less);
     1240                emitJumpSlowToHot(branchTest32(NonZero, regT0), target + 3);
     1241            } else if (isOperandConstantImmediateInt(op1)) {
     1242                linkSlowCase(iter);
     1243                emitPutJITStubArgFromVirtualRegister(op1, 1, regT1);
     1244                emitPutJITStubArg(regT0, 2);
    12441245                emitCTICall(JITStubs::cti_op_loop_if_less);
    12451246                emitJumpSlowToHot(branchTest32(NonZero, regT0), target + 3);
     
    13231324        }
    13241325        case op_jnless: {
    1325             unsigned op2 = currentInstruction[2].u.operand;
    1326             unsigned target = currentInstruction[3].u.operand;
    1327             if (isOperandConstantImmediateInt(op2)) {
    1328                 linkSlowCase(iter);
    1329                 emitPutJITStubArg(regT0, 1);
    1330                 emitPutJITStubArgFromVirtualRegister(currentInstruction[2].u.operand, 2, regT2);
    1331                 emitCTICall(JITStubs::cti_op_jless);
    1332                 emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
    1333             } else {
    1334                 linkSlowCase(iter);
    1335                 linkSlowCase(iter);
    1336                 emitPutJITStubArg(regT0, 1);
    1337                 emitPutJITStubArg(regT1, 2);
    1338                 emitCTICall(JITStubs::cti_op_jless);
    1339                 emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
    1340             }
     1326            compileFastArithSlow_op_jnless(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, iter);
    13411327            NEXT_OPCODE(op_jnless);
    13421328        }
Note: See TracChangeset for help on using the changeset viewer.