Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1070 return WriteBarrierKindFor(base_taggedness, field_representation, | 1070 return WriteBarrierKindFor(base_taggedness, field_representation, |
| 1071 field_type, value); | 1071 field_type, value); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 Graph* graph() const { return jsgraph_->graph(); } | 1074 Graph* graph() const { return jsgraph_->graph(); } |
| 1075 CommonOperatorBuilder* common() const { return jsgraph_->common(); } | 1075 CommonOperatorBuilder* common() const { return jsgraph_->common(); } |
| 1076 SimplifiedOperatorBuilder* simplified() const { | 1076 SimplifiedOperatorBuilder* simplified() const { |
| 1077 return jsgraph_->simplified(); | 1077 return jsgraph_->simplified(); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 void ChangeToInt32MulWithOverflowOp(Node* node, CheckForMinusZeroMode kMode) { | |
| 1081 NodeProperties::ChangeOp(node, simplified()->CheckedInt32Mul(kMode)); | |
| 1082 } | |
| 1083 | |
| 1080 void ChangeToInt32OverflowOp(Node* node) { | 1084 void ChangeToInt32OverflowOp(Node* node) { |
| 1081 NodeProperties::ChangeOp(node, Int32OverflowOp(node)); | 1085 NodeProperties::ChangeOp(node, Int32OverflowOp(node)); |
| 1082 } | 1086 } |
| 1083 | 1087 |
| 1084 void ChangeToUint32OverflowOp(Node* node) { | 1088 void ChangeToUint32OverflowOp(Node* node) { |
| 1085 NodeProperties::ChangeOp(node, Uint32OverflowOp(node)); | 1089 NodeProperties::ChangeOp(node, Uint32OverflowOp(node)); |
| 1086 } | 1090 } |
| 1087 | 1091 |
| 1088 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation, | 1092 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation, |
| 1089 SimplifiedLowering* lowering) { | 1093 SimplifiedLowering* lowering) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1327 // (b) the output is known to be Unsigned32, or | 1331 // (b) the output is known to be Unsigned32, or |
| 1328 // (c) the uses are truncating and the result is in the safe | 1332 // (c) the uses are truncating and the result is in the safe |
| 1329 // integer range. | 1333 // integer range. |
| 1330 VisitWord32TruncatingBinop(node); | 1334 VisitWord32TruncatingBinop(node); |
| 1331 if (lower()) ChangeToPureOp(node, Int32Op(node)); | 1335 if (lower()) ChangeToPureOp(node, Int32Op(node)); |
| 1332 return; | 1336 return; |
| 1333 } | 1337 } |
| 1334 // Try to use type feedback. | 1338 // Try to use type feedback. |
| 1335 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); | 1339 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); |
| 1336 | 1340 |
| 1341 // Determine if one of the inputs is a constant integer > 0. | |
| 1342 Type* input0_type = NodeProperties::GetType(node->InputAt(0)); | |
| 1343 Type* input1_type = NodeProperties::GetType(node->InputAt(1)); | |
|
Jarin
2016/07/17 18:24:41
You can use TypeOf here (instead of NodeProperties
mvstanton
2016/07/18 08:48:58
Done.
| |
| 1344 bool positive_range = false; | |
| 1345 if ((input0_type->IsRange() && input0_type->AsRange()->Min() > 0) || | |
| 1346 (input1_type->IsRange() && input1_type->AsRange()->Min() > 0)) { | |
|
Jarin
2016/07/17 16:37:47
Maybe it is better to not refer to ranges here and
Benedikt Meurer
2016/07/17 17:44:07
Yes, please. And I'd prefer to have this inline be
mvstanton
2016/07/18 08:48:58
No problemo
mvstanton
2016/07/18 08:48:58
Done.
| |
| 1347 positive_range = true; | |
| 1348 } | |
| 1349 | |
| 1350 // If one of the inputs is positive and/or truncation is being applied, | |
| 1351 // there is no need to return -0. | |
| 1352 CheckForMinusZeroMode mz_mode = | |
| 1353 (truncation.TruncatesToWord32() || positive_range) | |
| 1354 ? CheckForMinusZeroMode::kDontCheckForMinusZero | |
| 1355 : CheckForMinusZeroMode::kCheckForMinusZero; | |
|
Jarin
2016/07/17 18:24:41
Looking at this again, this logic is only used whe
mvstanton
2016/07/18 08:48:58
Good idea, done!
| |
| 1356 | |
| 1337 // Handle the case when no int32 checks on inputs are necessary | 1357 // Handle the case when no int32 checks on inputs are necessary |
| 1338 // (but an overflow check is needed on the output). | 1358 // (but an overflow check is needed on the output). |
| 1339 if (BothInputsAre(node, Type::Signed32())) { | 1359 if (BothInputsAre(node, Type::Signed32())) { |
| 1340 // If both the inputs the feedback are int32, use the overflow op. | 1360 // If both the inputs the feedback are int32, use the overflow op. |
| 1341 if (hint == BinaryOperationHints::kSignedSmall || | 1361 if (hint == BinaryOperationHints::kSignedSmall || |
| 1342 hint == BinaryOperationHints::kSigned32) { | 1362 hint == BinaryOperationHints::kSigned32) { |
| 1343 VisitBinop(node, UseInfo::TruncatingWord32(), | 1363 VisitBinop(node, UseInfo::TruncatingWord32(), |
| 1344 MachineRepresentation::kWord32, Type::Signed32()); | 1364 MachineRepresentation::kWord32, Type::Signed32()); |
| 1345 if (lower()) ChangeToInt32OverflowOp(node); | 1365 if (lower()) ChangeToInt32MulWithOverflowOp(node, mz_mode); |
| 1346 return; | 1366 return; |
| 1347 } | 1367 } |
| 1348 } | 1368 } |
| 1349 | 1369 |
| 1350 if (hint == BinaryOperationHints::kSignedSmall || | 1370 if (hint == BinaryOperationHints::kSignedSmall || |
| 1351 hint == BinaryOperationHints::kSigned32) { | 1371 hint == BinaryOperationHints::kSigned32) { |
| 1352 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), | 1372 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), |
| 1353 MachineRepresentation::kWord32, Type::Signed32()); | 1373 MachineRepresentation::kWord32, Type::Signed32()); |
| 1354 if (lower()) ChangeToInt32OverflowOp(node); | 1374 if (lower()) ChangeToInt32MulWithOverflowOp(node, mz_mode); |
| 1355 return; | 1375 return; |
| 1356 } | 1376 } |
| 1357 | 1377 |
| 1358 // Checked float64 x float64 => float64 | 1378 // Checked float64 x float64 => float64 |
| 1359 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), | 1379 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), |
| 1360 MachineRepresentation::kFloat64, Type::Number()); | 1380 MachineRepresentation::kFloat64, Type::Number()); |
| 1361 if (lower()) ChangeToPureOp(node, Float64Op(node)); | 1381 if (lower()) ChangeToPureOp(node, Float64Op(node)); |
| 1362 return; | 1382 return; |
| 1363 } | 1383 } |
| 1364 case IrOpcode::kNumberMultiply: { | 1384 case IrOpcode::kNumberMultiply: { |
| (...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3346 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3366 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
| 3347 Operator::kNoProperties); | 3367 Operator::kNoProperties); |
| 3348 to_number_operator_.set(common()->Call(desc)); | 3368 to_number_operator_.set(common()->Call(desc)); |
| 3349 } | 3369 } |
| 3350 return to_number_operator_.get(); | 3370 return to_number_operator_.get(); |
| 3351 } | 3371 } |
| 3352 | 3372 |
| 3353 } // namespace compiler | 3373 } // namespace compiler |
| 3354 } // namespace internal | 3374 } // namespace internal |
| 3355 } // namespace v8 | 3375 } // namespace v8 |
| OLD | NEW |