Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index 4f8af2b0c041f429b1992213a8f4d7571dd5bea4..b1e3a943537f3602f83b188e9b08921a63fecc0f 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -364,6 +364,54 @@ HType HType::TypeFromValue(Handle<Object> value) { |
} |
+bool HValue::CheckDominanceFollowingDefinitionList( |
+ 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()) { |
+ HInstruction* next = HInstruction::cast(dominator)->next(); |
+ while (next != NULL) { |
Jakob Kummerow
2013/01/31 14:06:43
I don't like endless loops very much.
Massi
2013/01/31 17:16:19
Done (and it was actually an embarrassing bug...).
|
+ 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::CheckDominanceUsingProcessedFlag( |
+ HValue* dominator, HValue* dominated) { |
+ if (dominator->block() != dominated->block()) { |
+ return dominator->block()->Dominates(dominated->block()); |
+ } else { |
+ // If "dominated" is in the same block as the definition we check if is |
+ // has already been processed or if it is a phi: if not it is dominated. |
+ return dominated->CheckFlag(kIDefsProcessingDone) || dominated->IsPhi(); |
Jakob Kummerow
2013/01/31 14:06:43
I think this condition is the wrong way round: it'
Massi
2013/01/31 17:16:19
Done.
|
+ } |
+} |
+ |
+ |
bool HValue::IsDefinedAfter(HBasicBlock* other) const { |
return block()->block_id() > other->block_id(); |
} |