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

Unified Diff: src/hydrogen-instructions.cc

Issue 12079042: Base iDef update code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments. Created 7 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
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 4f8af2b0c041f429b1992213a8f4d7571dd5bea4..4163b50045d8c61a114efbe119d5566e9f24db2e 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -364,6 +364,54 @@ HType HType::TypeFromValue(Handle<Object> value) {
}
+bool HValue::Dominates(HValue* dominator, HValue* dominated) {
+ if (dominator->block() != dominated->block()) {
+ // If they are in different blocks we can use the dominance relation
+ // between the blocks.
+ return dominator->block()->Dominates(dominated->block());
+ } else {
+ // Otherwise we must see which instruction comes first, considering
+ // that phis always precede regular instructions.
+ if (dominator->IsInstruction()) {
+ if (dominated->IsInstruction()) {
+ for (HInstruction* next = HInstruction::cast(dominator)->next();
+ next != NULL;
+ next = next->next()) {
+ if (next == dominated) return true;
+ }
+ return false;
+ } else if (dominated->IsPhi()) {
+ return false;
+ } else {
+ UNREACHABLE();
+ }
+ } else if (dominator->IsPhi()) {
+ if (dominated->IsInstruction()) {
+ return true;
+ } else {
+ // We cannot compare which phi comes first.
+ UNREACHABLE();
+ }
+ } else {
+ UNREACHABLE();
+ }
+ return false;
+ }
+}
+
+
+bool HValue::TestDominanceUsingProcessedFlag(HValue* dominator,
+ HValue* dominated) {
+ if (dominator->block() != dominated->block()) {
+ return dominator->block()->Dominates(dominated->block());
+ } else {
+ // If both arguments are in the same block we check if "dominator" has
+ // already been processed or if it is a phi: if yes it dominates the other.
+ return dominator->CheckFlag(kIDefsProcessingDone) || dominator->IsPhi();
+ }
+}
+
+
bool HValue::IsDefinedAfter(HBasicBlock* other) const {
return block()->block_id() > other->block_id();
}
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698