Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: src/compiler/simplified-lowering.cc

Issue 2181743004: [turbofan] Speculative optimize number operations with no feedback. Base URL: https://chromium.googlesource.com/v8/v8.git@631318
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index e7aaf43535a54e0bf27a1361265758a28c9d7532..f19f978ef2569e7132e13e4a80206f9de4ccc411 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1101,7 +1101,17 @@ class RepresentationSelector {
}
// Try to use type feedback.
- BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
+ NumberOperationHint hint = NumberOperationHintOf(node->op());
+ if (hint == NumberOperationHint::kNone) {
+ // TODO(turbofan): Shall we change any deopts that are caused by this
+ // speculation to soft ones so we don't count against the deopt limit?
+ if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
+ hint = NumberOperationHint::kSigned32;
+ } else {
+ hint = NumberOperationHint::kNumberOrOddball;
Jarin 2016/07/26 09:39:21 I doubt this helps anything - if the type cannot b
+ }
+ }
// Handle the case when no int32 checks on inputs are necessary
// (but an overflow check is needed on the output).
@@ -1109,8 +1119,7 @@ class RepresentationSelector {
(BothInputsAre(node, type_cache_.kSigned32OrMinusZero) &&
NodeProperties::GetType(node)->Is(type_cache_.kSafeInteger))) {
// If both the inputs the feedback are int32, use the overflow op.
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32, Type::Signed32());
if (lower()) ChangeToInt32OverflowOp(node);
@@ -1118,8 +1127,7 @@ class RepresentationSelector {
}
}
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kWord32, Type::Signed32());
if (lower()) ChangeToInt32OverflowOp(node);
@@ -1127,6 +1135,7 @@ class RepresentationSelector {
}
// default case => Float64Add/Sub
+ DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
MachineRepresentation::kFloat64, Type::Number());
if (lower()) {
@@ -1296,16 +1305,26 @@ class RepresentationSelector {
return;
}
// Try to use type feedback.
- CompareOperationHints::Hint hint = CompareOperationHintOf(node->op());
+ NumberOperationHint hint = NumberOperationHintOf(node->op());
+ if (hint == NumberOperationHint::kNone) {
+ // TODO(turbofan): Shall we change any deopts that are caused by this
+ // speculation to soft ones so we don't count against the deopt limit?
+ if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
+ hint = NumberOperationHint::kSigned32;
+ } else {
+ hint = NumberOperationHint::kNumberOrOddball;
+ }
+ }
- if (hint == CompareOperationHints::kSignedSmall) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kBit);
if (lower()) ChangeToPureOp(node, Int32Op(node));
return;
}
- DCHECK_EQ(CompareOperationHints::kNumberOrOddball, hint);
// default case => Float64 comparison
+ DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
MachineRepresentation::kBit);
if (lower()) ChangeToPureOp(node, Float64Op(node));
@@ -1358,7 +1377,17 @@ class RepresentationSelector {
return;
}
// Try to use type feedback.
- BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
+ NumberOperationHint hint = NumberOperationHintOf(node->op());
+ if (hint == NumberOperationHint::kNone) {
+ // TODO(turbofan): Shall we change any deopts that are caused by this
+ // speculation to soft ones so we don't count against the deopt limit?
+ if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
+ hint = NumberOperationHint::kSigned32;
+ } else {
+ hint = NumberOperationHint::kNumberOrOddball;
+ }
+ }
Type* input0_type = TypeOf(node->InputAt(0));
Type* input1_type = TypeOf(node->InputAt(1));
@@ -1366,8 +1395,7 @@ class RepresentationSelector {
// (but an overflow check is needed on the output).
if (BothInputsAre(node, Type::Signed32())) {
// If both the inputs the feedback are int32, use the overflow op.
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32, Type::Signed32());
if (lower()) {
@@ -1378,8 +1406,7 @@ class RepresentationSelector {
}
}
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kWord32, Type::Signed32());
if (lower()) {
@@ -1389,6 +1416,7 @@ class RepresentationSelector {
}
// Checked float64 x float64 => float64
+ DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
MachineRepresentation::kFloat64, Type::Number());
if (lower()) ChangeToPureOp(node, Float64Op(node));
@@ -1445,13 +1473,22 @@ class RepresentationSelector {
}
// Try to use type feedback.
- BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
+ NumberOperationHint hint = NumberOperationHintOf(node->op());
+ if (hint == NumberOperationHint::kNone) {
+ // TODO(turbofan): Shall we change any deopts that are caused by this
+ // speculation to soft ones so we don't count against the deopt limit?
+ if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
+ hint = NumberOperationHint::kSigned32;
+ } else {
+ hint = NumberOperationHint::kNumberOrOddball;
+ }
+ }
// Handle the case when no uint32 checks on inputs are necessary
// (but an overflow check is needed on the output).
if (BothInputsAreUnsigned32(node)) {
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32, Type::Unsigned32());
if (lower()) ChangeToUint32OverflowOp(node);
@@ -1463,8 +1500,7 @@ class RepresentationSelector {
// (but an overflow check is needed on the output).
if (BothInputsAreSigned32(node)) {
// If both the inputs the feedback are int32, use the overflow op.
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32, Type::Signed32());
if (lower()) ChangeToInt32OverflowOp(node);
@@ -1472,8 +1508,7 @@ class RepresentationSelector {
}
}
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
// If the result is truncated, we only need to check the inputs.
if (truncation.IsUsedAsWord32()) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
@@ -1488,6 +1523,7 @@ class RepresentationSelector {
}
// default case => Float64Div
+ DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
MachineRepresentation::kFloat64, Type::Number());
if (lower()) ChangeToPureOp(node, Float64Op(node));
@@ -1557,13 +1593,22 @@ class RepresentationSelector {
}
// Try to use type feedback.
- BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
+ NumberOperationHint hint = NumberOperationHintOf(node->op());
+ if (hint == NumberOperationHint::kNone) {
+ // TODO(turbofan): Shall we change any deopts that are caused by this
+ // speculation to soft ones so we don't count against the deopt limit?
+ if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
+ hint = NumberOperationHint::kSigned32;
+ } else {
+ hint = NumberOperationHint::kNumberOrOddball;
+ }
+ }
// Handle the case when no uint32 checks on inputs are necessary
// (but an overflow check is needed on the output).
if (BothInputsAreUnsigned32(node)) {
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32, Type::Unsigned32());
if (lower()) ChangeToUint32OverflowOp(node);
@@ -1575,8 +1620,7 @@ class RepresentationSelector {
// (but an overflow check is needed on the output).
if (BothInputsAre(node, Type::Signed32())) {
// If both the inputs the feedback are int32, use the overflow op.
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
VisitBinop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32, Type::Signed32());
if (lower()) ChangeToInt32OverflowOp(node);
@@ -1584,8 +1628,7 @@ class RepresentationSelector {
}
}
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ if (hint == NumberOperationHint::kSigned32) {
// If the result is truncated, we only need to check the inputs.
if (truncation.IsUsedAsWord32()) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
@@ -1600,6 +1643,7 @@ class RepresentationSelector {
}
// default case => Float64Mod
+ DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
MachineRepresentation::kFloat64, Type::Number());
if (lower()) ChangeToPureOp(node, Float64Op(node));
@@ -1665,9 +1709,18 @@ class RepresentationSelector {
}
return;
}
- BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
- if (hint == BinaryOperationHints::kSignedSmall ||
- hint == BinaryOperationHints::kSigned32) {
+ NumberOperationHint hint = NumberOperationHintOf(node->op());
+ if (hint == NumberOperationHint::kNone) {
+ // TODO(turbofan): Shall we change any deopts that are caused by this
+ // speculation to soft ones so we don't count against the deopt limit?
+ if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
+ TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
+ hint = NumberOperationHint::kSigned32;
+ } else {
+ hint = NumberOperationHint::kNumberOrOddball;
+ }
+ }
+ if (hint == NumberOperationHint::kSigned32) {
Type* rhs_type = GetUpperBound(node->InputAt(1));
if (truncation.IsUsedAsWord32()) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),

Powered by Google App Engine
This is Rietveld 408576698