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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 UNREACHABLE(); | 86 UNREACHABLE(); |
87 return MachineRepresentation::kNone; | 87 return MachineRepresentation::kNone; |
88 } | 88 } |
89 | 89 |
90 UseInfo CheckedUseInfoAsWord32FromHint(NumberOperationHint hint) { | 90 UseInfo CheckedUseInfoAsWord32FromHint(NumberOperationHint hint) { |
91 switch (hint) { | 91 switch (hint) { |
92 case NumberOperationHint::kSignedSmall: | 92 case NumberOperationHint::kSignedSmall: |
93 return UseInfo::CheckedSignedSmallAsWord32(); | 93 return UseInfo::CheckedSignedSmallAsWord32(); |
94 case NumberOperationHint::kSigned32: | 94 case NumberOperationHint::kSigned32: |
95 return UseInfo::CheckedSigned32AsWord32(); | 95 return UseInfo::CheckedSigned32AsWord32(); |
| 96 case NumberOperationHint::kNumber: |
| 97 return UseInfo::CheckedNumberAsWord32(); |
96 case NumberOperationHint::kNumberOrOddball: | 98 case NumberOperationHint::kNumberOrOddball: |
97 return UseInfo::CheckedNumberOrOddballAsWord32(); | 99 return UseInfo::CheckedNumberOrOddballAsWord32(); |
98 } | 100 } |
99 UNREACHABLE(); | 101 UNREACHABLE(); |
100 return UseInfo::None(); | 102 return UseInfo::None(); |
101 } | 103 } |
102 | 104 |
| 105 UseInfo CheckedUseInfoAsFloat64FromHint(NumberOperationHint hint) { |
| 106 switch (hint) { |
| 107 case NumberOperationHint::kSignedSmall: |
| 108 case NumberOperationHint::kSigned32: |
| 109 // Not used currently. |
| 110 UNREACHABLE(); |
| 111 break; |
| 112 case NumberOperationHint::kNumber: |
| 113 return UseInfo::CheckedNumberAsFloat64(); |
| 114 case NumberOperationHint::kNumberOrOddball: |
| 115 return UseInfo::CheckedNumberOrOddballAsFloat64(); |
| 116 } |
| 117 UNREACHABLE(); |
| 118 return UseInfo::None(); |
| 119 } |
| 120 |
103 UseInfo TruncatingUseInfoFromRepresentation(MachineRepresentation rep) { | 121 UseInfo TruncatingUseInfoFromRepresentation(MachineRepresentation rep) { |
104 switch (rep) { | 122 switch (rep) { |
105 case MachineRepresentation::kTagged: | 123 case MachineRepresentation::kTagged: |
106 return UseInfo::AnyTagged(); | 124 return UseInfo::AnyTagged(); |
107 case MachineRepresentation::kFloat64: | 125 case MachineRepresentation::kFloat64: |
108 return UseInfo::TruncatingFloat64(); | 126 return UseInfo::TruncatingFloat64(); |
109 case MachineRepresentation::kFloat32: | 127 case MachineRepresentation::kFloat32: |
110 return UseInfo::TruncatingFloat32(); | 128 return UseInfo::TruncatingFloat32(); |
111 case MachineRepresentation::kWord64: | 129 case MachineRepresentation::kWord64: |
112 return UseInfo::TruncatingWord64(); | 130 return UseInfo::TruncatingWord64(); |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 return; | 1358 return; |
1341 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) && | 1359 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) && |
1342 TypeOf(node->InputAt(1))->Is(Type::Signed32())) { | 1360 TypeOf(node->InputAt(1))->Is(Type::Signed32())) { |
1343 // => signed Int32Cmp | 1361 // => signed Int32Cmp |
1344 VisitInt32Cmp(node); | 1362 VisitInt32Cmp(node); |
1345 if (lower()) ChangeToPureOp(node, Int32Op(node)); | 1363 if (lower()) ChangeToPureOp(node, Int32Op(node)); |
1346 return; | 1364 return; |
1347 } | 1365 } |
1348 // Try to use type feedback. | 1366 // Try to use type feedback. |
1349 NumberOperationHint hint = NumberOperationHintOf(node->op()); | 1367 NumberOperationHint hint = NumberOperationHintOf(node->op()); |
1350 | 1368 switch (hint) { |
1351 if (hint == NumberOperationHint::kSignedSmall) { | 1369 case NumberOperationHint::kSignedSmall: |
1352 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), | 1370 case NumberOperationHint::kSigned32: |
1353 MachineRepresentation::kBit); | 1371 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint), |
1354 if (lower()) ChangeToPureOp(node, Int32Op(node)); | 1372 MachineRepresentation::kBit); |
1355 return; | 1373 if (lower()) ChangeToPureOp(node, Int32Op(node)); |
| 1374 return; |
| 1375 case NumberOperationHint::kNumber: |
| 1376 case NumberOperationHint::kNumberOrOddball: |
| 1377 VisitBinop(node, CheckedUseInfoAsFloat64FromHint(hint), |
| 1378 MachineRepresentation::kBit); |
| 1379 if (lower()) ChangeToPureOp(node, Float64Op(node)); |
| 1380 return; |
1356 } | 1381 } |
1357 DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint); | 1382 UNREACHABLE(); |
1358 // default case => Float64 comparison | |
1359 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), | |
1360 MachineRepresentation::kBit); | |
1361 if (lower()) ChangeToPureOp(node, Float64Op(node)); | |
1362 return; | 1383 return; |
1363 } | 1384 } |
1364 | 1385 |
1365 case IrOpcode::kNumberAdd: | 1386 case IrOpcode::kNumberAdd: |
1366 case IrOpcode::kNumberSubtract: { | 1387 case IrOpcode::kNumberSubtract: { |
1367 if (BothInputsAre(node, Type::Signed32()) && | 1388 if (BothInputsAre(node, Type::Signed32()) && |
1368 NodeProperties::GetType(node)->Is(Type::Signed32())) { | 1389 NodeProperties::GetType(node)->Is(Type::Signed32())) { |
1369 // int32 + int32 = int32 | 1390 // int32 + int32 = int32 |
1370 // => signed Int32Add/Sub | 1391 // => signed Int32Add/Sub |
1371 VisitInt32Binop(node); | 1392 VisitInt32Binop(node); |
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3315 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3336 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3316 Operator::kNoProperties); | 3337 Operator::kNoProperties); |
3317 to_number_operator_.set(common()->Call(desc)); | 3338 to_number_operator_.set(common()->Call(desc)); |
3318 } | 3339 } |
3319 return to_number_operator_.get(); | 3340 return to_number_operator_.get(); |
3320 } | 3341 } |
3321 | 3342 |
3322 } // namespace compiler | 3343 } // namespace compiler |
3323 } // namespace internal | 3344 } // namespace internal |
3324 } // namespace v8 | 3345 } // namespace v8 |
OLD | NEW |