Exemple #1
0
//from jit/shared/BaselineIC-x86-shared.cpp
bool
ICCompare_Double::Compiler::generateStubCode(MacroAssembler &masm)
{
    Label failure, notNaN;
    masm.ensureDouble(R0, FloatReg0, &failure);
    masm.ensureDouble(R1, FloatReg1, &failure);

    Register dest = R0.scratchReg();

    Assembler::DoubleCondition cond = JSOpToDoubleCondition(op);
    masm.mov(ImmWord(0), dest);
    masm.compareDouble(cond, FloatReg0, FloatReg1);
    masm.setCC(Assembler::ConditionFromDoubleCondition(cond), dest);

    // Check for NaN, if needed.
    Assembler::NaNCond nanCond = Assembler::NaNCondFromDoubleCondition(cond);
    if (nanCond != Assembler::NaN_HandledByCond) {
      masm.j(Assembler::NoParity, &notNaN);
      masm.mov(ImmWord(nanCond == Assembler::NaN_IsTrue), dest);
      masm.bind(&notNaN);
    }

    masm.tagValue(JSVAL_TYPE_BOOLEAN, dest, R0);
    EmitReturnFromIC(masm);

    // Failure case - jump to next stub
    masm.bind(&failure);
    EmitStubGuardFailure(masm);
    return true;
}
Exemple #2
0
bool
ICCompare_Double::Compiler::generateStubCode(MacroAssembler &masm)
{
    Label failure, isNaN;
    masm.ensureDouble(R0, FloatReg0, &failure);
    masm.ensureDouble(R1, FloatReg1, &failure);

    Register dest = R0.scratchReg();

    Assembler::DoubleCondition doubleCond = JSOpToDoubleCondition(op);

    masm.ma_cmp_set_double(dest, FloatReg0, FloatReg1, doubleCond);

    masm.tagValue(JSVAL_TYPE_BOOLEAN, dest, R0);
    EmitReturnFromIC(masm);

    // Failure case - jump to next stub
    masm.bind(&failure);
    EmitStubGuardFailure(masm);
    return true;
}
Exemple #3
0
bool
ICCompare_Double::Compiler::generateStubCode(MacroAssembler &masm)
{
	// by wangqing, 2013-11-28
    Label failure, notNaN, isTrue;
    /* if R0 is a double, load it into dest. If R0 is int32,  
	   convert it to double. Else, branch to failure.
	   by wangqing, 2013-11-28
	*/	
	    Label isDouble, done;

		masm.movl(ImmTag(JSVAL_TAG_CLEAR), cmpTempRegister);
		masm.sltu(cmpTempRegister, R0.typeReg(), cmpTempRegister);
		masm.bgtz(cmpTempRegister, &isDouble);
		masm.nop();

		masm.movl(ImmTag(JSVAL_TAG_INT32), cmpTempRegister);
		masm.bne(R0.typeReg(), cmpTempRegister, &failure);
		masm.nop();

        masm.convertInt32ToDouble(R0.payloadReg(), FloatReg0);
        masm.b(&done);
		masm.nop();

        masm.bindBranch(&isDouble);
        masm.unboxDouble(R0, FloatReg0);

        masm.bindBranch(&done);

	/* if R1 is a double, load it into dest. If R1 is int32,  
	   convert it to double. Else, branch to failure.
	   by wangqing, 2013-11-28
	*/	
	    Label isDouble1, done1;

		masm.movl(ImmTag(JSVAL_TAG_CLEAR), cmpTempRegister);
		masm.sltu(cmpTempRegister, R1.typeReg(), cmpTempRegister);
		masm.bgtz(cmpTempRegister, &isDouble1);
		masm.nop();

		masm.movl(ImmTag(JSVAL_TAG_INT32), cmpTempRegister);
		masm.bne(R1.typeReg(), cmpTempRegister, &failure);
		masm.nop();

        masm.convertInt32ToDouble(R1.payloadReg(), FloatReg1);
        masm.b(&done1);
		masm.nop();

        masm.bindBranch(&isDouble1);
        masm.unboxDouble(R1, FloatReg1);

        masm.bindBranch(&done1);

    Register dest = R0.scratchReg();

    Assembler::DoubleCondition cond = JSOpToDoubleCondition(op);
    masm.addiu(dest, zero, 1);
    masm.branchDoubleLocal(cond, FloatReg0, FloatReg1, &isTrue);
    masm.xorl(dest, dest);
    masm.bindBranch(&isTrue);


    // Check for NaN, if needed.
    Assembler::NaNCond nanCond = Assembler::NaNCondFromDoubleCondition(cond);
    if (nanCond != Assembler::NaN_HandledByCond) {
	  // check DoubleOrdered, by wangqing, 2013-11-28
	  masm.cud(FloatReg0, FloatReg1);
	  masm.bc1f(&notNaN);
	  masm.nop();
      masm.mov(Imm32(nanCond == Assembler::NaN_IsTrue), dest);
      masm.bindBranch(&notNaN);
    }

    masm.tagValue(JSVAL_TYPE_BOOLEAN, dest, R0);
    EmitReturnFromIC(masm);

    // Failure case - jump to next stub
    masm.bindBranch(&failure);
    EmitStubGuardFailure(masm);
    return true;
}