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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) && 1094 if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
1095 truncation.IsUsedAsWord32()) { 1095 truncation.IsUsedAsWord32()) {
1096 // safe-int + safe-int = x (truncated to int32) 1096 // safe-int + safe-int = x (truncated to int32)
1097 // => signed Int32Add/Sub (truncated) 1097 // => signed Int32Add/Sub (truncated)
1098 VisitWord32TruncatingBinop(node); 1098 VisitWord32TruncatingBinop(node);
1099 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1099 if (lower()) ChangeToPureOp(node, Int32Op(node));
1100 return; 1100 return;
1101 } 1101 }
1102 1102
1103 // Try to use type feedback. 1103 // Try to use type feedback.
1104 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); 1104 NumberOperationHint hint = NumberOperationHintOf(node->op());
1105 if (hint == NumberOperationHint::kNone) {
1106 // TODO(turbofan): Shall we change any deopts that are caused by this
1107 // speculation to soft ones so we don't count against the deopt limit?
1108 if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
1109 TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
1110 hint = NumberOperationHint::kSigned32;
1111 } else {
1112 hint = NumberOperationHint::kNumberOrOddball;
Jarin 2016/07/26 09:39:21 I doubt this helps anything - if the type cannot b
1113 }
1114 }
1105 1115
1106 // Handle the case when no int32 checks on inputs are necessary 1116 // Handle the case when no int32 checks on inputs are necessary
1107 // (but an overflow check is needed on the output). 1117 // (but an overflow check is needed on the output).
1108 if (BothInputsAre(node, Type::Signed32()) || 1118 if (BothInputsAre(node, Type::Signed32()) ||
1109 (BothInputsAre(node, type_cache_.kSigned32OrMinusZero) && 1119 (BothInputsAre(node, type_cache_.kSigned32OrMinusZero) &&
1110 NodeProperties::GetType(node)->Is(type_cache_.kSafeInteger))) { 1120 NodeProperties::GetType(node)->Is(type_cache_.kSafeInteger))) {
1111 // If both the inputs the feedback are int32, use the overflow op. 1121 // If both the inputs the feedback are int32, use the overflow op.
1112 if (hint == BinaryOperationHints::kSignedSmall || 1122 if (hint == NumberOperationHint::kSigned32) {
1113 hint == BinaryOperationHints::kSigned32) {
1114 VisitBinop(node, UseInfo::TruncatingWord32(), 1123 VisitBinop(node, UseInfo::TruncatingWord32(),
1115 MachineRepresentation::kWord32, Type::Signed32()); 1124 MachineRepresentation::kWord32, Type::Signed32());
1116 if (lower()) ChangeToInt32OverflowOp(node); 1125 if (lower()) ChangeToInt32OverflowOp(node);
1117 return; 1126 return;
1118 } 1127 }
1119 } 1128 }
1120 1129
1121 if (hint == BinaryOperationHints::kSignedSmall || 1130 if (hint == NumberOperationHint::kSigned32) {
1122 hint == BinaryOperationHints::kSigned32) {
1123 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1131 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1124 MachineRepresentation::kWord32, Type::Signed32()); 1132 MachineRepresentation::kWord32, Type::Signed32());
1125 if (lower()) ChangeToInt32OverflowOp(node); 1133 if (lower()) ChangeToInt32OverflowOp(node);
1126 return; 1134 return;
1127 } 1135 }
1128 1136
1129 // default case => Float64Add/Sub 1137 // default case => Float64Add/Sub
1138 DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
1130 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), 1139 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1131 MachineRepresentation::kFloat64, Type::Number()); 1140 MachineRepresentation::kFloat64, Type::Number());
1132 if (lower()) { 1141 if (lower()) {
1133 ChangeToPureOp(node, Float64Op(node)); 1142 ChangeToPureOp(node, Float64Op(node));
1134 } 1143 }
1135 return; 1144 return;
1136 } 1145 }
1137 1146
1138 // Dispatching routine for visiting the node {node} with the usage {use}. 1147 // Dispatching routine for visiting the node {node} with the usage {use}.
1139 // Depending on the operator, propagate new usage info to the inputs. 1148 // Depending on the operator, propagate new usage info to the inputs.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 if (lower()) ChangeToPureOp(node, Uint32Op(node)); 1298 if (lower()) ChangeToPureOp(node, Uint32Op(node));
1290 return; 1299 return;
1291 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) && 1300 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
1292 TypeOf(node->InputAt(1))->Is(Type::Signed32())) { 1301 TypeOf(node->InputAt(1))->Is(Type::Signed32())) {
1293 // => signed Int32Cmp 1302 // => signed Int32Cmp
1294 VisitInt32Cmp(node); 1303 VisitInt32Cmp(node);
1295 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1304 if (lower()) ChangeToPureOp(node, Int32Op(node));
1296 return; 1305 return;
1297 } 1306 }
1298 // Try to use type feedback. 1307 // Try to use type feedback.
1299 CompareOperationHints::Hint hint = CompareOperationHintOf(node->op()); 1308 NumberOperationHint hint = NumberOperationHintOf(node->op());
1309 if (hint == NumberOperationHint::kNone) {
1310 // TODO(turbofan): Shall we change any deopts that are caused by this
1311 // speculation to soft ones so we don't count against the deopt limit?
1312 if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
1313 TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
1314 hint = NumberOperationHint::kSigned32;
1315 } else {
1316 hint = NumberOperationHint::kNumberOrOddball;
1317 }
1318 }
1300 1319
1301 if (hint == CompareOperationHints::kSignedSmall) { 1320 if (hint == NumberOperationHint::kSigned32) {
1302 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1321 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1303 MachineRepresentation::kBit); 1322 MachineRepresentation::kBit);
1304 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1323 if (lower()) ChangeToPureOp(node, Int32Op(node));
1305 return; 1324 return;
1306 } 1325 }
1307 DCHECK_EQ(CompareOperationHints::kNumberOrOddball, hint);
1308 // default case => Float64 comparison 1326 // default case => Float64 comparison
1327 DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
1309 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), 1328 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1310 MachineRepresentation::kBit); 1329 MachineRepresentation::kBit);
1311 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1330 if (lower()) ChangeToPureOp(node, Float64Op(node));
1312 return; 1331 return;
1313 } 1332 }
1314 1333
1315 case IrOpcode::kNumberAdd: 1334 case IrOpcode::kNumberAdd:
1316 case IrOpcode::kNumberSubtract: { 1335 case IrOpcode::kNumberSubtract: {
1317 if (BothInputsAre(node, Type::Signed32()) && 1336 if (BothInputsAre(node, Type::Signed32()) &&
1318 NodeProperties::GetType(node)->Is(Type::Signed32())) { 1337 NodeProperties::GetType(node)->Is(Type::Signed32())) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 // Multiply reduces to Int32Mul if the inputs are integers, and 1370 // Multiply reduces to Int32Mul if the inputs are integers, and
1352 // (a) the output is either known to be Signed32, or 1371 // (a) the output is either known to be Signed32, or
1353 // (b) the output is known to be Unsigned32, or 1372 // (b) the output is known to be Unsigned32, or
1354 // (c) the uses are truncating and the result is in the safe 1373 // (c) the uses are truncating and the result is in the safe
1355 // integer range. 1374 // integer range.
1356 VisitWord32TruncatingBinop(node); 1375 VisitWord32TruncatingBinop(node);
1357 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1376 if (lower()) ChangeToPureOp(node, Int32Op(node));
1358 return; 1377 return;
1359 } 1378 }
1360 // Try to use type feedback. 1379 // Try to use type feedback.
1361 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); 1380 NumberOperationHint hint = NumberOperationHintOf(node->op());
1381 if (hint == NumberOperationHint::kNone) {
1382 // TODO(turbofan): Shall we change any deopts that are caused by this
1383 // speculation to soft ones so we don't count against the deopt limit?
1384 if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
1385 TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
1386 hint = NumberOperationHint::kSigned32;
1387 } else {
1388 hint = NumberOperationHint::kNumberOrOddball;
1389 }
1390 }
1362 Type* input0_type = TypeOf(node->InputAt(0)); 1391 Type* input0_type = TypeOf(node->InputAt(0));
1363 Type* input1_type = TypeOf(node->InputAt(1)); 1392 Type* input1_type = TypeOf(node->InputAt(1));
1364 1393
1365 // Handle the case when no int32 checks on inputs are necessary 1394 // Handle the case when no int32 checks on inputs are necessary
1366 // (but an overflow check is needed on the output). 1395 // (but an overflow check is needed on the output).
1367 if (BothInputsAre(node, Type::Signed32())) { 1396 if (BothInputsAre(node, Type::Signed32())) {
1368 // If both the inputs the feedback are int32, use the overflow op. 1397 // If both the inputs the feedback are int32, use the overflow op.
1369 if (hint == BinaryOperationHints::kSignedSmall || 1398 if (hint == NumberOperationHint::kSigned32) {
1370 hint == BinaryOperationHints::kSigned32) {
1371 VisitBinop(node, UseInfo::TruncatingWord32(), 1399 VisitBinop(node, UseInfo::TruncatingWord32(),
1372 MachineRepresentation::kWord32, Type::Signed32()); 1400 MachineRepresentation::kWord32, Type::Signed32());
1373 if (lower()) { 1401 if (lower()) {
1374 LowerToCheckedInt32Mul(node, truncation, input0_type, 1402 LowerToCheckedInt32Mul(node, truncation, input0_type,
1375 input1_type); 1403 input1_type);
1376 } 1404 }
1377 return; 1405 return;
1378 } 1406 }
1379 } 1407 }
1380 1408
1381 if (hint == BinaryOperationHints::kSignedSmall || 1409 if (hint == NumberOperationHint::kSigned32) {
1382 hint == BinaryOperationHints::kSigned32) {
1383 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1410 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1384 MachineRepresentation::kWord32, Type::Signed32()); 1411 MachineRepresentation::kWord32, Type::Signed32());
1385 if (lower()) { 1412 if (lower()) {
1386 LowerToCheckedInt32Mul(node, truncation, input0_type, input1_type); 1413 LowerToCheckedInt32Mul(node, truncation, input0_type, input1_type);
1387 } 1414 }
1388 return; 1415 return;
1389 } 1416 }
1390 1417
1391 // Checked float64 x float64 => float64 1418 // Checked float64 x float64 => float64
1419 DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
1392 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), 1420 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1393 MachineRepresentation::kFloat64, Type::Number()); 1421 MachineRepresentation::kFloat64, Type::Number());
1394 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1422 if (lower()) ChangeToPureOp(node, Float64Op(node));
1395 return; 1423 return;
1396 } 1424 }
1397 case IrOpcode::kNumberMultiply: { 1425 case IrOpcode::kNumberMultiply: {
1398 if (BothInputsAre(node, Type::Integral32()) && 1426 if (BothInputsAre(node, Type::Integral32()) &&
1399 (NodeProperties::GetType(node)->Is(Type::Signed32()) || 1427 (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
1400 NodeProperties::GetType(node)->Is(Type::Unsigned32()) || 1428 NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
1401 (truncation.IsUsedAsWord32() && 1429 (truncation.IsUsedAsWord32() &&
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 } 1466 }
1439 if (truncation.IsUsedAsWord32()) { 1467 if (truncation.IsUsedAsWord32()) {
1440 // => signed Int32Div 1468 // => signed Int32Div
1441 VisitWord32TruncatingBinop(node); 1469 VisitWord32TruncatingBinop(node);
1442 if (lower()) DeferReplacement(node, lowering->Int32Div(node)); 1470 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1443 return; 1471 return;
1444 } 1472 }
1445 } 1473 }
1446 1474
1447 // Try to use type feedback. 1475 // Try to use type feedback.
1448 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); 1476 NumberOperationHint hint = NumberOperationHintOf(node->op());
1477 if (hint == NumberOperationHint::kNone) {
1478 // TODO(turbofan): Shall we change any deopts that are caused by this
1479 // speculation to soft ones so we don't count against the deopt limit?
1480 if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
1481 TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
1482 hint = NumberOperationHint::kSigned32;
1483 } else {
1484 hint = NumberOperationHint::kNumberOrOddball;
1485 }
1486 }
1449 1487
1450 // Handle the case when no uint32 checks on inputs are necessary 1488 // Handle the case when no uint32 checks on inputs are necessary
1451 // (but an overflow check is needed on the output). 1489 // (but an overflow check is needed on the output).
1452 if (BothInputsAreUnsigned32(node)) { 1490 if (BothInputsAreUnsigned32(node)) {
1453 if (hint == BinaryOperationHints::kSignedSmall || 1491 if (hint == NumberOperationHint::kSigned32) {
1454 hint == BinaryOperationHints::kSigned32) {
1455 VisitBinop(node, UseInfo::TruncatingWord32(), 1492 VisitBinop(node, UseInfo::TruncatingWord32(),
1456 MachineRepresentation::kWord32, Type::Unsigned32()); 1493 MachineRepresentation::kWord32, Type::Unsigned32());
1457 if (lower()) ChangeToUint32OverflowOp(node); 1494 if (lower()) ChangeToUint32OverflowOp(node);
1458 return; 1495 return;
1459 } 1496 }
1460 } 1497 }
1461 1498
1462 // Handle the case when no int32 checks on inputs are necessary 1499 // Handle the case when no int32 checks on inputs are necessary
1463 // (but an overflow check is needed on the output). 1500 // (but an overflow check is needed on the output).
1464 if (BothInputsAreSigned32(node)) { 1501 if (BothInputsAreSigned32(node)) {
1465 // If both the inputs the feedback are int32, use the overflow op. 1502 // If both the inputs the feedback are int32, use the overflow op.
1466 if (hint == BinaryOperationHints::kSignedSmall || 1503 if (hint == NumberOperationHint::kSigned32) {
1467 hint == BinaryOperationHints::kSigned32) {
1468 VisitBinop(node, UseInfo::TruncatingWord32(), 1504 VisitBinop(node, UseInfo::TruncatingWord32(),
1469 MachineRepresentation::kWord32, Type::Signed32()); 1505 MachineRepresentation::kWord32, Type::Signed32());
1470 if (lower()) ChangeToInt32OverflowOp(node); 1506 if (lower()) ChangeToInt32OverflowOp(node);
1471 return; 1507 return;
1472 } 1508 }
1473 } 1509 }
1474 1510
1475 if (hint == BinaryOperationHints::kSignedSmall || 1511 if (hint == NumberOperationHint::kSigned32) {
1476 hint == BinaryOperationHints::kSigned32) {
1477 // If the result is truncated, we only need to check the inputs. 1512 // If the result is truncated, we only need to check the inputs.
1478 if (truncation.IsUsedAsWord32()) { 1513 if (truncation.IsUsedAsWord32()) {
1479 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1514 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1480 MachineRepresentation::kWord32); 1515 MachineRepresentation::kWord32);
1481 if (lower()) DeferReplacement(node, lowering->Int32Div(node)); 1516 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1482 } else { 1517 } else {
1483 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1518 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1484 MachineRepresentation::kWord32, Type::Signed32()); 1519 MachineRepresentation::kWord32, Type::Signed32());
1485 if (lower()) ChangeToInt32OverflowOp(node); 1520 if (lower()) ChangeToInt32OverflowOp(node);
1486 } 1521 }
1487 return; 1522 return;
1488 } 1523 }
1489 1524
1490 // default case => Float64Div 1525 // default case => Float64Div
1526 DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
1491 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), 1527 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1492 MachineRepresentation::kFloat64, Type::Number()); 1528 MachineRepresentation::kFloat64, Type::Number());
1493 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1529 if (lower()) ChangeToPureOp(node, Float64Op(node));
1494 return; 1530 return;
1495 } 1531 }
1496 case IrOpcode::kNumberDivide: { 1532 case IrOpcode::kNumberDivide: {
1497 if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) { 1533 if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
1498 // => unsigned Uint32Div 1534 // => unsigned Uint32Div
1499 VisitWord32TruncatingBinop(node); 1535 VisitWord32TruncatingBinop(node);
1500 if (lower()) DeferReplacement(node, lowering->Uint32Div(node)); 1536 if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 } 1586 }
1551 if (truncation.IsUsedAsWord32()) { 1587 if (truncation.IsUsedAsWord32()) {
1552 // => signed Int32Mod 1588 // => signed Int32Mod
1553 VisitWord32TruncatingBinop(node); 1589 VisitWord32TruncatingBinop(node);
1554 if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); 1590 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1555 return; 1591 return;
1556 } 1592 }
1557 } 1593 }
1558 1594
1559 // Try to use type feedback. 1595 // Try to use type feedback.
1560 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); 1596 NumberOperationHint hint = NumberOperationHintOf(node->op());
1597 if (hint == NumberOperationHint::kNone) {
1598 // TODO(turbofan): Shall we change any deopts that are caused by this
1599 // speculation to soft ones so we don't count against the deopt limit?
1600 if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
1601 TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
1602 hint = NumberOperationHint::kSigned32;
1603 } else {
1604 hint = NumberOperationHint::kNumberOrOddball;
1605 }
1606 }
1561 1607
1562 // Handle the case when no uint32 checks on inputs are necessary 1608 // Handle the case when no uint32 checks on inputs are necessary
1563 // (but an overflow check is needed on the output). 1609 // (but an overflow check is needed on the output).
1564 if (BothInputsAreUnsigned32(node)) { 1610 if (BothInputsAreUnsigned32(node)) {
1565 if (hint == BinaryOperationHints::kSignedSmall || 1611 if (hint == NumberOperationHint::kSigned32) {
1566 hint == BinaryOperationHints::kSigned32) {
1567 VisitBinop(node, UseInfo::TruncatingWord32(), 1612 VisitBinop(node, UseInfo::TruncatingWord32(),
1568 MachineRepresentation::kWord32, Type::Unsigned32()); 1613 MachineRepresentation::kWord32, Type::Unsigned32());
1569 if (lower()) ChangeToUint32OverflowOp(node); 1614 if (lower()) ChangeToUint32OverflowOp(node);
1570 return; 1615 return;
1571 } 1616 }
1572 } 1617 }
1573 1618
1574 // Handle the case when no int32 checks on inputs are necessary 1619 // Handle the case when no int32 checks on inputs are necessary
1575 // (but an overflow check is needed on the output). 1620 // (but an overflow check is needed on the output).
1576 if (BothInputsAre(node, Type::Signed32())) { 1621 if (BothInputsAre(node, Type::Signed32())) {
1577 // If both the inputs the feedback are int32, use the overflow op. 1622 // If both the inputs the feedback are int32, use the overflow op.
1578 if (hint == BinaryOperationHints::kSignedSmall || 1623 if (hint == NumberOperationHint::kSigned32) {
1579 hint == BinaryOperationHints::kSigned32) {
1580 VisitBinop(node, UseInfo::TruncatingWord32(), 1624 VisitBinop(node, UseInfo::TruncatingWord32(),
1581 MachineRepresentation::kWord32, Type::Signed32()); 1625 MachineRepresentation::kWord32, Type::Signed32());
1582 if (lower()) ChangeToInt32OverflowOp(node); 1626 if (lower()) ChangeToInt32OverflowOp(node);
1583 return; 1627 return;
1584 } 1628 }
1585 } 1629 }
1586 1630
1587 if (hint == BinaryOperationHints::kSignedSmall || 1631 if (hint == NumberOperationHint::kSigned32) {
1588 hint == BinaryOperationHints::kSigned32) {
1589 // If the result is truncated, we only need to check the inputs. 1632 // If the result is truncated, we only need to check the inputs.
1590 if (truncation.IsUsedAsWord32()) { 1633 if (truncation.IsUsedAsWord32()) {
1591 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1634 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1592 MachineRepresentation::kWord32); 1635 MachineRepresentation::kWord32);
1593 if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); 1636 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1594 } else { 1637 } else {
1595 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1638 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1596 MachineRepresentation::kWord32, Type::Signed32()); 1639 MachineRepresentation::kWord32, Type::Signed32());
1597 if (lower()) ChangeToInt32OverflowOp(node); 1640 if (lower()) ChangeToInt32OverflowOp(node);
1598 } 1641 }
1599 return; 1642 return;
1600 } 1643 }
1601 1644
1602 // default case => Float64Mod 1645 // default case => Float64Mod
1646 DCHECK_EQ(NumberOperationHint::kNumberOrOddball, hint);
1603 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(), 1647 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1604 MachineRepresentation::kFloat64, Type::Number()); 1648 MachineRepresentation::kFloat64, Type::Number());
1605 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1649 if (lower()) ChangeToPureOp(node, Float64Op(node));
1606 return; 1650 return;
1607 } 1651 }
1608 case IrOpcode::kNumberModulus: { 1652 case IrOpcode::kNumberModulus: {
1609 if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) { 1653 if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
1610 // => unsigned Uint32Mod 1654 // => unsigned Uint32Mod
1611 VisitWord32TruncatingBinop(node); 1655 VisitWord32TruncatingBinop(node);
1612 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); 1656 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 if (BothInputsAre(node, Type::NumberOrOddball())) { 1702 if (BothInputsAre(node, Type::NumberOrOddball())) {
1659 Type* rhs_type = GetUpperBound(node->InputAt(1)); 1703 Type* rhs_type = GetUpperBound(node->InputAt(1));
1660 VisitBinop(node, UseInfo::TruncatingWord32(), 1704 VisitBinop(node, UseInfo::TruncatingWord32(),
1661 UseInfo::TruncatingWord32(), 1705 UseInfo::TruncatingWord32(),
1662 MachineRepresentation::kWord32); 1706 MachineRepresentation::kWord32);
1663 if (lower()) { 1707 if (lower()) {
1664 lowering->DoShift(node, lowering->machine()->Word32Shl(), rhs_type); 1708 lowering->DoShift(node, lowering->machine()->Word32Shl(), rhs_type);
1665 } 1709 }
1666 return; 1710 return;
1667 } 1711 }
1668 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); 1712 NumberOperationHint hint = NumberOperationHintOf(node->op());
1669 if (hint == BinaryOperationHints::kSignedSmall || 1713 if (hint == NumberOperationHint::kNone) {
1670 hint == BinaryOperationHints::kSigned32) { 1714 // TODO(turbofan): Shall we change any deopts that are caused by this
1715 // speculation to soft ones so we don't count against the deopt limit?
1716 if (TypeOf(node->InputAt(0))->Maybe(Type::Signed32()) &&
1717 TypeOf(node->InputAt(1))->Maybe(Type::Signed32())) {
1718 hint = NumberOperationHint::kSigned32;
1719 } else {
1720 hint = NumberOperationHint::kNumberOrOddball;
1721 }
1722 }
1723 if (hint == NumberOperationHint::kSigned32) {
1671 Type* rhs_type = GetUpperBound(node->InputAt(1)); 1724 Type* rhs_type = GetUpperBound(node->InputAt(1));
1672 if (truncation.IsUsedAsWord32()) { 1725 if (truncation.IsUsedAsWord32()) {
1673 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1726 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1674 MachineRepresentation::kWord32); 1727 MachineRepresentation::kWord32);
1675 if (lower()) { 1728 if (lower()) {
1676 lowering->DoShift(node, lowering->machine()->Word32Shl(), 1729 lowering->DoShift(node, lowering->machine()->Word32Shl(),
1677 rhs_type); 1730 rhs_type);
1678 } 1731 }
1679 } else { 1732 } else {
1680 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), 1733 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
3504 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3557 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3505 Operator::kNoProperties); 3558 Operator::kNoProperties);
3506 to_number_operator_.set(common()->Call(desc)); 3559 to_number_operator_.set(common()->Call(desc));
3507 } 3560 }
3508 return to_number_operator_.get(); 3561 return to_number_operator_.get();
3509 } 3562 }
3510 3563
3511 } // namespace compiler 3564 } // namespace compiler
3512 } // namespace internal 3565 } // namespace internal
3513 } // namespace v8 3566 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698