Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: src/hydrogen-check-elimination.cc

Issue 130613003: Eliminatable CheckMaps replaced with if(true) or if(false). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes applied, rev.2 Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/hydrogen-check-elimination.cc
diff --git a/src/hydrogen-check-elimination.cc b/src/hydrogen-check-elimination.cc
index ae11042ba1e449b3c33b2d036ca36477165142d6..90e8450c821a17081c8bbd7dc9991ee28e792070 100644
--- a/src/hydrogen-check-elimination.cc
+++ b/src/hydrogen-check-elimination.cc
@@ -132,8 +132,10 @@ class HCheckTable : public ZoneObject {
// Branch-sensitive analysis for certain comparisons may add more facts
// to the state for the successor on the true branch.
- HControlInstruction* end = succ->predecessors()->at(0)->end();
- if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ) {
+ HBasicBlock* pred_block = succ->predecessors()->at(0);
+ HControlInstruction* end = pred_block->end();
+ if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ &&
+ pred_block->IsReachable()) {
if (end->IsCompareMap()) {
// Learn on the true branch of if(CompareMap(x)).
HCompareMap* cmp = HCompareMap::cast(end);
@@ -311,14 +313,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);
}
}
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | src/hydrogen-flow-engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698