Index: src/hydrogen-instructions.h |
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
index 2d57537596b612ffff8aa628dac5b0bac9cb8027..f4da3dfc33adee15e466d9132e100bf0b3f1b189 100644 |
--- a/src/hydrogen-instructions.h |
+++ b/src/hydrogen-instructions.h |
@@ -579,7 +579,10 @@ class HValue: public ZoneObject { |
// HGraph::ComputeSafeUint32Operations is responsible for setting this |
// flag. |
kUint32, |
- kLastFlag = kUint32 |
+ // This flag is set to true after the SetupInformativeDefinitions() pass |
+ // has processed this instruction. |
+ kIDefsProcessingDone, |
+ kLastFlag = kIDefsProcessingDone |
}; |
STATIC_ASSERT(kLastFlag < kBitsPerInt); |
@@ -687,8 +690,8 @@ class HValue: public ZoneObject { |
return RedefinedOperandIndex() != kNoRedefinedOperand; |
} |
HValue* RedefinedOperand() { |
- ASSERT(IsInformativeDefinition()); |
- return OperandAt(RedefinedOperandIndex()); |
+ return IsInformativeDefinition() ? OperandAt(RedefinedOperandIndex()) |
+ : NULL; |
} |
// This method must always return the original HValue SSA definition |
@@ -698,6 +701,15 @@ class HValue: public ZoneObject { |
: this; |
} |
+ virtual void AddInformativeDefinitions() {} |
+ |
+ void UpdateRedefinedUsesWhileSettingUpInformativeDefinitions() { |
+ UpdateRedefinedUsesInner<CheckDominanceUsingProcessedFlag>(); |
+ } |
+ void UpdateRedefinedUses() { |
+ UpdateRedefinedUsesInner<CheckDominanceFollowingDefinitionList>(); |
+ } |
+ |
bool IsDefinedAfter(HBasicBlock* other) const; |
// Operands. |
@@ -856,6 +868,36 @@ class HValue: public ZoneObject { |
representation_ = r; |
} |
+ // Check if "dominator" properly dominates "dominated" |
+ // (used in UpdateRedefinedUsesInner). |
+ static bool CheckDominanceFollowingDefinitionList( |
Jakob Kummerow
2013/01/31 14:06:43
I'm not too happy with this method's name. "Check"
Massi
2013/01/31 17:16:19
Renamed the methods but, after the offline chat, k
|
+ HValue* dominator, HValue* dominated); |
Jakob Kummerow
2013/01/31 14:06:43
nit: for method/function declarations (contrary to
Massi
2013/01/31 17:16:19
Done.
|
+ |
+ // When we are setting up informaative definitions we use a flag to mark |
Jakob Kummerow
2013/01/31 14:06:43
nit: s/informaative/informative/
Massi
2013/01/31 17:16:19
Done.
|
+ // processed instructions, and by checking the flag we know if an |
+ // instruction comes before or after the "current" one. |
+ static bool CheckDominanceUsingProcessedFlag( |
+ HValue* dominator, HValue* dominated); |
Jakob Kummerow
2013/01/31 14:06:43
same here
Massi
2013/01/31 17:16:19
Done.
|
+ |
+ // If we are redefining an operand, update all its dominated uses (the |
+ // function that checks if a use is dominated is the template argument). |
+ template<bool (*CheckDominance)(HValue*, HValue*)> |
Jakob Kummerow
2013/01/31 14:06:43
Please use a typedef for the function signature de
Massi
2013/01/31 17:16:19
Done.
|
+ void UpdateRedefinedUsesInner() { |
+ HValue* input = RedefinedOperand(); |
+ if (input != NULL) { |
+ HUseIterator uses = input->uses(); |
+ while (!uses.Done()) { |
Jakob Kummerow
2013/01/31 14:06:43
I'm used to seeing for-loops for iterating over us
Massi
2013/01/31 17:16:19
Done.
|
+ HValue* use = uses.value(); |
+ int index = uses.index(); |
+ uses.Advance(); |
+ // We need to update all dominated uses. |
+ if (CheckDominance(this, use)) { |
+ use->SetOperandAt(index, this); |
+ } |
+ } |
+ } |
+ } |
+ |
static GVNFlagSet AllDependsOnFlagSet() { |
GVNFlagSet result; |
// Create changes mask. |