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


Ignore:
Timestamp:
Jan 1, 2009, 7:06:10 PM (16 years ago)
Author:
[email protected]
Message:

2009-01-01 Gavin Barraclough <[email protected]>

Reviewed by Darin Adler.

Allow 32-bit integers to be stored in JSImmediates, on x64-bit.
Presently the top 32-bits of a 64-bit JSImmediate serve as a sign extension of a 31-bit
int stored in the low word (shifted left by one, to make room for a tag). In the new
format, the top 31-bits serve as a sign extension of a 32-bit int, still shifted left by
one.

The new behavior is enabled using a flag in Platform.h, 'WTF_USE_ALTERNATE_JSIMMEDIATE'.
When this is set the constants defining the range of ints allowed to be stored as
JSImmediate values is extended. The code in JSImmediate.h can safely operate on either
format. This patch updates the JIT so that it can also operate with the new format.

~2% progression on x86-64, with & without the JIT, on sunspider & v8 tests.

  • assembler/MacroAssembler.h: (JSC::MacroAssembler::addPtr): (JSC::MacroAssembler::orPtr): (JSC::MacroAssembler::or32): (JSC::MacroAssembler::rshiftPtr): (JSC::MacroAssembler::rshift32): (JSC::MacroAssembler::subPtr): (JSC::MacroAssembler::xorPtr): (JSC::MacroAssembler::xor32): (JSC::MacroAssembler::move): (JSC::MacroAssembler::compareImm64ForBranch): (JSC::MacroAssembler::compareImm64ForBranchEquality): (JSC::MacroAssembler::jePtr): (JSC::MacroAssembler::jgePtr): (JSC::MacroAssembler::jlPtr): (JSC::MacroAssembler::jlePtr): (JSC::MacroAssembler::jnePtr): (JSC::MacroAssembler::jnzSubPtr): (JSC::MacroAssembler::joAddPtr): (JSC::MacroAssembler::jzSubPtr):
  • assembler/X86Assembler.h: (JSC::X86Assembler::addq_rr): (JSC::X86Assembler::orq_ir): (JSC::X86Assembler::subq_ir): (JSC::X86Assembler::xorq_rr): (JSC::X86Assembler::sarq_CLr): (JSC::X86Assembler::sarq_i8r): (JSC::X86Assembler::cmpq_ir):
  • jit/JIT.cpp: (JSC::JIT::compileOpStrictEq): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h:
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_lshift): (JSC::JIT::compileFastArithSlow_op_lshift): (JSC::JIT::compileFastArith_op_rshift): (JSC::JIT::compileFastArithSlow_op_rshift): (JSC::JIT::compileFastArith_op_bitand): (JSC::JIT::compileFastArithSlow_op_bitand): (JSC::JIT::compileFastArith_op_mod): (JSC::JIT::compileFastArithSlow_op_mod): (JSC::JIT::compileFastArith_op_add): (JSC::JIT::compileFastArithSlow_op_add): (JSC::JIT::compileFastArith_op_mul): (JSC::JIT::compileFastArithSlow_op_mul): (JSC::JIT::compileFastArith_op_post_inc): (JSC::JIT::compileFastArithSlow_op_post_inc): (JSC::JIT::compileFastArith_op_post_dec): (JSC::JIT::compileFastArithSlow_op_post_dec): (JSC::JIT::compileFastArith_op_pre_inc): (JSC::JIT::compileFastArithSlow_op_pre_inc): (JSC::JIT::compileFastArith_op_pre_dec): (JSC::JIT::compileFastArithSlow_op_pre_dec): (JSC::JIT::compileBinaryArithOp):
  • jit/JITInlineMethods.h: (JSC::JIT::getConstantOperand): (JSC::JIT::getConstantOperandImmediateInt): (JSC::JIT::isOperandConstantImmediateInt): (JSC::JIT::isOperandConstant31BitImmediateInt): (JSC::JIT::emitFastArithDeTagImmediate): (JSC::JIT::emitFastArithDeTagImmediateJumpIfZero): (JSC::JIT::emitFastArithReTagImmediate): (JSC::JIT::emitFastArithImmToInt): (JSC::JIT::emitFastArithIntToImmNoCheck):
  • runtime/JSImmediate.h: (JSC::JSImmediate::isPositiveNumber): (JSC::JSImmediate::isNegative): (JSC::JSImmediate::rightShiftImmediateNumbers): (JSC::JSImmediate::canDoFastAdditiveOperations): (JSC::JSImmediate::makeValue): (JSC::JSImmediate::makeInt): (JSC::JSImmediate::makeBool): (JSC::JSImmediate::intValue): (JSC::JSImmediate::rawValue): (JSC::JSImmediate::toBoolean): (JSC::JSImmediate::from):
  • wtf/Platform.h:
