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


Ignore:
Timestamp:
Jan 15, 2009, 7:20:35 PM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Geoff Garen.

On x86-64 allow JSImmediate to encode 64-bit double precision values.
This patch only affects builds that set USE(ALTERNATE_JSIMMEDIATE).

Updates the implementation of JSValuePtr
and JSImmediate:: methods that operate on neumeric values to be be aware of the new representation. When this representation is in use, the class JSNumberCell is redundant and is compiled out.

The format of the new immediate representation is documented in JSImmediate.h.

  • JavaScriptCore.exp:
  • assembler/MacroAssembler.h: (JSC::MacroAssembler::subPtr):
  • assembler/X86Assembler.h: (JSC::X86Assembler::): (JSC::X86Assembler::subq_rr): (JSC::X86Assembler::movq_rr): (JSC::X86Assembler::ucomisd_rr): (JSC::X86Assembler::X86InstructionFormatter::twoByteOp64):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::cti_op_stricteq): (JSC::Interpreter::cti_op_nstricteq):
  • jit/JIT.cpp: (JSC::JIT::compileOpStrictEq): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases):
  • jit/JIT.h:
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_lshift): (JSC::JIT::compileFastArith_op_rshift): (JSC::JIT::compileFastArith_op_bitand): (JSC::JIT::compileFastArith_op_mod): (JSC::JIT::compileFastArith_op_add): (JSC::JIT::compileFastArith_op_mul): (JSC::JIT::compileFastArith_op_post_inc): (JSC::JIT::compileFastArith_op_post_dec): (JSC::JIT::compileFastArith_op_pre_inc): (JSC::JIT::compileFastArith_op_pre_dec): (JSC::JIT::putDoubleResultToJSNumberCellOrJSImmediate): (JSC::JIT::compileBinaryArithOp):
  • jit/JITInlineMethods.h: (JSC::JIT::emitJumpIfBothJSCells): (JSC::JIT::emitJumpIfEitherNumber): (JSC::JIT::emitJumpIfNotEitherNumber): (JSC::JIT::emitJumpIfImmediateIntegerNumber): (JSC::JIT::emitJumpIfNotImmediateIntegerNumber): (JSC::JIT::emitJumpIfNotImmediateIntegerNumbers): (JSC::JIT::emitJumpSlowCaseIfNotImmediateIntegerNumber): (JSC::JIT::emitJumpSlowCaseIfNotImmediateIntegerNumbers): (JSC::JIT::emitFastArithDeTagImmediate): (JSC::JIT::emitFastArithDeTagImmediateJumpIfZero): (JSC::JIT::emitFastArithReTagImmediate): (JSC::JIT::emitFastArithIntToImmNoCheck):
  • runtime/JSCell.h:
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSImmediate.cpp: (JSC::JSImmediate::toThisObject): (JSC::JSImmediate::toObject): (JSC::JSImmediate::toString):
  • runtime/JSImmediate.h: (JSC::wtf_reinterpret_cast): (JSC::JSImmediate::isNumber): (JSC::JSImmediate::isIntegerNumber): (JSC::JSImmediate::isDoubleNumber): (JSC::JSImmediate::isPositiveIntegerNumber): (JSC::JSImmediate::areBothImmediateIntegerNumbers): (JSC::JSImmediate::makeInt): (JSC::JSImmediate::makeDouble): (JSC::JSImmediate::doubleValue): (JSC::doubleToBoolean): (JSC::JSImmediate::toBoolean): (JSC::JSImmediate::getTruncatedUInt32): (JSC::JSImmediate::makeOutOfIntegerRange): (JSC::JSImmediate::from): (JSC::JSImmediate::getTruncatedInt32): (JSC::JSImmediate::toDouble): (JSC::JSImmediate::getUInt32): (JSC::JSValuePtr::isInt32Fast): (JSC::JSValuePtr::isUInt32Fast): (JSC::JSValuePtr::areBothInt32Fast): (JSC::JSFastMath::canDoFastBitwiseOperations): (JSC::JSFastMath::xorImmediateNumbers): (JSC::JSFastMath::canDoFastRshift): (JSC::JSFastMath::canDoFastUrshift): (JSC::JSFastMath::rightShiftImmediateNumbers): (JSC::JSFastMath::canDoFastAdditiveOperations): (JSC::JSFastMath::addImmediateNumbers): (JSC::JSFastMath::subImmediateNumbers):
  • runtime/JSNumberCell.cpp: (JSC::jsNumberCell):
  • runtime/JSNumberCell.h: (JSC::createNumberStructure): (JSC::isNumberCell): (JSC::asNumberCell): (JSC::jsNumber): (JSC::JSValuePtr::isDoubleNumber): (JSC::JSValuePtr::getDoubleNumber): (JSC::JSValuePtr::isNumber): (JSC::JSValuePtr::uncheckedGetNumber): (JSC::jsNaN): (JSC::JSValuePtr::getNumber): (JSC::JSValuePtr::numberToInt32): (JSC::JSValuePtr::numberToUInt32):
  • runtime/JSValue.h:
  • runtime/NumberConstructor.cpp: (JSC::numberConstructorNegInfinity): (JSC::numberConstructorPosInfinity): (JSC::numberConstructorMaxValue): (JSC::numberConstructorMinValue):
  • runtime/NumberObject.cpp: (JSC::constructNumber):
  • runtime/NumberObject.h:
  • runtime/Operations.h: (JSC::JSValuePtr::equal): (JSC::JSValuePtr::equalSlowCaseInline): (JSC::JSValuePtr::strictEqual): (JSC::JSValuePtr::strictEqualSlowCaseInline):
  • wtf/Platform.h:
