Reviewers: Jakob,
Message:
PTAL
Description:
Observed double + truncating input = observed int32
Please review this at https://chromiumcodereview.appspot.com/16439019/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen-instructions.h
M src/hydrogen-instructions.cc
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index
d3f1a9e09024c8f1643eb53bddc3b595b3953d3e..e316fcbeb792a65e59b24149987e8c1b3be6f095
100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -2185,6 +2185,7 @@ void HConstant::Initialize(Representation r) {
}
}
set_representation(r);
+ if (has_int32_value_) SetFlag(kTruncatedToInt32);
SetFlag(kUseGVN);
if (representation().IsInteger32()) {
ClearGVNFlag(kDependsOnOsrEntries);
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
4a8a406eb3befbc126c4f0f6aa15119892ef316f..2fb5ba33af28aed93b5a5ff66bc99a7e22fa42cb
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -792,7 +792,10 @@ class HValue: public ZoneObject {
kCanBeDivByZero,
kAllowUndefinedAsNaN,
kIsArguments,
+ // Indicates whether the instruction truncates its inputs to int32.
kTruncatingToInt32,
+ // Indicates whether the result of the instruction is truncated to
int32.
+ kTruncatedToInt32,
// Set after an instruction is killed.
kIsDead,
// Instructions that are allowed to produce full range unsigned integer
@@ -967,6 +970,8 @@ class HValue: public ZoneObject {
int32_t GetInteger32Constant();
bool EqualsInteger32Constant(int32_t value);
+ bool IsTruncatedToInt32() const { return CheckFlag(kTruncatedToInt32); }
+
bool IsDefinedAfter(HBasicBlock* other) const;
// Operands.
@@ -1794,6 +1799,7 @@ class HClampToUint8: public HUnaryOperation {
explicit HClampToUint8(HValue* value)
: HUnaryOperation(value) {
set_representation(Representation::Integer32());
+ SetFlag(kTruncatedToInt32);
SetFlag(kAllowUndefinedAsNaN);
SetFlag(kUseGVN);
}
@@ -2557,6 +2563,7 @@ class HElementsKind: public HUnaryOperation {
public:
explicit HElementsKind(HValue* value) : HUnaryOperation(value) {
set_representation(Representation::Integer32());
+ SetFlag(kTruncatedToInt32);
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnElementsKind);
}
@@ -2581,6 +2588,7 @@ class HBitNot: public HUnaryOperation {
set_representation(Representation::Integer32());
SetFlag(kUseGVN);
SetFlag(kTruncatingToInt32);
+ SetFlag(kTruncatedToInt32);
SetFlag(kAllowUndefinedAsNaN);
}
@@ -2666,6 +2674,7 @@ class HUnaryMathOperation: public
HTemplateInstruction<2> {
case kMathFloor:
case kMathRound:
set_representation(Representation::Integer32());
+ SetFlag(kTruncatedToInt32);
break;
case kMathAbs:
// Not setting representation here: it is None intentionally.
@@ -3431,6 +3440,9 @@ class HBinaryOperation: public
HTemplateInstruction<3> {
void set_observed_input_representation(int index, Representation rep) {
ASSERT(index >= 1 && index <= 2);
+ if (rep.IsDouble() && OperandAt(index)->IsTruncatedToInt32()) {
+ rep = Representation::Integer32();
+ }
observed_input_representation_[index - 1] = rep;
}
@@ -3738,6 +3750,7 @@ class HBitwiseBinaryOperation: public
HBinaryOperation {
: HBinaryOperation(context, left, right) {
SetFlag(kFlexibleRepresentation);
SetFlag(kTruncatingToInt32);
+ SetFlag(kTruncatedToInt32);
SetFlag(kAllowUndefinedAsNaN);
SetAllSideEffects();
}
@@ -3788,6 +3801,7 @@ class HMathFloorOfDiv: public HBinaryOperation {
HMathFloorOfDiv(HValue* context, HValue* left, HValue* right)
: HBinaryOperation(context, left, right) {
set_representation(Representation::Integer32());
+ SetFlag(kTruncatedToInt32);
SetFlag(kUseGVN);
SetFlag(kCanOverflow);
if (!right->IsConstant()) {
@@ -3891,8 +3905,14 @@ class HCompareIDAndBranch: public
HTemplateControlInstruction<2, 2> {
void set_observed_input_representation(Representation left,
Representation right) {
- observed_input_representation_[0] = left;
- observed_input_representation_[1] = right;
+ if (left.IsDouble() && this->left()->IsTruncatedToInt32()) {
+ left = Representation::Integer32();
+ }
+ if (right.IsDouble() && this->right()->IsTruncatedToInt32()) {
+ right = Representation::Integer32();
+ }
+ observed_input_representation_[0] = left;
+ observed_input_representation_[1] = right;
}
virtual void InferRepresentation(HInferRepresentation* h_infer);
@@ -4220,6 +4240,7 @@ class HInstanceSize: public HTemplateInstruction<1> {
explicit HInstanceSize(HValue* object) {
SetOperandAt(0, object);
set_representation(Representation::Integer32());
+ SetFlag(kTruncatedToInt32);
}
HValue* object() { return OperandAt(0); }
@@ -5528,6 +5549,7 @@ class HLoadKeyed
set_representation(Representation::Double());
} else {
set_representation(Representation::Integer32());
+ SetFlag(kTruncatedToInt32);
}
SetGVNFlag(kDependsOnSpecializedArrayElements);
@@ -6046,6 +6068,7 @@ class HStringCharCodeAt: public
HTemplateInstruction<3> {
SetOperandAt(1, string);
SetOperandAt(2, index);
set_representation(Representation::Integer32());
+ SetFlag(kTruncatedToInt32);
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnMaps);
SetGVNFlag(kChangesNewSpacePromotion);
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.