File:
1 edited

Legend:

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

    r39524 r39540  
    228228
    229229    // They are equal - set the result to true. (Or false, if negated).
    230     move(Imm32(asInteger(jsBoolean(!negated))), X86::eax);
     230    move(ImmPtr(jsBoolean(!negated)), X86::eax);
    231231    Jump bothWereImmediatesAndEqual = jump();
    232232
     
    236236    firstNotImmediate.link(this);
    237237    emitJumpSlowCaseIfJSCell(X86::edx);
    238     addSlowCase(je32(X86::edx, Imm32(asInteger(JSImmediate::zeroImmediate()))));
     238    addSlowCase(jePtr(X86::edx, ImmPtr(JSImmediate::zeroImmediate())));
    239239    Jump firstWasNotImmediate = jump();
    240240
     
    242242    // If eax is 0 jump to a slow case, otherwise these values are not equal.
    243243    secondNotImmediate.link(this);
    244     addSlowCase(je32(X86::eax, Imm32(asInteger(JSImmediate::zeroImmediate()))));
     244    addSlowCase(jePtr(X86::eax, ImmPtr(JSImmediate::zeroImmediate())));
    245245
    246246    // We get here if the two values are different immediates, or one is 0 and the other is a JSCell.
     
    248248    bothWereImmediatesButNotEqual.link(this);
    249249    firstWasNotImmediate.link(this);
    250     move(Imm32(asInteger(jsBoolean(negated))), X86::eax);
     250    move(ImmPtr(jsBoolean(negated)), X86::eax);
    251251   
    252252    bothWereImmediatesAndEqual.link(this);
     
    313313        }
    314314        case op_add: {
    315             unsigned dst = currentInstruction[1].u.operand;
    316             unsigned src1 = currentInstruction[2].u.operand;
    317             unsigned src2 = currentInstruction[3].u.operand;
    318 
    319             if (JSValue* value = getConstantImmediateNumericArg(src1)) {
    320                 emitGetVirtualRegister(src2, X86::eax);
    321                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    322                 addSlowCase(joAdd32(Imm32(getDeTaggedConstantImmediate(value)), X86::eax));
    323                 signExtend32ToPtr(X86::eax, X86::eax);
    324                 emitPutVirtualRegister(dst);
    325             } else if (JSValue* value = getConstantImmediateNumericArg(src2)) {
    326                 emitGetVirtualRegister(src1, X86::eax);
    327                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    328                 addSlowCase(joAdd32(Imm32(getDeTaggedConstantImmediate(value)), X86::eax));
    329                 signExtend32ToPtr(X86::eax, X86::eax);
    330                 emitPutVirtualRegister(dst);
    331             } else {
    332                 OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
    333                 if (types.first().mightBeNumber() && types.second().mightBeNumber())
    334                     compileBinaryArithOp(op_add, currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, OperandTypes::fromInt(currentInstruction[4].u.operand));
    335                 else {
    336                     emitPutJITStubArgFromVirtualRegister(currentInstruction[2].u.operand, 1, X86::ecx);
    337                     emitPutJITStubArgFromVirtualRegister(currentInstruction[3].u.operand, 2, X86::ecx);
    338                     emitCTICall(Interpreter::cti_op_add);
    339                     emitPutVirtualRegister(currentInstruction[1].u.operand);
    340                 }
    341             }
     315            compileFastArith_op_add(currentInstruction);
    342316            NEXT_OPCODE(op_add);
    343317        }
     
    356330        }
    357331        case op_pre_inc: {
    358             int srcDst = currentInstruction[1].u.operand;
    359             emitGetVirtualRegister(srcDst, X86::eax);
    360             emitJumpSlowCaseIfNotImmNum(X86::eax);
    361             addSlowCase(joAdd32(Imm32(getDeTaggedConstantImmediate(JSImmediate::oneImmediate())), X86::eax));
    362             signExtend32ToPtr(X86::eax, X86::eax);
    363             emitPutVirtualRegister(srcDst);
     332            compileFastArith_op_pre_inc(currentInstruction[1].u.operand);
    364333            NEXT_OPCODE(op_pre_inc);
    365334        }
     
    374343            emitSlowScriptCheck();
    375344
     345            unsigned op1 = currentInstruction[1].u.operand;
     346            unsigned op2 = currentInstruction[2].u.operand;
    376347            unsigned target = currentInstruction[3].u.operand;
    377             JSValue* src2imm = getConstantImmediateNumericArg(currentInstruction[2].u.operand);
    378             if (src2imm) {
    379                 emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
     348            if (isOperandConstantImmediateInt(op2)) {
     349                emitGetVirtualRegister(op1, X86::eax);
    380350                emitJumpSlowCaseIfNotImmNum(X86::eax);
    381                 addJump(jl32(X86::eax, Imm32(asInteger(src2imm))), target + 3);
     351                addJump(jlPtr(X86::eax, ImmPtr(getConstantOperand(op2))), target + 3);
    382352            } else {
    383                 emitGetVirtualRegisters(currentInstruction[1].u.operand, X86::eax, currentInstruction[2].u.operand, X86::edx);
     353                emitGetVirtualRegisters(op1, X86::eax, op2, X86::edx);
    384354                emitJumpSlowCaseIfNotImmNum(X86::eax);
    385355                emitJumpSlowCaseIfNotImmNum(X86::edx);
    386                 addJump(jl32(X86::eax, X86::edx), target + 3);
     356                addJump(jlPtr(X86::eax, X86::edx), target + 3);
    387357            }
    388358            NEXT_OPCODE(op_loop_if_less);
     
    391361            emitSlowScriptCheck();
    392362
     363            unsigned op1 = currentInstruction[1].u.operand;
     364            unsigned op2 = currentInstruction[2].u.operand;
    393365            unsigned target = currentInstruction[3].u.operand;
    394             JSValue* src2imm = getConstantImmediateNumericArg(currentInstruction[2].u.operand);
    395             if (src2imm) {
    396                 emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
     366            if (isOperandConstantImmediateInt(op2)) {
     367                emitGetVirtualRegister(op1, X86::eax);
    397368                emitJumpSlowCaseIfNotImmNum(X86::eax);
    398                 addJump(jle32(X86::eax, Imm32(asInteger(src2imm))), target + 3);
     369                addJump(jlePtr(X86::eax, ImmPtr(getConstantOperand(op2))), target + 3);
    399370            } else {
    400                 emitGetVirtualRegisters(currentInstruction[1].u.operand, X86::eax, currentInstruction[2].u.operand, X86::edx);
     371                emitGetVirtualRegisters(op1, X86::eax, op2, X86::edx);
    401372                emitJumpSlowCaseIfNotImmNum(X86::eax);
    402373                emitJumpSlowCaseIfNotImmNum(X86::edx);
    403                 addJump(jle32(X86::eax, X86::edx), target + 3);
     374                addJump(jlePtr(X86::eax, X86::edx), target + 3);
    404375            }
    405             NEXT_OPCODE(op_loop_if_lesseq);
     376            NEXT_OPCODE(op_loop_if_less);
    406377        }
    407378        case op_new_object: {
     
    449420
    450421            // optimistically load true result
    451             move(Imm32(asInteger(jsBoolean(true))), X86::eax);
     422            move(ImmPtr(jsBoolean(true)), X86::eax);
    452423
    453424            Label loop(this);
     
    459430            Jump exit = jePtr(X86::ecx, X86::edx);
    460431
    461             jne32(X86::ecx, Imm32(asInteger(jsNull())), loop);
    462 
    463             move(Imm32(asInteger(jsBoolean(false))), X86::eax);
     432            jnePtr(X86::ecx, ImmPtr(jsNull()), loop);
     433
     434            move(ImmPtr(jsBoolean(false)), X86::eax);
    464435
    465436            exit.link(this);
     
    478449        }
    479450        case op_mul: {
    480             unsigned dst = currentInstruction[1].u.operand;
    481             unsigned src1 = currentInstruction[2].u.operand;
    482             unsigned src2 = currentInstruction[3].u.operand;
    483 
    484             // For now, only plant a fast int case if the constant operand is greater than zero.
    485             JSValue* src1Value = getConstantImmediateNumericArg(src1);
    486             JSValue* src2Value = getConstantImmediateNumericArg(src2);
    487             int32_t value;
    488             if (src1Value && ((value = JSImmediate::intValue(src1Value)) > 0)) {
    489                 emitGetVirtualRegister(src2, X86::eax);
    490                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    491                 emitFastArithDeTagImmediate(X86::eax);
    492                 addSlowCase(joMul32(Imm32(value), X86::eax, X86::eax));
    493                 emitFastArithReTagImmediate(X86::eax);
    494                 emitPutVirtualRegister(dst);
    495             } else if (src2Value && ((value = JSImmediate::intValue(src2Value)) > 0)) {
    496                 emitGetVirtualRegister(src1, X86::eax);
    497                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    498                 emitFastArithDeTagImmediate(X86::eax);
    499                 addSlowCase(joMul32(Imm32(value), X86::eax, X86::eax));
    500                 emitFastArithReTagImmediate(X86::eax);
    501                 emitPutVirtualRegister(dst);
    502             } else
    503                 compileBinaryArithOp(op_mul, currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, OperandTypes::fromInt(currentInstruction[4].u.operand));
    504 
     451            compileFastArith_op_mul(currentInstruction);
    505452            NEXT_OPCODE(op_mul);
    506453        }
     
    672619            emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
    673620
    674             Jump isZero = je32(X86::eax, Imm32(asInteger(JSImmediate::zeroImmediate())));
     621            Jump isZero = jePtr(X86::eax, ImmPtr(JSImmediate::zeroImmediate()));
    675622            addJump(jnz32(X86::eax, Imm32(JSImmediate::TagBitTypeInteger)), target + 2);
    676623
    677             addJump(je32(X86::eax, Imm32(asInteger(JSImmediate::trueImmediate()))), target + 2);
    678             addSlowCase(jne32(X86::eax, Imm32(asInteger(JSImmediate::falseImmediate()))));
     624            addJump(jePtr(X86::eax, ImmPtr(jsBoolean(true))), target + 2);
     625            addSlowCase(jnePtr(X86::eax, ImmPtr(jsBoolean(false))));
    679626
    680627            isZero.link(this);
     
    735682        CTI_COMPILE_BINARY_OP(op_div)
    736683        case op_pre_dec: {
    737             int srcDst = currentInstruction[1].u.operand;
    738             emitGetVirtualRegister(srcDst, X86::eax);
    739             emitJumpSlowCaseIfNotImmNum(X86::eax);
    740             addSlowCase(joSub32(Imm32(getDeTaggedConstantImmediate(JSImmediate::oneImmediate())), X86::eax));
    741             signExtend32ToPtr(X86::eax, X86::eax);
    742             emitPutVirtualRegister(srcDst);
     684            compileFastArith_op_pre_dec(currentInstruction[1].u.operand);
    743685            NEXT_OPCODE(op_pre_dec);
    744686        }
    745687        case op_jnless: {
     688            unsigned op1 = currentInstruction[1].u.operand;
     689            unsigned op2 = currentInstruction[2].u.operand;
    746690            unsigned target = currentInstruction[3].u.operand;
    747             JSValue* src2imm = getConstantImmediateNumericArg(currentInstruction[2].u.operand);
    748             if (src2imm) {
    749                 emitGetVirtualRegister(currentInstruction[1].u.operand, X86::edx);
    750                 emitJumpSlowCaseIfNotImmNum(X86::edx);
    751                 addJump(jge32(X86::edx, Imm32(asInteger(src2imm))), target + 3);
     691            if (isOperandConstantImmediateInt(op2)) {
     692                emitGetVirtualRegister(op1, X86::eax);
     693                emitJumpSlowCaseIfNotImmNum(X86::eax);
     694                addJump(jgePtr(X86::eax, ImmPtr(getConstantOperand(op2))), target + 3);
    752695            } else {
    753                 emitGetVirtualRegisters(currentInstruction[1].u.operand, X86::eax, currentInstruction[2].u.operand, X86::edx);
     696                emitGetVirtualRegisters(op1, X86::eax, op2, X86::edx);
    754697                emitJumpSlowCaseIfNotImmNum(X86::eax);
    755698                emitJumpSlowCaseIfNotImmNum(X86::edx);
    756                 addJump(jge32(X86::eax, X86::edx), target + 3);
     699                addJump(jgePtr(X86::eax, X86::edx), target + 3);
    757700            }
    758701            NEXT_OPCODE(op_jnless);
     
    770713            emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
    771714
    772             addJump(je32(X86::eax, Imm32(asInteger(JSImmediate::zeroImmediate()))), target + 2);
     715            addJump(jePtr(X86::eax, ImmPtr(JSImmediate::zeroImmediate())), target + 2);
    773716            Jump isNonZero = jnz32(X86::eax, Imm32(JSImmediate::TagBitTypeInteger));
    774717
    775             addJump(je32(X86::eax, Imm32(asInteger(JSImmediate::falseImmediate()))), target + 2);
    776             addSlowCase(jne32(X86::eax, Imm32(asInteger(JSImmediate::trueImmediate()))));
     718            addJump(jePtr(X86::eax, ImmPtr(jsBoolean(false))), target + 2);
     719            addSlowCase(jnePtr(X86::eax, ImmPtr(jsBoolean(true))));
    777720
    778721            isNonZero.link(this);
     
    794737            isImmediate.link(this);
    795738            and32(Imm32(~JSImmediate::ExtendedTagBitUndefined), X86::eax);
    796             addJump(je32(X86::eax, Imm32(asInteger(jsNull()))), target + 2);           
     739            addJump(jePtr(X86::eax, ImmPtr(jsNull())), target + 2);           
    797740
    798741            wasNotImmediate.link(this);
     
    814757            isImmediate.link(this);
    815758            and32(Imm32(~JSImmediate::ExtendedTagBitUndefined), X86::eax);
    816             addJump(jne32(X86::eax, Imm32(asInteger(jsNull()))), target + 2);           
     759            addJump(jnePtr(X86::eax, ImmPtr(jsNull())), target + 2);           
    817760
    818761            wasNotImmediate.link(this);
     
    820763        }
    821764        case op_post_inc: {
    822             int srcDst = currentInstruction[2].u.operand;
    823             emitGetVirtualRegister(srcDst, X86::eax);
    824             move(X86::eax, X86::edx);
    825             emitJumpSlowCaseIfNotImmNum(X86::eax);
    826             addSlowCase(joAdd32(Imm32(getDeTaggedConstantImmediate(JSImmediate::oneImmediate())), X86::edx));
    827             signExtend32ToPtr(X86::edx, X86::edx);
    828             emitPutVirtualRegister(srcDst, X86::edx);
    829             emitPutVirtualRegister(currentInstruction[1].u.operand);
     765            compileFastArith_op_post_inc(currentInstruction[1].u.operand, currentInstruction[2].u.operand);
    830766            NEXT_OPCODE(op_post_inc);
    831767        }
     
    857793        }
    858794        case op_lshift: {
    859             emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::ecx);
    860             emitJumpSlowCaseIfNotImmNum(X86::eax);
    861             emitJumpSlowCaseIfNotImmNum(X86::ecx);
    862             emitFastArithImmToInt(X86::eax);
    863             emitFastArithImmToInt(X86::ecx);
    864             lshift32(X86::ecx, X86::eax);
    865             emitFastArithIntToImmOrSlowCase(X86::eax);
    866             emitPutVirtualRegister(currentInstruction[1].u.operand);
     795            compileFastArith_op_lshift(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand);
    867796            NEXT_OPCODE(op_lshift);
    868797        }
    869798        case op_bitand: {
    870             unsigned src1 = currentInstruction[2].u.operand;
    871             unsigned src2 = currentInstruction[3].u.operand;
    872             unsigned dst = currentInstruction[1].u.operand;
    873             if (JSValue* value = getConstantImmediateNumericArg(src1)) {
    874                 emitGetVirtualRegister(src2, X86::eax);
    875                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    876                 andPtr(Imm32(asInteger(value)), X86::eax); // FIXME: make it more obvious this is relying on the format of JSImmediate
    877                 emitPutVirtualRegister(dst);
    878             } else if (JSValue* value = getConstantImmediateNumericArg(src2)) {
    879                 emitGetVirtualRegister(src1, X86::eax);
    880                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    881                 andPtr(Imm32(asInteger(value)), X86::eax);
    882                 emitPutVirtualRegister(dst);
    883             } else {
    884                 emitGetVirtualRegisters(src1, X86::eax, src2, X86::edx);
    885                 andPtr(X86::edx, X86::eax);
    886                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    887                 emitPutVirtualRegister(dst);
    888             }
     799            compileFastArith_op_bitand(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand);
    889800            NEXT_OPCODE(op_bitand);
    890801        }
    891802        case op_rshift: {
    892             unsigned src1 = currentInstruction[2].u.operand;
    893             unsigned src2 = currentInstruction[3].u.operand;
    894             if (JSValue* value = getConstantImmediateNumericArg(src2)) {
    895                 emitGetVirtualRegister(src1, X86::eax);
    896                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    897                 // Mask with 0x1f as per ecma-262 11.7.2 step 7.
    898                 rshift32(Imm32(JSImmediate::getTruncatedUInt32(value) & 0x1f), X86::eax);
    899             } else {
    900                 emitGetVirtualRegisters(src1, X86::eax, src2, X86::ecx);
    901                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    902                 emitJumpSlowCaseIfNotImmNum(X86::ecx);
    903                 emitFastArithImmToInt(X86::ecx);
    904                 rshift32(X86::ecx, X86::eax);
    905             }
    906             emitFastArithPotentiallyReTagImmediate(X86::eax);
    907             emitPutVirtualRegister(currentInstruction[1].u.operand);
     803            compileFastArith_op_rshift(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand);
    908804            NEXT_OPCODE(op_rshift);
    909805        }
     
    931827        }
    932828        case op_mod: {
    933             emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::ecx);
    934             emitJumpSlowCaseIfNotImmNum(X86::eax);
    935             emitJumpSlowCaseIfNotImmNum(X86::ecx);
    936             emitFastArithDeTagImmediate(X86::eax);
    937             addSlowCase(emitFastArithDeTagImmediateJumpIfZero(X86::ecx));
    938             mod32(X86::ecx, X86::eax, X86::edx);
    939             emitFastArithReTagImmediate(X86::edx);
    940             move(X86::edx, X86::eax);
    941             emitPutVirtualRegister(currentInstruction[1].u.operand);
     829            compileFastArith_op_mod(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand);
    942830            NEXT_OPCODE(op_mod);
    943831        }
     
    946834            emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
    947835
    948             Jump isZero = je32(X86::eax, Imm32(asInteger(JSImmediate::zeroImmediate())));
     836            Jump isZero = jePtr(X86::eax, ImmPtr(JSImmediate::zeroImmediate()));
    949837            addJump(jnz32(X86::eax, Imm32(JSImmediate::TagBitTypeInteger)), target + 2);
    950838
    951             addJump(je32(X86::eax, Imm32(asInteger(JSImmediate::trueImmediate()))), target + 2);
    952             addSlowCase(jne32(X86::eax, Imm32(asInteger(JSImmediate::falseImmediate()))));
     839            addJump(jePtr(X86::eax, ImmPtr(jsBoolean(true))), target + 2);
     840            addSlowCase(jnePtr(X86::eax, ImmPtr(jsBoolean(false))));
    953841
    954842            isZero.link(this);
     
    967855        }
    968856        case op_post_dec: {
    969             int srcDst = currentInstruction[2].u.operand;
    970             emitGetVirtualRegister(srcDst, X86::eax);
    971             move(X86::eax, X86::edx);
    972             emitJumpSlowCaseIfNotImmNum(X86::eax);
    973             addSlowCase(joSub32(Imm32(getDeTaggedConstantImmediate(JSImmediate::oneImmediate())), X86::edx));
    974             signExtend32ToPtr(X86::edx, X86::edx);
    975             emitPutVirtualRegister(srcDst, X86::edx);
    976             emitPutVirtualRegister(currentInstruction[1].u.operand);
     857            compileFastArith_op_post_dec(currentInstruction[1].u.operand, currentInstruction[2].u.operand);
    977858            NEXT_OPCODE(op_post_dec);
    978859        }
     
    981862            emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::edx);
    982863            emitJumpSlowCaseIfNotImmNums(X86::eax, X86::edx, X86::ecx);
    983             xor32(X86::edx, X86::eax);
     864            xorPtr(X86::edx, X86::eax);
    984865            emitFastArithReTagImmediate(X86::eax);
    985866            emitPutVirtualRegister(currentInstruction[1].u.operand);
     
    13551236        }
    13561237        case op_add: {
    1357             unsigned dst = currentInstruction[1].u.operand;
    1358             unsigned src1 = currentInstruction[2].u.operand;
    1359             unsigned src2 = currentInstruction[3].u.operand;
    1360             if (JSValue* value = getConstantImmediateNumericArg(src1)) {
    1361                 Jump notImm = getSlowCase(iter);
    1362                 linkSlowCase(iter);
    1363                 sub32(Imm32(getDeTaggedConstantImmediate(value)), X86::eax);
    1364                 notImm.link(this);
    1365                 emitPutJITStubArgFromVirtualRegister(src1, 1, X86::ecx);
    1366                 emitPutJITStubArg(X86::eax, 2);
    1367                 emitCTICall(Interpreter::cti_op_add);
    1368                 emitPutVirtualRegister(dst);
    1369             } else if (JSValue* value = getConstantImmediateNumericArg(src2)) {
    1370                 Jump notImm = getSlowCase(iter);
    1371                 linkSlowCase(iter);
    1372                 sub32(Imm32(getDeTaggedConstantImmediate(value)), X86::eax);
    1373                 notImm.link(this);
    1374                 emitPutJITStubArg(X86::eax, 1);
    1375                 emitPutJITStubArgFromVirtualRegister(src2, 2, X86::ecx);
    1376                 emitCTICall(Interpreter::cti_op_add);
    1377                 emitPutVirtualRegister(dst);
    1378             } else {
    1379                 OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
    1380                 ASSERT(types.first().mightBeNumber() && types.second().mightBeNumber());
    1381                 compileBinaryArithOpSlowCase(op_add, iter, dst, src1, src2, types);
    1382             }
    1383 
     1238            compileFastArithSlow_op_add(currentInstruction, iter);
    13841239            NEXT_OPCODE(op_add);
    13851240        }
     
    14261281        }
    14271282        case op_rshift: {
    1428             unsigned src2 = currentInstruction[3].u.operand;
    1429             linkSlowCase(iter);
    1430             if (getConstantImmediateNumericArg(src2))
    1431                 emitPutJITStubArgFromVirtualRegister(src2, 2, X86::ecx);
    1432             else {
    1433                 linkSlowCase(iter);
    1434                 emitPutJITStubArg(X86::ecx, 2);
    1435             }
    1436 
    1437             emitPutJITStubArg(X86::eax, 1);
    1438             emitCTICall(Interpreter::cti_op_rshift);
    1439             emitPutVirtualRegister(currentInstruction[1].u.operand);
     1283            compileFastArithSlow_op_rshift(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, iter);
    14401284            NEXT_OPCODE(op_rshift);
    14411285        }
    14421286        case op_lshift: {
    1443             Jump notImm1 = getSlowCase(iter);
    1444             Jump notImm2 = getSlowCase(iter);
    1445             linkSlowCase(iter);
    1446             emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::ecx);
    1447             notImm1.link(this);
    1448             notImm2.link(this);
    1449             emitPutJITStubArg(X86::eax, 1);
    1450             emitPutJITStubArg(X86::ecx, 2);
    1451             emitCTICall(Interpreter::cti_op_lshift);
    1452             emitPutVirtualRegister(currentInstruction[1].u.operand);
     1287            compileFastArithSlow_op_lshift(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, iter);
    14531288            NEXT_OPCODE(op_lshift);
    14541289        }
     
    15001335        }
    15011336        case op_pre_inc: {
    1502             unsigned srcDst = currentInstruction[1].u.operand;
    1503             Jump notImm = getSlowCase(iter);
    1504             linkSlowCase(iter);
    1505             sub32(Imm32(getDeTaggedConstantImmediate(JSImmediate::oneImmediate())), X86::eax);
    1506             notImm.link(this);
    1507             emitPutJITStubArg(X86::eax, 1);
    1508             emitCTICall(Interpreter::cti_op_pre_inc);
    1509             emitPutVirtualRegister(srcDst);
     1337            compileFastArithSlow_op_pre_inc(currentInstruction[1].u.operand, iter);
    15101338            NEXT_OPCODE(op_pre_inc);
    15111339        }
     
    15441372        }
    15451373        case op_pre_dec: {
    1546             unsigned srcDst = currentInstruction[1].u.operand;
    1547             Jump notImm = getSlowCase(iter);
    1548             linkSlowCase(iter);
    1549             add32(Imm32(getDeTaggedConstantImmediate(JSImmediate::oneImmediate())), X86::eax);
    1550             notImm.link(this);
    1551             emitPutJITStubArg(X86::eax, 1);
    1552             emitCTICall(Interpreter::cti_op_pre_dec);
    1553             emitPutVirtualRegister(srcDst);
     1374            compileFastArithSlow_op_pre_dec(currentInstruction[1].u.operand, iter);
    15541375            NEXT_OPCODE(op_pre_dec);
    15551376        }
     
    15591380            if (src2imm) {
    15601381                linkSlowCase(iter);
    1561                 emitPutJITStubArg(X86::edx, 1);
     1382                emitPutJITStubArg(X86::eax, 1);
    15621383                emitPutJITStubArgFromVirtualRegister(currentInstruction[2].u.operand, 2, X86::ecx);
    15631384                emitCTICall(Interpreter::cti_op_jless);
     
    15901411        }
    15911412        case op_post_inc: {
    1592             unsigned srcDst = currentInstruction[2].u.operand;
    1593             linkSlowCase(iter);
    1594             linkSlowCase(iter);
    1595             emitPutJITStubArg(X86::eax, 1);
    1596             emitCTICall(Interpreter::cti_op_post_inc);
    1597             emitPutVirtualRegister(srcDst, X86::edx);
    1598             emitPutVirtualRegister(currentInstruction[1].u.operand);
     1413            compileFastArithSlow_op_post_inc(currentInstruction[1].u.operand, currentInstruction[2].u.operand, iter);
    15991414            NEXT_OPCODE(op_post_inc);
    16001415        }
     
    16071422        }
    16081423        case op_bitand: {
    1609             linkSlowCase(iter);
    1610             unsigned src1 = currentInstruction[2].u.operand;
    1611             unsigned src2 = currentInstruction[3].u.operand;
    1612             unsigned dst = currentInstruction[1].u.operand;
    1613             if (getConstantImmediateNumericArg(src1)) {
    1614                 emitPutJITStubArgFromVirtualRegister(src1, 1, X86::ecx);
    1615                 emitPutJITStubArg(X86::eax, 2);
    1616                 emitCTICall(Interpreter::cti_op_bitand);
    1617                 emitPutVirtualRegister(dst);
    1618             } else if (getConstantImmediateNumericArg(src2)) {
    1619                 emitPutJITStubArg(X86::eax, 1);
    1620                 emitPutJITStubArgFromVirtualRegister(src2, 2, X86::ecx);
    1621                 emitCTICall(Interpreter::cti_op_bitand);
    1622                 emitPutVirtualRegister(dst);
    1623             } else {
    1624                 emitPutJITStubArgFromVirtualRegister(src1, 1, X86::ecx);
    1625                 emitPutJITStubArg(X86::edx, 2);
    1626                 emitCTICall(Interpreter::cti_op_bitand);
    1627                 emitPutVirtualRegister(dst);
    1628             }
     1424            compileFastArithSlow_op_bitand(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, iter);
    16291425            NEXT_OPCODE(op_bitand);
    16301426        }
     
    16381434        }
    16391435        case op_post_dec: {
    1640             unsigned srcDst = currentInstruction[2].u.operand;
    1641             linkSlowCase(iter);
    1642             linkSlowCase(iter);
    1643             emitPutJITStubArg(X86::eax, 1);
    1644             emitCTICall(Interpreter::cti_op_post_dec);
    1645             emitPutVirtualRegister(srcDst, X86::edx);
    1646             emitPutVirtualRegister(currentInstruction[1].u.operand);
     1436            compileFastArithSlow_op_post_dec(currentInstruction[1].u.operand, currentInstruction[2].u.operand, iter);
    16471437            NEXT_OPCODE(op_post_dec);
    16481438        }
     
    17111501        }
    17121502        case op_mod: {
    1713             Jump notImm1 = getSlowCase(iter);
    1714             Jump notImm2 = getSlowCase(iter);
    1715             linkSlowCase(iter);
    1716             emitFastArithReTagImmediate(X86::eax);
    1717             emitFastArithReTagImmediate(X86::ecx);
    1718             notImm1.link(this);
    1719             notImm2.link(this);
    1720             emitPutJITStubArg(X86::eax, 1);
    1721             emitPutJITStubArg(X86::ecx, 2);
    1722             emitCTICall(Interpreter::cti_op_mod);
    1723             emitPutVirtualRegister(currentInstruction[1].u.operand);
     1503            compileFastArithSlow_op_mod(currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, iter);
    17241504            NEXT_OPCODE(op_mod);
    17251505        }
    17261506        case op_mul: {
    1727             int dst = currentInstruction[1].u.operand;
    1728             int src1 = currentInstruction[2].u.operand;
    1729             int src2 = currentInstruction[3].u.operand;
    1730             JSValue* src1Value = getConstantImmediateNumericArg(src1);
    1731             JSValue* src2Value = getConstantImmediateNumericArg(src2);
    1732             int32_t value;
    1733             if (src1Value && ((value = JSImmediate::intValue(src1Value)) > 0)) {
    1734                 linkSlowCase(iter);
    1735                 linkSlowCase(iter);
    1736                 // There is an extra slow case for (op1 * -N) or (-N * op2), to check for 0 since this should produce a result of -0.
    1737                 emitPutJITStubArgFromVirtualRegister(src1, 1, X86::ecx);
    1738                 emitPutJITStubArgFromVirtualRegister(src2, 2, X86::ecx);
    1739                 emitCTICall(Interpreter::cti_op_mul);
    1740                 emitPutVirtualRegister(dst);
    1741             } else if (src2Value && ((value = JSImmediate::intValue(src2Value)) > 0)) {
    1742                 linkSlowCase(iter);
    1743                 linkSlowCase(iter);
    1744                 // There is an extra slow case for (op1 * -N) or (-N * op2), to check for 0 since this should produce a result of -0.
    1745                 emitPutJITStubArgFromVirtualRegister(src1, 1, X86::ecx);
    1746                 emitPutJITStubArgFromVirtualRegister(src2, 2, X86::ecx);
    1747                 emitCTICall(Interpreter::cti_op_mul);
    1748                 emitPutVirtualRegister(dst);
    1749             } else
    1750                 compileBinaryArithOpSlowCase(op_mul, iter, dst, src1, src2, OperandTypes::fromInt(currentInstruction[4].u.operand));
     1507            compileFastArithSlow_op_mul(currentInstruction, iter);
    17511508            NEXT_OPCODE(op_mul);
    17521509        }
     
    19331690    Jump array_failureCases3 = ja32(X86::eax, Imm32(JSImmediate::maxImmediateInt));
    19341691
    1935     add32(X86::eax, X86::eax);
    1936     add32(Imm32(1), X86::eax);
    1937    
     1692    // X86::eax contains a 64 bit value (is signed, is zero extended) so we don't need sign extend here.
     1693    emitFastArithIntToImmNoCheck(X86::eax);
     1694
    19381695    ret();
    19391696
     
    19511708    Jump string_failureCases3 = ja32(X86::eax, Imm32(JSImmediate::maxImmediateInt));
    19521709
    1953     add32(X86::eax, X86::eax);
    1954     add32(Imm32(1), X86::eax);
     1710    // X86::eax contains a 64 bit value (is signed, is zero extended) so we don't need sign extend here.
     1711    emitFastArithIntToImmNoCheck(X86::eax);
    19551712   
    19561713    ret();
Note: See TracChangeset for help on using the changeset viewer.