Bug 1019304 - Part 4: Add MUnreachable to end basic blocks that have bails in them. (r=sunfish)

This commit is contained in:
Shu-yu Guo 2014-06-20 18:39:14 -07:00
parent 027da740ee
commit eb1c87ada9
9 changed files with 53 additions and 21 deletions

View File

@ -2711,6 +2711,13 @@ CodeGenerator::visitBail(LBail *lir)
return bailout(lir->snapshot()); return bailout(lir->snapshot());
} }
bool
CodeGenerator::visitUnreachable(LUnreachable *lir)
{
masm.assumeUnreachable("end-of-block assumed unreachable");
return true;
}
bool bool
CodeGenerator::visitGetDynamicName(LGetDynamicName *lir) CodeGenerator::visitGetDynamicName(LGetDynamicName *lir)
{ {

View File

@ -131,6 +131,7 @@ class CodeGenerator : public CodeGeneratorSpecific
void emitPopArguments(LApplyArgsGeneric *apply, Register extraStackSize); void emitPopArguments(LApplyArgsGeneric *apply, Register extraStackSize);
bool visitApplyArgsGeneric(LApplyArgsGeneric *apply); bool visitApplyArgsGeneric(LApplyArgsGeneric *apply);
bool visitBail(LBail *lir); bool visitBail(LBail *lir);
bool visitUnreachable(LUnreachable *unreachable);
bool visitGetDynamicName(LGetDynamicName *lir); bool visitGetDynamicName(LGetDynamicName *lir);
bool visitFilterArgumentsOrEvalS(LFilterArgumentsOrEvalS *lir); bool visitFilterArgumentsOrEvalS(LFilterArgumentsOrEvalS *lir);
bool visitFilterArgumentsOrEvalV(LFilterArgumentsOrEvalV *lir); bool visitFilterArgumentsOrEvalV(LFilterArgumentsOrEvalV *lir);

View File

@ -1199,6 +1199,12 @@ class LBail : public LInstructionHelper<0, 0, 0>
LIR_HEADER(Bail) LIR_HEADER(Bail)
}; };
class LUnreachable : public LControlInstructionHelper<0, 0, 0>
{
public:
LIR_HEADER(Unreachable)
};
template <size_t defs, size_t ops> template <size_t defs, size_t ops>
class LDOMPropertyInstructionHelper : public LCallInstructionHelper<defs, 1 + ops, 3> class LDOMPropertyInstructionHelper : public LCallInstructionHelper<defs, 1 + ops, 3>
{ {

View File

@ -48,6 +48,7 @@
_(CallNative) \ _(CallNative) \
_(ApplyArgsGeneric) \ _(ApplyArgsGeneric) \
_(Bail) \ _(Bail) \
_(Unreachable) \
_(GetDynamicName) \ _(GetDynamicName) \
_(FilterArgumentsOrEvalS) \ _(FilterArgumentsOrEvalS) \
_(FilterArgumentsOrEvalV) \ _(FilterArgumentsOrEvalV) \

View File

@ -498,6 +498,13 @@ LIRGenerator::visitBail(MBail *bail)
return assignSnapshot(lir, bail->bailoutKind()) && add(lir, bail); return assignSnapshot(lir, bail->bailoutKind()) && add(lir, bail);
} }
bool
LIRGenerator::visitUnreachable(MUnreachable *unreachable)
{
LUnreachable *lir = new(alloc()) LUnreachable();
return add(lir, unreachable);
}
bool bool
LIRGenerator::visitAssertFloat32(MAssertFloat32 *assertion) LIRGenerator::visitAssertFloat32(MAssertFloat32 *assertion)
{ {

View File

@ -99,6 +99,7 @@ class LIRGenerator : public LIRGeneratorSpecific
bool visitApplyArgs(MApplyArgs *apply); bool visitApplyArgs(MApplyArgs *apply);
bool visitArraySplice(MArraySplice *splice); bool visitArraySplice(MArraySplice *splice);
bool visitBail(MBail *bail); bool visitBail(MBail *bail);
bool visitUnreachable(MUnreachable *unreachable);
bool visitAssertFloat32(MAssertFloat32 *ins); bool visitAssertFloat32(MAssertFloat32 *ins);
bool visitGetDynamicName(MGetDynamicName *ins); bool visitGetDynamicName(MGetDynamicName *ins);
bool visitFilterArgumentsOrEval(MFilterArgumentsOrEval *ins); bool visitFilterArgumentsOrEval(MFilterArgumentsOrEval *ins);

View File

@ -2274,11 +2274,11 @@ class MApplyArgs
} }
}; };
class MBail : public MAryControlInstruction<0, 0> class MBail : public MNullaryInstruction
{ {
protected: protected:
MBail(BailoutKind kind) MBail(BailoutKind kind)
: MAryControlInstruction<0, 0>() : MNullaryInstruction()
{ {
bailoutKind_ = kind; bailoutKind_ = kind;
setGuard(); setGuard();
@ -2308,6 +2308,20 @@ class MBail : public MAryControlInstruction<0, 0>
} }
}; };
class MUnreachable : public MAryControlInstruction<0, 0>
{
public:
INSTRUCTION_HEADER(Unreachable)
static MUnreachable *New(TempAllocator &alloc) {
return new(alloc) MUnreachable();
}
AliasSet getAliasSet() const {
return AliasSet::None();
}
};
class MAssertFloat32 : public MUnaryInstruction class MAssertFloat32 : public MUnaryInstruction
{ {
protected: protected:

View File

@ -43,6 +43,7 @@ namespace jit {
_(ApplyArgs) \ _(ApplyArgs) \
_(ArraySplice) \ _(ArraySplice) \
_(Bail) \ _(Bail) \
_(Unreachable) \
_(AssertFloat32) \ _(AssertFloat32) \
_(GetDynamicName) \ _(GetDynamicName) \
_(FilterArgumentsOrEval) \ _(FilterArgumentsOrEval) \

View File

@ -75,7 +75,6 @@ class ParallelSafetyVisitor : public MInstructionVisitor
bool replaceWithNewPar(MInstruction *newInstruction, JSObject *templateObject); bool replaceWithNewPar(MInstruction *newInstruction, JSObject *templateObject);
bool replace(MInstruction *oldInstruction, MInstruction *replacementInstruction); bool replace(MInstruction *oldInstruction, MInstruction *replacementInstruction);
bool replaceLastIns(MInstruction *oldInstruction, MControlInstruction *replacementInstruction);
bool visitSpecializedInstruction(MInstruction *ins, MIRType spec, uint32_t flags); bool visitSpecializedInstruction(MInstruction *ins, MIRType spec, uint32_t flags);
@ -141,7 +140,8 @@ class ParallelSafetyVisitor : public MInstructionVisitor
CUSTOM_OP(Call) CUSTOM_OP(Call)
UNSAFE_OP(ApplyArgs) UNSAFE_OP(ApplyArgs)
UNSAFE_OP(ArraySplice) UNSAFE_OP(ArraySplice)
UNSAFE_OP(Bail) SAFE_OP(Bail)
SAFE_OP(Unreachable)
UNSAFE_OP(AssertFloat32) UNSAFE_OP(AssertFloat32)
UNSAFE_OP(GetDynamicName) UNSAFE_OP(GetDynamicName)
UNSAFE_OP(FilterArgumentsOrEval) UNSAFE_OP(FilterArgumentsOrEval)
@ -438,10 +438,11 @@ ParallelSafetyVisitor::convertToBailout(MInstructionIterator &iter)
block->getSuccessor(i)->removePredecessor(block); block->getSuccessor(i)->removePredecessor(block);
block->discardAllInstructionsStartingAt(iter); block->discardAllInstructionsStartingAt(iter);
// End the block in the bail. // End the block in a bail.
MBail *bailout = MBail::New(graph_.alloc()); MBail *bail = MBail::New(graph_.alloc());
TransplantResumePoint(ins, bailout); TransplantResumePoint(ins, bail);
block->end(bailout); block->add(bail);
block->end(MUnreachable::New(alloc()));
return true; return true;
} }
@ -589,17 +590,6 @@ ParallelSafetyVisitor::replace(MInstruction *oldInstruction,
return true; return true;
} }
bool
ParallelSafetyVisitor::replaceLastIns(MInstruction *oldInstruction,
MControlInstruction *replacementInstruction)
{
TransplantResumePoint(oldInstruction, replacementInstruction);
MBasicBlock *block = oldInstruction->block();
block->discardLastIns();
block->end(replacementInstruction);
return true;
}
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Write Guards // Write Guards
// //
@ -763,8 +753,12 @@ ParallelSafetyVisitor::visitSpecializedInstruction(MInstruction *ins, MIRType sp
bool bool
ParallelSafetyVisitor::visitThrow(MThrow *thr) ParallelSafetyVisitor::visitThrow(MThrow *thr)
{ {
JS_ASSERT(thr->block()->lastIns() == thr); MBasicBlock *block = thr->block();
replaceLastIns(thr, MBail::New(alloc())); JS_ASSERT(block->lastIns() == thr);
MBail *bail = MBail::New(alloc());
TransplantResumePoint(thr, bail);
block->discardLastIns();
block->end(MUnreachable::New(alloc()));
return true; return true;
} }