Index: src/hydrogen-instructions.h |
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
index eac5173f7d00748bec37cba8a7bb68990113342c..78e9a6b192a3e477b1633cfbfc9dc538dd1370e8 100644 |
--- a/src/hydrogen-instructions.h |
+++ b/src/hydrogen-instructions.h |
@@ -2775,6 +2775,21 @@ class HUnaryMathOperation: public HTemplateInstruction<2> { |
} |
} |
+ virtual void UpdateRepresentation(Representation new_rep, |
+ HInferRepresentationPhase* h_infer, |
+ const char* reason) { |
+ if (flexible_int() && !new_rep.IsSmi()) { |
+ new_rep = Representation::Integer32(); |
+ } |
+ HValue::UpdateRepresentation(new_rep, h_infer, reason); |
+ } |
+ |
+ virtual void RepresentationChanged(Representation new_rep) { |
+ if (flexible_int() && new_rep.IsInteger32()) { |
+ ClearFlag(kFlexibleRepresentation); |
+ } |
+ } |
+ |
virtual Range* InferRange(Zone* zone); |
virtual HValue* Canonicalize(); |
@@ -2792,6 +2807,10 @@ class HUnaryMathOperation: public HTemplateInstruction<2> { |
} |
private: |
+ bool flexible_int() { |
+ return op_ == kMathFloor || op_ == kMathRound; |
+ } |
+ |
HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
: HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { |
SetOperandAt(0, context); |
@@ -2799,8 +2818,8 @@ class HUnaryMathOperation: public HTemplateInstruction<2> { |
switch (op) { |
case kMathFloor: |
case kMathRound: |
- // TODO(verwaest): Set representation to flexible int starting as smi. |
- set_representation(Representation::Integer32()); |
+ set_representation(Representation::Smi()); |
+ SetFlag(kFlexibleRepresentation); |
break; |
case kMathAbs: |
// Not setting representation here: it is None intentionally. |
@@ -3439,7 +3458,7 @@ class HPhi: public HValue { |
non_phi_uses_[i] = 0; |
indirect_uses_[i] = 0; |
} |
- ASSERT(merged_index >= 0); |
+ ASSERT(merged_index >= 0 || merged_index == kInvalidMergedIndex); |
SetFlag(kFlexibleRepresentation); |
SetFlag(kAllowUndefinedAsNaN); |
} |
@@ -3462,6 +3481,7 @@ class HPhi: public HValue { |
bool HasRealUses(); |
bool IsReceiver() const { return merged_index_ == 0; } |
+ bool HasMergedIndex() const { return merged_index_ != kInvalidMergedIndex; } |
int merged_index() const { return merged_index_; } |
@@ -3526,6 +3546,9 @@ class HPhi: public HValue { |
void SimplifyConstantInputs(); |
+ // Marker value representing an invalid merge index. |
+ static const int kInvalidMergedIndex = -1; |
+ |
protected: |
virtual void DeleteFromGraph(); |
virtual void InternalSetOperandAt(int index, HValue* value) { |