Index: src/hydrogen-instructions.h |
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
index f977a750d946a6b24d657b08229fc4a238c368b2..a03faca5c85ff989f6c35449e24b41e82b2b5ce3 100644 |
--- a/src/hydrogen-instructions.h |
+++ b/src/hydrogen-instructions.h |
@@ -2430,6 +2430,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(); |
@@ -2447,6 +2462,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); |
@@ -2454,8 +2473,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. |