Bug 834678 - Ensure correct update of lastPC_ for MInstructions which add OOL code. r=jandem

This commit is contained in:
Kannan Vijayan 2013-12-09 10:28:58 -05:00
parent ed772b9951
commit 73515ed307
10 changed files with 119 additions and 66 deletions

View File

@ -4307,8 +4307,8 @@ CodeGenerator::visitIsNullOrLikeUndefined(LIsNullOrLikeUndefined *lir)
bool
CodeGenerator::visitIsNullOrLikeUndefinedAndBranch(LIsNullOrLikeUndefinedAndBranch *lir)
{
JSOp op = lir->mir()->jsop();
MCompare::CompareType compareType = lir->mir()->compareType();
JSOp op = lir->cmpMir()->jsop();
MCompare::CompareType compareType = lir->cmpMir()->compareType();
JS_ASSERT(compareType == MCompare::Compare_Undefined ||
compareType == MCompare::Compare_Null);
@ -4328,12 +4328,12 @@ CodeGenerator::visitIsNullOrLikeUndefinedAndBranch(LIsNullOrLikeUndefinedAndBran
op = JSOP_EQ;
}
MOZ_ASSERT(lir->mir()->lhs()->type() != MIRType_Object ||
lir->mir()->operandMightEmulateUndefined(),
MOZ_ASSERT(lir->cmpMir()->lhs()->type() != MIRType_Object ||
lir->cmpMir()->operandMightEmulateUndefined(),
"Operands which can't emulate undefined should have been folded");
OutOfLineTestObject *ool = nullptr;
if (lir->mir()->operandMightEmulateUndefined()) {
if (lir->cmpMir()->operandMightEmulateUndefined()) {
ool = new(alloc()) OutOfLineTestObject();
if (!addOutOfLineCode(ool))
return false;
@ -4410,12 +4410,12 @@ CodeGenerator::visitEmulatesUndefined(LEmulatesUndefined *lir)
bool
CodeGenerator::visitEmulatesUndefinedAndBranch(LEmulatesUndefinedAndBranch *lir)
{
MOZ_ASSERT(lir->mir()->compareType() == MCompare::Compare_Undefined ||
lir->mir()->compareType() == MCompare::Compare_Null);
MOZ_ASSERT(lir->mir()->operandMightEmulateUndefined(),
MOZ_ASSERT(lir->cmpMir()->compareType() == MCompare::Compare_Undefined ||
lir->cmpMir()->compareType() == MCompare::Compare_Null);
MOZ_ASSERT(lir->cmpMir()->operandMightEmulateUndefined(),
"Operands which can't emulate undefined should have been folded");
JSOp op = lir->mir()->jsop();
JSOp op = lir->cmpMir()->jsop();
MOZ_ASSERT(op == JSOP_EQ || op == JSOP_NE, "Strict equality should have been folded");
OutOfLineTestObject *ool = new(alloc()) OutOfLineTestObject();

View File

@ -1649,13 +1649,15 @@ class LCompare : public LInstructionHelper<1, 2, 0>
// For objects, both operands are in registers.
class LCompareAndBranch : public LControlInstructionHelper<2, 2, 0>
{
MCompare *cmpMir_;
JSOp jsop_;
public:
LIR_HEADER(CompareAndBranch)
LCompareAndBranch(JSOp jsop, const LAllocation &left, const LAllocation &right,
LCompareAndBranch(MCompare *cmpMir, JSOp jsop,
const LAllocation &left, const LAllocation &right,
MBasicBlock *ifTrue, MBasicBlock *ifFalse)
: jsop_(jsop)
: cmpMir_(cmpMir), jsop_(jsop)
{
setOperand(0, left);
setOperand(1, right);
@ -1678,8 +1680,11 @@ class LCompareAndBranch : public LControlInstructionHelper<2, 2, 0>
const LAllocation *right() {
return getOperand(1);
}
MCompare *mir() {
return mir_->toCompare();
MTest *mir() const {
return mir_->toTest();
}
MCompare *cmpMir() const {
return cmpMir_;
}
const char *extraName() const {
return js_CodeName[jsop_];
@ -1728,10 +1733,13 @@ class LCompareF : public LInstructionHelper<1, 2, 0>
class LCompareDAndBranch : public LControlInstructionHelper<2, 2, 0>
{
MCompare *cmpMir_;
public:
LIR_HEADER(CompareDAndBranch)
LCompareDAndBranch(const LAllocation &left, const LAllocation &right,
LCompareDAndBranch(MCompare *cmpMir, const LAllocation &left, const LAllocation &right,
MBasicBlock *ifTrue, MBasicBlock *ifFalse)
: cmpMir_(cmpMir)
{
setOperand(0, left);
setOperand(1, right);
@ -1751,17 +1759,23 @@ class LCompareDAndBranch : public LControlInstructionHelper<2, 2, 0>
const LAllocation *right() {
return getOperand(1);
}
MCompare *mir() {
return mir_->toCompare();
MTest *mir() const {
return mir_->toTest();
}
MCompare *cmpMir() const {
return cmpMir_;
}
};
class LCompareFAndBranch : public LControlInstructionHelper<2, 2, 0>
{
MCompare *cmpMir_;
public:
LIR_HEADER(CompareFAndBranch)
LCompareFAndBranch(const LAllocation &left, const LAllocation &right,
LCompareFAndBranch(MCompare *cmpMir, const LAllocation &left, const LAllocation &right,
MBasicBlock *ifTrue, MBasicBlock *ifFalse)
: cmpMir_(cmpMir)
{
setOperand(0, left);
setOperand(1, right);
@ -1781,8 +1795,11 @@ class LCompareFAndBranch : public LControlInstructionHelper<2, 2, 0>
const LAllocation *right() {
return getOperand(1);
}
MCompare *mir() {
return mir_->toCompare();
MTest *mir() const {
return mir_->toTest();
}
MCompare *cmpMir() const {
return cmpMir_;
}
};
@ -1864,10 +1881,14 @@ class LCompareB : public LInstructionHelper<1, BOX_PIECES + 1, 0>
class LCompareBAndBranch : public LControlInstructionHelper<2, BOX_PIECES + 1, 0>
{
MCompare *cmpMir_;
public:
LIR_HEADER(CompareBAndBranch)
LCompareBAndBranch(const LAllocation &rhs, MBasicBlock *ifTrue, MBasicBlock *ifFalse)
LCompareBAndBranch(MCompare *cmpMir, const LAllocation &rhs,
MBasicBlock *ifTrue, MBasicBlock *ifFalse)
: cmpMir_(cmpMir)
{
setOperand(BOX_PIECES, rhs);
setSuccessor(0, ifTrue);
@ -1886,8 +1907,11 @@ class LCompareBAndBranch : public LControlInstructionHelper<2, BOX_PIECES + 1, 0
MBasicBlock *ifFalse() const {
return getSuccessor(1);
}
MCompare *mir() {
return mir_->toCompare();
MTest *mir() const {
return mir_->toTest();
}
MCompare *cmpMir() const {
return cmpMir_;
}
};
@ -1906,13 +1930,16 @@ class LCompareV : public LInstructionHelper<1, 2 * BOX_PIECES, 0>
class LCompareVAndBranch : public LControlInstructionHelper<2, 2 * BOX_PIECES, 0>
{
MCompare *cmpMir_;
public:
LIR_HEADER(CompareVAndBranch)
static const size_t LhsInput = 0;
static const size_t RhsInput = BOX_PIECES;
LCompareVAndBranch(MBasicBlock *ifTrue, MBasicBlock *ifFalse)
LCompareVAndBranch(MCompare *cmpMir, MBasicBlock *ifTrue, MBasicBlock *ifFalse)
: cmpMir_(cmpMir)
{
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
@ -1924,8 +1951,11 @@ class LCompareVAndBranch : public LControlInstructionHelper<2, 2 * BOX_PIECES, 0
MBasicBlock *ifFalse() const {
return getSuccessor(1);
}
MCompare *mir() {
return mir_->toCompare();
MTest *mir() const {
return mir_->toTest();
}
MCompare *cmpMir() const {
return cmpMir_;
}
};
@ -1964,9 +1994,6 @@ class LBitAndAndBranch : public LControlInstructionHelper<2, 2, 0>
const LAllocation *right() {
return getOperand(1);
}
MCompare *mir() {
return mir_->toCompare();
}
};
class LIsNullOrLikeUndefined : public LInstructionHelper<1, BOX_PIECES, 2>
@ -1997,10 +2024,14 @@ class LIsNullOrLikeUndefined : public LInstructionHelper<1, BOX_PIECES, 2>
class LIsNullOrLikeUndefinedAndBranch : public LControlInstructionHelper<2, BOX_PIECES, 2>
{
MCompare *cmpMir_;
public:
LIR_HEADER(IsNullOrLikeUndefinedAndBranch)
LIsNullOrLikeUndefinedAndBranch(MBasicBlock *ifTrue, MBasicBlock *ifFalse, const LDefinition &temp, const LDefinition &tempToUnbox)
LIsNullOrLikeUndefinedAndBranch(MCompare *cmpMir, MBasicBlock *ifTrue, MBasicBlock *ifFalse,
const LDefinition &temp, const LDefinition &tempToUnbox)
: cmpMir_(cmpMir)
{
setSuccessor(0, ifTrue);
setSuccessor(1, ifFalse);
@ -2016,8 +2047,11 @@ class LIsNullOrLikeUndefinedAndBranch : public LControlInstructionHelper<2, BOX_
MBasicBlock *ifFalse() const {
return getSuccessor(1);
}
MCompare *mir() {
return mir_->toCompare();
MTest *mir() const {
return mir_->toTest();
}
MCompare *cmpMir() const {
return cmpMir_;
}
const LDefinition *temp() {
return getTemp(0);
@ -2047,10 +2081,15 @@ class LEmulatesUndefined : public LInstructionHelper<1, 1, 0>
class LEmulatesUndefinedAndBranch : public LControlInstructionHelper<2, 1, 1>
{
MCompare *cmpMir_;
public:
LIR_HEADER(EmulatesUndefinedAndBranch)
LEmulatesUndefinedAndBranch(const LAllocation &input, MBasicBlock *ifTrue, MBasicBlock *ifFalse, const LDefinition &temp)
LEmulatesUndefinedAndBranch(MCompare *cmpMir, const LAllocation &input,
MBasicBlock *ifTrue, MBasicBlock *ifFalse,
const LDefinition &temp)
: cmpMir_(cmpMir)
{
setOperand(0, input);
setSuccessor(0, ifTrue);
@ -2064,8 +2103,11 @@ class LEmulatesUndefinedAndBranch : public LControlInstructionHelper<2, 1, 1>
MBasicBlock *ifFalse() const {
return getSuccessor(1);
}
MCompare *mir() {
return mir_->toCompare();
MTest *mir() const {
return mir_->toTest();
}
MCompare *cmpMir() const {
return cmpMir_;
}
const LDefinition *temp() {
return getTemp(0);

View File

@ -110,7 +110,7 @@ LIRGenerator::visitCheckOverRecursed(MCheckOverRecursed *ins)
{
LCheckOverRecursed *lir = new(alloc()) LCheckOverRecursed();
if (!add(lir))
if (!add(lir, ins))
return false;
if (!assignSafepoint(lir, ins))
return false;
@ -736,8 +736,9 @@ LIRGenerator::visitTest(MTest *test)
"MCompare::tryFold should handle the never-emulates-undefined case");
LEmulatesUndefinedAndBranch *lir =
new(alloc()) LEmulatesUndefinedAndBranch(useRegister(left), ifTrue, ifFalse, temp());
return add(lir, comp);
new(alloc()) LEmulatesUndefinedAndBranch(comp, useRegister(left),
ifTrue, ifFalse, temp());
return add(lir, test);
}
LDefinition tmp, tmpToUnbox;
@ -750,10 +751,11 @@ LIRGenerator::visitTest(MTest *test)
}
LIsNullOrLikeUndefinedAndBranch *lir =
new(alloc()) LIsNullOrLikeUndefinedAndBranch(ifTrue, ifFalse, tmp, tmpToUnbox);
new(alloc()) LIsNullOrLikeUndefinedAndBranch(comp, ifTrue, ifFalse,
tmp, tmpToUnbox);
if (!useBox(lir, LIsNullOrLikeUndefinedAndBranch::Value, left))
return false;
return add(lir, comp);
return add(lir, test);
}
// Compare and branch booleans.
@ -762,10 +764,10 @@ LIRGenerator::visitTest(MTest *test)
JS_ASSERT(right->type() == MIRType_Boolean);
LAllocation rhs = useRegisterOrConstant(right);
LCompareBAndBranch *lir = new(alloc()) LCompareBAndBranch(rhs, ifTrue, ifFalse);
LCompareBAndBranch *lir = new(alloc()) LCompareBAndBranch(comp, rhs, ifTrue, ifFalse);
if (!useBox(lir, LCompareBAndBranch::Lhs, left))
return false;
return add(lir, comp);
return add(lir, test);
}
// Compare and branch Int32 or Object pointers.
@ -780,34 +782,37 @@ LIRGenerator::visitTest(MTest *test)
rhs = useAnyOrConstant(right);
else
rhs = useRegister(right);
LCompareAndBranch *lir = new(alloc()) LCompareAndBranch(op, lhs, rhs, ifTrue, ifFalse);
return add(lir, comp);
LCompareAndBranch *lir = new(alloc()) LCompareAndBranch(comp, op, lhs, rhs,
ifTrue, ifFalse);
return add(lir, test);
}
// Compare and branch doubles.
if (comp->isDoubleComparison()) {
LAllocation lhs = useRegister(left);
LAllocation rhs = useRegister(right);
LCompareDAndBranch *lir = new(alloc()) LCompareDAndBranch(lhs, rhs, ifTrue, ifFalse);
return add(lir, comp);
LCompareDAndBranch *lir = new(alloc()) LCompareDAndBranch(comp, lhs, rhs,
ifTrue, ifFalse);
return add(lir, test);
}
// Compare and branch floats.
if (comp->isFloat32Comparison()) {
LAllocation lhs = useRegister(left);
LAllocation rhs = useRegister(right);
LCompareFAndBranch *lir = new(alloc()) LCompareFAndBranch(lhs, rhs, ifTrue, ifFalse);
return add(lir, comp);
LCompareFAndBranch *lir = new(alloc()) LCompareFAndBranch(comp, lhs, rhs,
ifTrue, ifFalse);
return add(lir, test);
}
// Compare values.
if (comp->compareType() == MCompare::Compare_Value) {
LCompareVAndBranch *lir = new(alloc()) LCompareVAndBranch(ifTrue, ifFalse);
LCompareVAndBranch *lir = new(alloc()) LCompareVAndBranch(comp, ifTrue, ifFalse);
if (!useBoxAtStart(lir, LCompareVAndBranch::LhsInput, left))
return false;
if (!useBoxAtStart(lir, LCompareVAndBranch::RhsInput, right))
return false;
return add(lir, comp);
return add(lir, test);
}
}
@ -2080,12 +2085,12 @@ LIRGenerator::visitInterruptCheck(MInterruptCheck *ins)
#ifndef JS_CPU_ARM
if (GetIonContext()->runtime->signalHandlersInstalled()) {
LInterruptCheckImplicit *lir = new(alloc()) LInterruptCheckImplicit();
return add(lir) && assignSafepoint(lir, ins);
return add(lir, ins) && assignSafepoint(lir, ins);
}
#endif
LInterruptCheck *lir = new(alloc()) LInterruptCheck();
return add(lir) && assignSafepoint(lir, ins);
return add(lir, ins) && assignSafepoint(lir, ins);
}
bool

View File

@ -1277,6 +1277,9 @@ class MTest
static MTest *New(TempAllocator &alloc, MDefinition *ins,
MBasicBlock *ifTrue, MBasicBlock *ifFalse);
MDefinition *input() const {
return getOperand(0);
}
MBasicBlock *ifTrue() const {
return getSuccessor(0);
}

View File

@ -134,7 +134,7 @@ CodeGeneratorARM::visitCompare(LCompare *comp)
bool
CodeGeneratorARM::visitCompareAndBranch(LCompareAndBranch *comp)
{
Assembler::Condition cond = JSOpToCondition(comp->mir()->compareType(), comp->jsop());
Assembler::Condition cond = JSOpToCondition(comp->cmpMir()->compareType(), comp->jsop());
if (comp->right()->isConstant())
masm.ma_cmp(ToRegister(comp->left()), Imm32(ToInt32(comp->right())));
else
@ -1460,7 +1460,7 @@ CodeGeneratorARM::visitCompareDAndBranch(LCompareDAndBranch *comp)
FloatRegister lhs = ToFloatRegister(comp->left());
FloatRegister rhs = ToFloatRegister(comp->right());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->mir()->jsop());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->cmpMir()->jsop());
masm.compareDouble(lhs, rhs);
emitBranch(Assembler::ConditionFromDoubleCondition(cond), comp->ifTrue(), comp->ifFalse());
return true;
@ -1472,7 +1472,7 @@ CodeGeneratorARM::visitCompareFAndBranch(LCompareFAndBranch *comp)
FloatRegister lhs = ToFloatRegister(comp->left());
FloatRegister rhs = ToFloatRegister(comp->right());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->mir()->jsop());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->cmpMir()->jsop());
masm.compareFloat(lhs, rhs);
emitBranch(Assembler::ConditionFromDoubleCondition(cond), comp->ifTrue(), comp->ifFalse());
return true;
@ -1512,7 +1512,7 @@ CodeGeneratorARM::visitCompareB(LCompareB *lir)
bool
CodeGeneratorARM::visitCompareBAndBranch(LCompareBAndBranch *lir)
{
MCompare *mir = lir->mir();
MCompare *mir = lir->cmpMir();
const ValueOperand lhs = ToValue(lir, LCompareBAndBranch::Lhs);
const LAllocation *rhs = lir->rhs();
@ -1561,7 +1561,7 @@ CodeGeneratorARM::visitCompareV(LCompareV *lir)
bool
CodeGeneratorARM::visitCompareVAndBranch(LCompareVAndBranch *lir)
{
MCompare *mir = lir->mir();
MCompare *mir = lir->cmpMir();
Assembler::Condition cond = JSOpToCondition(mir->compareType(), mir->jsop());
const ValueOperand lhs = ToValue(lir, LCompareVAndBranch::LhsInput);
const ValueOperand rhs = ToValue(lir, LCompareVAndBranch::RhsInput);

View File

@ -115,6 +115,7 @@ CodeGeneratorShared::addOutOfLineCode(OutOfLineCode *code)
code->setSource(oolIns->script(), oolIns->pc());
else
code->setSource(current ? current->mir()->info().script() : nullptr, lastPC_);
JS_ASSERT_IF(code->script(), code->script()->containsPC(code->pc()));
return outOfLineCode_.append(code);
}

View File

@ -180,7 +180,7 @@ CodeGeneratorX86Shared::visitCompare(LCompare *comp)
bool
CodeGeneratorX86Shared::visitCompareAndBranch(LCompareAndBranch *comp)
{
MCompare *mir = comp->mir();
MCompare *mir = comp->cmpMir();
emitCompare(mir->compareType(), comp->left(), comp->right());
Assembler::Condition cond = JSOpToCondition(mir->compareType(), comp->jsop());
emitBranch(cond, comp->ifTrue(), comp->ifFalse());
@ -269,10 +269,10 @@ CodeGeneratorX86Shared::visitCompareDAndBranch(LCompareDAndBranch *comp)
FloatRegister lhs = ToFloatRegister(comp->left());
FloatRegister rhs = ToFloatRegister(comp->right());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->mir()->jsop());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->cmpMir()->jsop());
Assembler::NaNCond nanCond = Assembler::NaNCondFromDoubleCondition(cond);
if (comp->mir()->operandsAreNeverNaN())
if (comp->cmpMir()->operandsAreNeverNaN())
nanCond = Assembler::NaN_HandledByCond;
masm.compareDouble(cond, lhs, rhs);
@ -286,10 +286,10 @@ CodeGeneratorX86Shared::visitCompareFAndBranch(LCompareFAndBranch *comp)
FloatRegister lhs = ToFloatRegister(comp->left());
FloatRegister rhs = ToFloatRegister(comp->right());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->mir()->jsop());
Assembler::DoubleCondition cond = JSOpToDoubleCondition(comp->cmpMir()->jsop());
Assembler::NaNCond nanCond = Assembler::NaNCondFromDoubleCondition(cond);
if (comp->mir()->operandsAreNeverNaN())
if (comp->cmpMir()->operandsAreNeverNaN())
nanCond = Assembler::NaN_HandledByCond;
masm.compareFloat(cond, lhs, rhs);

View File

@ -446,8 +446,10 @@ LIRGeneratorShared::add(T *ins, MInstruction *mir)
{
JS_ASSERT(!ins->isPhi());
current->add(ins);
if (mir)
if (mir) {
JS_ASSERT(current == mir->block()->lir());
ins->setMir(mir);
}
annotate(ins);
return true;
}

View File

@ -313,7 +313,7 @@ CodeGeneratorX64::visitCompareB(LCompareB *lir)
bool
CodeGeneratorX64::visitCompareBAndBranch(LCompareBAndBranch *lir)
{
MCompare *mir = lir->mir();
MCompare *mir = lir->cmpMir();
const ValueOperand lhs = ToValue(lir, LCompareBAndBranch::Lhs);
const LAllocation *rhs = lir->rhs();
@ -349,7 +349,7 @@ CodeGeneratorX64::visitCompareV(LCompareV *lir)
bool
CodeGeneratorX64::visitCompareVAndBranch(LCompareVAndBranch *lir)
{
MCompare *mir = lir->mir();
MCompare *mir = lir->cmpMir();
const ValueOperand lhs = ToValue(lir, LCompareVAndBranch::LhsInput);
const ValueOperand rhs = ToValue(lir, LCompareVAndBranch::RhsInput);

View File

@ -310,7 +310,7 @@ CodeGeneratorX86::visitCompareB(LCompareB *lir)
bool
CodeGeneratorX86::visitCompareBAndBranch(LCompareBAndBranch *lir)
{
MCompare *mir = lir->mir();
MCompare *mir = lir->cmpMir();
const ValueOperand lhs = ToValue(lir, LCompareBAndBranch::Lhs);
const LAllocation *rhs = lir->rhs();
@ -358,7 +358,7 @@ CodeGeneratorX86::visitCompareV(LCompareV *lir)
bool
CodeGeneratorX86::visitCompareVAndBranch(LCompareVAndBranch *lir)
{
MCompare *mir = lir->mir();
MCompare *mir = lir->cmpMir();
Assembler::Condition cond = JSOpToCondition(mir->compareType(), mir->jsop());
const ValueOperand lhs = ToValue(lir, LCompareVAndBranch::LhsInput);
const ValueOperand rhs = ToValue(lir, LCompareVAndBranch::RhsInput);