| 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 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 SimplifiedLowering* lowering) { | 1049 SimplifiedLowering* lowering) { |
| 1050 if (BothInputsAre(node, Type::Signed32()) && | 1050 if (BothInputsAre(node, Type::Signed32()) && |
| 1051 NodeProperties::GetType(node)->Is(Type::Signed32())) { | 1051 NodeProperties::GetType(node)->Is(Type::Signed32())) { |
| 1052 // int32 + int32 = int32 ==> signed Int32Add/Sub | 1052 // int32 + int32 = int32 ==> signed Int32Add/Sub |
| 1053 VisitInt32Binop(node); | 1053 VisitInt32Binop(node); |
| 1054 if (lower()) ChangeToPureOp(node, Int32Op(node)); | 1054 if (lower()) ChangeToPureOp(node, Int32Op(node)); |
| 1055 return; | 1055 return; |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 // Use truncation if available. | 1058 // Use truncation if available. |
| 1059 if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) && | 1059 if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) && |
| 1060 truncation.TruncatesToWord32()) { | 1060 truncation.TruncatesToWord32()) { |
| 1061 // safe-int + safe-int = x (truncated to int32) | 1061 // safe-int + safe-int = x (truncated to int32) |
| 1062 // => signed Int32Add/Sub (truncated) | 1062 // => signed Int32Add/Sub (truncated) |
| 1063 VisitWord32TruncatingBinop(node); | 1063 VisitWord32TruncatingBinop(node); |
| 1064 if (lower()) ChangeToPureOp(node, Int32Op(node)); | 1064 if (lower()) ChangeToPureOp(node, Int32Op(node)); |
| 1065 return; | 1065 return; |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 // Try to use type feedback. | 1068 // Try to use type feedback. |
| 1069 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); | 1069 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 case IrOpcode::kNumberAdd: | 1277 case IrOpcode::kNumberAdd: |
| 1278 case IrOpcode::kNumberSubtract: { | 1278 case IrOpcode::kNumberSubtract: { |
| 1279 if (BothInputsAre(node, Type::Signed32()) && | 1279 if (BothInputsAre(node, Type::Signed32()) && |
| 1280 NodeProperties::GetType(node)->Is(Type::Signed32())) { | 1280 NodeProperties::GetType(node)->Is(Type::Signed32())) { |
| 1281 // int32 + int32 = int32 | 1281 // int32 + int32 = int32 |
| 1282 // => signed Int32Add/Sub | 1282 // => signed Int32Add/Sub |
| 1283 VisitInt32Binop(node); | 1283 VisitInt32Binop(node); |
| 1284 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); | 1284 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); |
| 1285 } else if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) && | 1285 } else if (BothInputsAre(node, |
| 1286 type_cache_.kAdditiveSafeIntegerOrMinusZero) && |
| 1286 truncation.TruncatesToWord32()) { | 1287 truncation.TruncatesToWord32()) { |
| 1287 // safe-int + safe-int = x (truncated to int32) | 1288 // safe-int + safe-int = x (truncated to int32) |
| 1288 // => signed Int32Add/Sub (truncated) | 1289 // => signed Int32Add/Sub (truncated) |
| 1289 VisitWord32TruncatingBinop(node); | 1290 VisitWord32TruncatingBinop(node); |
| 1290 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); | 1291 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); |
| 1291 } else { | 1292 } else { |
| 1292 // => Float64Add/Sub | 1293 // => Float64Add/Sub |
| 1293 VisitFloat64Binop(node); | 1294 VisitFloat64Binop(node); |
| 1294 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 1295 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
| 1295 } | 1296 } |
| 1296 return; | 1297 return; |
| 1297 } | 1298 } |
| 1298 case IrOpcode::kNumberMultiply: { | 1299 case IrOpcode::kNumberMultiply: { |
| 1299 if (BothInputsAreSigned32(node)) { | 1300 if (BothInputsAreSigned32(node)) { |
| 1300 if (NodeProperties::GetType(node)->Is(Type::Signed32())) { | 1301 if (NodeProperties::GetType(node)->Is(Type::Signed32())) { |
| 1301 // Multiply reduces to Int32Mul if the inputs and the output | 1302 // Multiply reduces to Int32Mul if the inputs and the output |
| 1302 // are integers. | 1303 // are integers. |
| 1303 VisitInt32Binop(node); | 1304 VisitInt32Binop(node); |
| 1304 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); | 1305 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); |
| 1305 return; | 1306 return; |
| 1306 } | 1307 } |
| 1307 if (truncation.TruncatesToWord32() && | 1308 if (truncation.TruncatesToWord32() && |
| 1308 NodeProperties::GetType(node)->Is(type_cache_.kSafeInteger)) { | 1309 NodeProperties::GetType(node)->Is( |
| 1310 type_cache_.kSafeIntegerOrMinusZero)) { |
| 1309 // Multiply reduces to Int32Mul if the inputs are integers, | 1311 // Multiply reduces to Int32Mul if the inputs are integers, |
| 1310 // the uses are truncating and the result is in the safe | 1312 // the uses are truncating and the result is in the safe |
| 1311 // integer range. | 1313 // integer range. |
| 1312 VisitWord32TruncatingBinop(node); | 1314 VisitWord32TruncatingBinop(node); |
| 1313 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); | 1315 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); |
| 1314 return; | 1316 return; |
| 1315 } | 1317 } |
| 1316 } | 1318 } |
| 1317 // => Float64Mul | 1319 // => Float64Mul |
| 1318 VisitFloat64Binop(node); | 1320 VisitFloat64Binop(node); |
| (...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2930 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 2932 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
| 2931 Operator::kNoProperties); | 2933 Operator::kNoProperties); |
| 2932 to_number_operator_.set(common()->Call(desc)); | 2934 to_number_operator_.set(common()->Call(desc)); |
| 2933 } | 2935 } |
| 2934 return to_number_operator_.get(); | 2936 return to_number_operator_.get(); |
| 2935 } | 2937 } |
| 2936 | 2938 |
| 2937 } // namespace compiler | 2939 } // namespace compiler |
| 2938 } // namespace internal | 2940 } // namespace internal |
| 2939 } // namespace v8 | 2941 } // namespace v8 |
| OLD | NEW |