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

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

Issue 106733002: Improve check elimination with branch sensitivity on HCompareObjectEqAndBranch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Split variable declarations onto multiple lines. Created 7 years 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
« no previous file with comments | « no previous file | src/unique.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-check-elimination.cc
diff --git a/src/hydrogen-check-elimination.cc b/src/hydrogen-check-elimination.cc
index bbd3042fb7af6659f4107fffb7127e1298000593..ae11042ba1e449b3c33b2d036ca36477165142d6 100644
--- a/src/hydrogen-check-elimination.cc
+++ b/src/hydrogen-check-elimination.cc
@@ -127,9 +127,14 @@ class HCheckTable : public ZoneObject {
new_entry->check_ = NULL;
new_entry->maps_ = old_entry->maps_->Copy(phase_->zone());
}
- if (succ->predecessors()->length() == 1) {
- HControlInstruction* end = succ->predecessors()->at(0)->end();
- if (end->IsCompareMap() && end->SuccessorAt(0) == succ) {
+ copy->cursor_ = cursor_;
+ copy->size_ = size_;
+
+ // 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) {
+ if (end->IsCompareMap()) {
// Learn on the true branch of if(CompareMap(x)).
HCompareMap* cmp = HCompareMap::cast(end);
HValue* object = cmp->value()->ActualValue();
@@ -141,9 +146,29 @@ class HCheckTable : public ZoneObject {
list->Add(cmp->map(), phase_->zone());
entry->maps_ = list;
}
+ } else if (end->IsCompareObjectEqAndBranch()) {
+ // Learn on the true branch of if(CmpObjectEq(x, y)).
+ HCompareObjectEqAndBranch* cmp =
+ HCompareObjectEqAndBranch::cast(end);
+ HValue* left = cmp->left()->ActualValue();
+ HValue* right = cmp->right()->ActualValue();
+ HCheckTableEntry* le = copy->Find(left);
+ HCheckTableEntry* re = copy->Find(right);
+ if (le == NULL) {
+ if (re != NULL) {
+ copy->Insert(left, NULL, re->maps_->Copy(zone));
+ }
+ } else if (re == NULL) {
+ copy->Insert(right, NULL, le->maps_->Copy(zone));
+ } else {
+ MapSet intersect = le->maps_->Intersect(re->maps_, zone);
+ le->maps_ = intersect;
+ re->maps_ = intersect->Copy(zone);
+ }
}
- // TODO(titzer): is it worthwhile to learn on false branch too?
+ // Learning on false branches requires storing negative facts.
}
+
return copy;
}
« no previous file with comments | « no previous file | src/unique.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698