Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 4377b420705755d36223b319fc2119ab40bfcd42..f924307993a2835b3aadf6f2da06fe9b0b4e5c8e 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -313,6 +313,30 @@ int HBasicBlock::LoopNestingDepth() const { |
} |
+void HBasicBlock::ReplaceControlWithGotoSuccessor(int succ) { |
+ ASSERT(IsFinished()); |
+ ASSERT(end()->SuccessorCount() == 2); // Only this case is supported yet. |
+ ASSERT(succ < end()->SuccessorCount()); |
+ |
+ int unreachable_succ = 1 - succ; |
+ |
+ // Replace control instruction with if (true) {succ} else {unreachable_succ}. |
+ HBranch* new_branch = HBranch::New( |
+ zone(), |
+ NULL, |
+ graph()->GetConstantTrue(), |
+ ToBooleanStub::Types(ToBooleanStub::BOOLEAN), |
+ end()->SuccessorAt(succ), |
+ end()->SuccessorAt(unreachable_succ)); |
+ |
+ MarkSuccEdgeUnreachable(unreachable_succ); |
+ |
+ end()->DeleteAndReplaceWith(end()->ActualValue()); |
Jakob Kummerow
2014/01/15 10:30:19
As discussed offline, this is a bug.
Some instruc
|
+ new_branch->InsertAfter(last()); |
+ end_ = new_branch; |
+} |
+ |
+ |
void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { |
ASSERT(IsLoopHeader()); |
@@ -331,6 +355,15 @@ void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { |
} |
+void HBasicBlock::MarkSuccEdgeUnreachable(int succ) { |
+ ASSERT(IsFinished()); |
+ HBasicBlock* succ_block = end()->SuccessorAt(succ); |
+ |
+ ASSERT(succ_block->predecessors()->length() == 1); |
+ succ_block->MarkUnreachable(); |
+} |
+ |
+ |
void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) { |
if (HasPredecessor()) { |
// Only loop header blocks can have a predecessor added after |