Index: src/hydrogen-check-elimination.cc |
diff --git a/src/hydrogen-check-elimination.cc b/src/hydrogen-check-elimination.cc |
index ae11042ba1e449b3c33b2d036ca36477165142d6..96d18dc990c3113de16eb7093e5a0a43fde0b95e 100644 |
--- a/src/hydrogen-check-elimination.cc |
+++ b/src/hydrogen-check-elimination.cc |
@@ -118,6 +118,8 @@ class HCheckTable : public ZoneObject { |
// Global analysis: Copy state to successor block. |
HCheckTable* Copy(HBasicBlock* succ, Zone* zone) { |
+ ASSERT(succ->IsReachable()); |
+ |
HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); |
for (int i = 0; i < size_; i++) { |
HCheckTableEntry* old_entry = &entries_[i]; |
@@ -174,6 +176,8 @@ class HCheckTable : public ZoneObject { |
// Global analysis: Merge this state with the other incoming state. |
HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) { |
+ ASSERT(succ->IsReachable()); |
+ |
if (that->size_ == 0) { |
// If the other state is empty, simply reset. |
size_ = 0; |
@@ -311,14 +315,27 @@ class HCheckTable : public ZoneObject { |
void ReduceCompareMap(HCompareMap* instr) { |
MapSet maps = FindMaps(instr->value()->ActualValue()); |
if (maps == NULL) return; |
+ |
+ TRACE(("CompareMap for #%d at B%d ", |
+ instr->value()->ActualValue()->id(), instr->block()->block_id())); |
+ |
if (maps->Contains(instr->map())) { |
if (maps->size() == 1) { |
- // TODO(titzer): replace with goto true branch |
INC_STAT(compares_true_); |
+ |
+ TRACE(("replaced with goto B%d (true target)\n", |
+ instr->SuccessorAt(0)->block_id())); |
+ |
+ instr->block()->ReplaceControlWithGotoSuccessor(0); |
+ } else { |
+ TRACE(("can't be replaced with goto: ambiguous set of maps\n")); |
} |
} else { |
- // TODO(titzer): replace with goto false branch |
INC_STAT(compares_false_); |
+ TRACE(("replaced with goto B%d (false target)\n", |
+ instr->SuccessorAt(1)->block_id())); |
+ |
+ instr->block()->ReplaceControlWithGotoSuccessor(1); |
} |
} |