diff --git a/js/src/jit/MIRGraph.cpp b/js/src/jit/MIRGraph.cpp index 9d93b7f11cc..56501a47dc6 100644 --- a/js/src/jit/MIRGraph.cpp +++ b/js/src/jit/MIRGraph.cpp @@ -758,16 +758,6 @@ MBasicBlock::moveBefore(MInstruction *at, MInstruction *ins) ins->setTrackedSite(at->trackedSite()); } -static inline void -AssertSafelyDiscardable(MDefinition *def) -{ -#ifdef DEBUG - // Instructions captured by resume points cannot be safely discarded, since - // they are necessary for interpreter frame reconstruction in case of bailout. - JS_ASSERT(!def->hasUses()); -#endif -} - void MBasicBlock::discardResumePoint(MResumePoint *rp, ReferencesType refType /* = RefType_Default */) { @@ -800,9 +790,11 @@ MBasicBlock::prepareForDiscard(MInstruction *ins, ReferencesType refType /* = Re // point. MOZ_ASSERT_IF(refType & RefType_AssertNoUses, !ins->hasUses()); - MOZ_ASSERT(refType & RefType_DiscardOperands); - for (size_t i = 0, e = ins->numOperands(); i < e; i++) - ins->discardOperand(i); + const uint32_t InstructionOperands = RefType_DiscardOperands | RefType_DiscardInstruction; + if ((refType & InstructionOperands) == InstructionOperands) { + for (size_t i = 0, e = ins->numOperands(); i < e; i++) + ins->discardOperand(i); + } ins->setDiscarded(); } @@ -817,12 +809,12 @@ MBasicBlock::discard(MInstruction *ins) void MBasicBlock::discardIgnoreOperands(MInstruction *ins) { - AssertSafelyDiscardable(ins); #ifdef DEBUG for (size_t i = 0, e = ins->numOperands(); i < e; i++) JS_ASSERT(ins->operandDiscarded(i)); #endif + prepareForDiscard(ins, RefType_IgnoreOperands); instructions_.remove(ins); } diff --git a/js/src/jit/MIRGraph.h b/js/src/jit/MIRGraph.h index e37dc680492..d1745e65521 100644 --- a/js/src/jit/MIRGraph.h +++ b/js/src/jit/MIRGraph.h @@ -66,11 +66,29 @@ class MBasicBlock : public TempObject, public InlineListNode enum ReferencesType { RefType_None = 0, + + // Assert that the instruction is unused. RefType_AssertNoUses = 1 << 0, + + // Discard the operands of the resume point / instructions if the + // following flag are given too. RefType_DiscardOperands = 1 << 1, RefType_DiscardResumePoint = 1 << 2, - RefType_DefaultNoAssert = RefType_DiscardOperands | RefType_DiscardResumePoint, - RefType_Default = RefType_AssertNoUses | RefType_DiscardOperands | RefType_DiscardResumePoint + RefType_DiscardInstruction = 1 << 3, + + // Discard operands of the instruction and its resume point. + RefType_DefaultNoAssert = RefType_DiscardOperands | + RefType_DiscardResumePoint | + RefType_DiscardInstruction, + + // Discard everything and assert that the instruction is not used. + RefType_Default = RefType_AssertNoUses | RefType_DefaultNoAssert, + + // Discard resume point operands only, without discarding the operands + // of the current instruction. Asserts that the instruction is unused. + RefType_IgnoreOperands = RefType_AssertNoUses | + RefType_DiscardOperands | + RefType_DiscardResumePoint }; void discardResumePoint(MResumePoint *rp, ReferencesType refType = RefType_Default);