File:
1 edited

Legend:

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

    r39851 r39958  
    214214void JIT::compileOpStrictEq(Instruction* currentInstruction, CompileOpStrictEqType type)
    215215{
    216     bool negated = (type == OpNStrictEq);
    217 
    218216    unsigned dst = currentInstruction[1].u.operand;
    219217    unsigned src1 = currentInstruction[2].u.operand;
     
    222220    emitGetVirtualRegisters(src1, X86::eax, src2, X86::edx);
    223221
    224     // Check that bot are immediates, if so check if they're equal
     222#if USE(ALTERNATE_JSIMMEDIATE)
     223    // Jump to a slow case if either operand is a number, or if both are JSCell*s.
     224    move(X86::eax, X86::ecx);
     225    orPtr(X86::edx, X86::ecx);
     226    addSlowCase(emitJumpIfJSCell(X86::ecx));
     227    addSlowCase(emitJumpIfImmediateNumber(X86::ecx));
     228
     229    if (type == OpStrictEq)
     230        sete32(X86::edx, X86::eax);
     231    else
     232        setne32(X86::edx, X86::eax);
     233    emitTagAsBoolImmediate(X86::eax);
     234#else
     235    bool negated = (type == OpNStrictEq);
     236
     237    // Check that both are immediates, if so check if they're equal
    225238    Jump firstNotImmediate = emitJumpIfJSCell(X86::eax);
    226239    Jump secondNotImmediate = emitJumpIfJSCell(X86::edx);
    227     Jump bothWereImmediatesButNotEqual = jne32(X86::edx, X86::eax);
     240    Jump bothWereImmediatesButNotEqual = jnePtr(X86::edx, X86::eax);
    228241
    229242    // They are equal - set the result to true. (Or false, if negated).
     
    251264   
    252265    bothWereImmediatesAndEqual.link(this);
     266#endif
     267
    253268    emitPutVirtualRegister(dst);
    254269}
     
    348363            if (isOperandConstantImmediateInt(op2)) {
    349364                emitGetVirtualRegister(op1, X86::eax);
    350                 emitJumpSlowCaseIfNotImmNum(X86::eax);
     365                emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
    351366#if USE(ALTERNATE_JSIMMEDIATE)
    352367                int32_t op2imm = getConstantOperandImmediateInt(op2);
     
    357372            } else {
    358373                emitGetVirtualRegisters(op1, X86::eax, op2, X86::edx);
    359                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    360                 emitJumpSlowCaseIfNotImmNum(X86::edx);
     374                emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
     375                emitJumpSlowCaseIfNotImmediateInteger(X86::edx);
    361376                addJump(jl32(X86::eax, X86::edx), target + 3);
    362377            }
     
    371386            if (isOperandConstantImmediateInt(op2)) {
    372387                emitGetVirtualRegister(op1, X86::eax);
    373                 emitJumpSlowCaseIfNotImmNum(X86::eax);
     388                emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
    374389#if USE(ALTERNATE_JSIMMEDIATE)
    375390                int32_t op2imm = getConstantOperandImmediateInt(op2);
     
    380395            } else {
    381396                emitGetVirtualRegisters(op1, X86::eax, op2, X86::edx);
    382                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    383                 emitJumpSlowCaseIfNotImmNum(X86::edx);
     397                emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
     398                emitJumpSlowCaseIfNotImmediateInteger(X86::edx);
    384399                addJump(jle32(X86::eax, X86::edx), target + 3);
    385400            }
     
    573588        case op_get_by_val: {
    574589            emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::edx);
    575             emitJumpSlowCaseIfNotImmNum(X86::edx);
     590            emitJumpSlowCaseIfNotImmediateInteger(X86::edx);
    576591#if USE(ALTERNATE_JSIMMEDIATE)
    577592            // This is technically incorrect - we're zero-extending an int32.  On the hot path this doesn't matter.
     
    611626        case op_put_by_val: {
    612627            emitGetVirtualRegisters(currentInstruction[1].u.operand, X86::eax, currentInstruction[2].u.operand, X86::edx);
    613             emitJumpSlowCaseIfNotImmNum(X86::edx);
     628            emitJumpSlowCaseIfNotImmediateInteger(X86::edx);
    614629#if USE(ALTERNATE_JSIMMEDIATE)
    615630            // See comment in op_get_by_val.
     
    645660
    646661            Jump isZero = jePtr(X86::eax, ImmPtr(JSValuePtr::encode(js0())));
    647             addJump(emitJumpIfImmNum(X86::eax), target + 2);
     662            addJump(emitJumpIfImmediateInteger(X86::eax), target + 2);
    648663
    649664            addJump(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(jsBoolean(true)))), target + 2);
     
    716731            if (isOperandConstantImmediateInt(op2)) {
    717732                emitGetVirtualRegister(op1, X86::eax);
    718                 emitJumpSlowCaseIfNotImmNum(X86::eax);
     733                emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
    719734#if USE(ALTERNATE_JSIMMEDIATE)
    720735                int32_t op2imm = getConstantOperandImmediateInt(op2);
     
    725740            } else {
    726741                emitGetVirtualRegisters(op1, X86::eax, op2, X86::edx);
    727                 emitJumpSlowCaseIfNotImmNum(X86::eax);
    728                 emitJumpSlowCaseIfNotImmNum(X86::edx);
     742                emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
     743                emitJumpSlowCaseIfNotImmediateInteger(X86::edx);
    729744                addJump(jge32(X86::eax, X86::edx), target + 3);
    730745            }
     
    744759
    745760            addJump(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(js0()))), target + 2);
    746             Jump isNonZero = emitJumpIfImmNum(X86::eax);
     761            Jump isNonZero = emitJumpIfImmediateInteger(X86::eax);
    747762
    748763            addJump(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(jsBoolean(false)))), target + 2);
     
    816831        case op_eq: {
    817832            emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::edx);
    818             emitJumpSlowCaseIfNotImmNums(X86::eax, X86::edx, X86::ecx);
     833            emitJumpSlowCaseIfNotImmediateIntegers(X86::eax, X86::edx, X86::ecx);
    819834            sete32(X86::edx, X86::eax);
    820835            emitTagAsBoolImmediate(X86::eax);
     
    836851        case op_bitnot: {
    837852            emitGetVirtualRegister(currentInstruction[2].u.operand, X86::eax);
    838             emitJumpSlowCaseIfNotImmNum(X86::eax);
     853            emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
    839854#if USE(ALTERNATE_JSIMMEDIATE)
    840855            not32(X86::eax);
    841856            emitFastArithIntToImmNoCheck(X86::eax, X86::eax);
    842857#else
    843             xorPtr(Imm32(~JSImmediate::TagTypeInteger), X86::eax);
     858            xorPtr(Imm32(~JSImmediate::TagTypeNumber), X86::eax);
    844859#endif
    845860            emitPutVirtualRegister(currentInstruction[1].u.operand);
     
    870885
    871886            Jump isZero = jePtr(X86::eax, ImmPtr(JSValuePtr::encode(js0())));
    872             addJump(emitJumpIfImmNum(X86::eax), target + 2);
     887            addJump(emitJumpIfImmediateInteger(X86::eax), target + 2);
    873888
    874889            addJump(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(jsBoolean(true)))), target + 2);
     
    881896        case op_neq: {
    882897            emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::edx);
    883             emitJumpSlowCaseIfNotImmNums(X86::eax, X86::edx, X86::ecx);
     898            emitJumpSlowCaseIfNotImmediateIntegers(X86::eax, X86::edx, X86::ecx);
    884899            setne32(X86::edx, X86::eax);
    885900            emitTagAsBoolImmediate(X86::eax);
     
    896911        case op_bitxor: {
    897912            emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::edx);
    898             emitJumpSlowCaseIfNotImmNums(X86::eax, X86::edx, X86::ecx);
     913            emitJumpSlowCaseIfNotImmediateIntegers(X86::eax, X86::edx, X86::ecx);
    899914            xorPtr(X86::edx, X86::eax);
    900915            emitFastArithReTagImmediate(X86::eax, X86::eax);
     
    911926        case op_bitor: {
    912927            emitGetVirtualRegisters(currentInstruction[2].u.operand, X86::eax, currentInstruction[3].u.operand, X86::edx);
    913             emitJumpSlowCaseIfNotImmNums(X86::eax, X86::edx, X86::ecx);
     928            emitJumpSlowCaseIfNotImmediateIntegers(X86::eax, X86::edx, X86::ecx);
    914929            orPtr(X86::edx, X86::eax);
    915930            emitPutVirtualRegister(currentInstruction[1].u.operand);
     
    981996            emitGetVirtualRegister(srcVReg, X86::eax);
    982997           
    983             Jump wasImmediate = emitJumpIfImmNum(X86::eax);
     998            Jump wasImmediate = emitJumpIfImmediateInteger(X86::eax);
    984999
    9851000            emitJumpSlowCaseIfNotJSCell(X86::eax, srcVReg);
     
    15071522            linkSlowCase(iter);
    15081523            linkSlowCase(iter);
    1509             linkSlowCase(iter);
     1524#if !USE(ALTERNATE_JSIMMEDIATE)
     1525            linkSlowCase(iter);
     1526#endif
    15101527            emitPutJITStubArg(X86::eax, 1);
    15111528            emitPutJITStubArg(X86::edx, 2);
     
    15171534            linkSlowCase(iter);
    15181535            linkSlowCase(iter);
    1519             linkSlowCase(iter);
     1536#if !USE(ALTERNATE_JSIMMEDIATE)
     1537            linkSlowCase(iter);
     1538#endif
    15201539            emitPutJITStubArg(X86::eax, 1);
    15211540            emitPutJITStubArg(X86::edx, 2);
Note: See TracChangeset for help on using the changeset viewer.