| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 return false; | 1498 return false; |
| 1499 } | 1499 } |
| 1500 AddCheckClass(call->ArgumentAt(0), | 1500 AddCheckClass(call->ArgumentAt(0), |
| 1501 ICData::ZoneHandle( | 1501 ICData::ZoneHandle( |
| 1502 call->ic_data()->AsUnaryClassChecksForArgNr(0)), | 1502 call->ic_data()->AsUnaryClassChecksForArgNr(0)), |
| 1503 call->deopt_id(), | 1503 call->deopt_id(), |
| 1504 call->env(), | 1504 call->env(), |
| 1505 call); | 1505 call); |
| 1506 intptr_t mask = 0; | 1506 intptr_t mask = 0; |
| 1507 if (getter == MethodRecognizer::kFloat32x4Shuffle) { | 1507 if (getter == MethodRecognizer::kFloat32x4Shuffle) { |
| 1508 // Extract shuffle mask. |
| 1508 ASSERT(call->ArgumentCount() == 2); | 1509 ASSERT(call->ArgumentCount() == 2); |
| 1509 // Extract shuffle mask. | |
| 1510 Definition* mask_definition = call->ArgumentAt(1); | 1510 Definition* mask_definition = call->ArgumentAt(1); |
| 1511 if (!mask_definition->IsConstant()) { | 1511 if (!mask_definition->IsConstant()) { |
| 1512 // Not a constant. | 1512 // Not a constant. |
| 1513 return false; | 1513 return false; |
| 1514 } | 1514 } |
| 1515 ASSERT(mask_definition->IsConstant()); | 1515 ASSERT(mask_definition->IsConstant()); |
| 1516 ConstantInstr* constant_instruction = mask_definition->AsConstant(); | 1516 ConstantInstr* constant_instruction = mask_definition->AsConstant(); |
| 1517 const Object& constant_mask = constant_instruction->value(); | 1517 const Object& constant_mask = constant_instruction->value(); |
| 1518 if (!constant_mask.IsSmi()) { | 1518 if (!constant_mask.IsSmi()) { |
| 1519 // Not a smi. | 1519 // Not a smi. |
| 1520 return false; | 1520 return false; |
| 1521 } | 1521 } |
| 1522 ASSERT(constant_mask.IsSmi()); | 1522 ASSERT(constant_mask.IsSmi()); |
| 1523 mask = Smi::Cast(constant_mask).Value(); | 1523 mask = Smi::Cast(constant_mask).Value(); |
| 1524 if (mask < 0 || mask > 255) { | 1524 if (mask < 0 || mask > 255) { |
| 1525 // Not a valid mask. | 1525 // Not a valid mask. |
| 1526 return false; | 1526 return false; |
| 1527 } | 1527 } |
| 1528 } | 1528 } |
| 1529 Float32x4ShuffleInstr* instr = new Float32x4ShuffleInstr( | 1529 if (getter == MethodRecognizer::kFloat32x4GetSignMask) { |
| 1530 getter, | 1530 Simd32x4GetSignMaskInstr* instr = new Simd32x4GetSignMaskInstr( |
| 1531 new Value(call->ArgumentAt(0)), | 1531 getter, |
| 1532 mask, | 1532 new Value(call->ArgumentAt(0)), |
| 1533 call->deopt_id()); | 1533 call->deopt_id()); |
| 1534 ReplaceCall(call, instr); | 1534 ReplaceCall(call, instr); |
| 1535 return true; | 1535 return true; |
| 1536 } else { |
| 1537 ASSERT((getter == MethodRecognizer::kFloat32x4Shuffle) || |
| 1538 (getter == MethodRecognizer::kFloat32x4ShuffleX) || |
| 1539 (getter == MethodRecognizer::kFloat32x4ShuffleY) || |
| 1540 (getter == MethodRecognizer::kFloat32x4ShuffleZ) || |
| 1541 (getter == MethodRecognizer::kFloat32x4ShuffleW)); |
| 1542 Float32x4ShuffleInstr* instr = new Float32x4ShuffleInstr( |
| 1543 getter, |
| 1544 new Value(call->ArgumentAt(0)), |
| 1545 mask, |
| 1546 call->deopt_id()); |
| 1547 ReplaceCall(call, instr); |
| 1548 return true; |
| 1549 } |
| 1550 UNREACHABLE(); |
| 1551 return false; |
| 1536 } | 1552 } |
| 1537 | 1553 |
| 1538 | 1554 |
| 1539 bool FlowGraphOptimizer::InlineUint32x4Getter(InstanceCallInstr* call, | 1555 bool FlowGraphOptimizer::InlineUint32x4Getter(InstanceCallInstr* call, |
| 1540 MethodRecognizer::Kind getter) { | 1556 MethodRecognizer::Kind getter) { |
| 1541 if (!ShouldInlineSimd()) { | 1557 if (!ShouldInlineSimd()) { |
| 1542 return false; | 1558 return false; |
| 1543 } | 1559 } |
| 1544 AddCheckClass(call->ArgumentAt(0), | 1560 AddCheckClass(call->ArgumentAt(0), |
| 1545 ICData::ZoneHandle( | 1561 ICData::ZoneHandle( |
| 1546 call->ic_data()->AsUnaryClassChecksForArgNr(0)), | 1562 call->ic_data()->AsUnaryClassChecksForArgNr(0)), |
| 1547 call->deopt_id(), | 1563 call->deopt_id(), |
| 1548 call->env(), | 1564 call->env(), |
| 1549 call); | 1565 call); |
| 1550 Uint32x4GetFlagInstr* instr = new Uint32x4GetFlagInstr( | 1566 if (getter == MethodRecognizer::kUint32x4GetSignMask) { |
| 1551 getter, | 1567 Simd32x4GetSignMaskInstr* instr = new Simd32x4GetSignMaskInstr( |
| 1552 new Value(call->ArgumentAt(0)), | 1568 getter, |
| 1553 call->deopt_id()); | 1569 new Value(call->ArgumentAt(0)), |
| 1554 ReplaceCall(call, instr); | 1570 call->deopt_id()); |
| 1555 return true; | 1571 ReplaceCall(call, instr); |
| 1572 return true; |
| 1573 } else { |
| 1574 Uint32x4GetFlagInstr* instr = new Uint32x4GetFlagInstr( |
| 1575 getter, |
| 1576 new Value(call->ArgumentAt(0)), |
| 1577 call->deopt_id()); |
| 1578 ReplaceCall(call, instr); |
| 1579 return true; |
| 1580 } |
| 1556 } | 1581 } |
| 1557 | 1582 |
| 1558 | 1583 |
| 1559 bool FlowGraphOptimizer::InlineFloat32x4BinaryOp(InstanceCallInstr* call, | 1584 bool FlowGraphOptimizer::InlineFloat32x4BinaryOp(InstanceCallInstr* call, |
| 1560 Token::Kind op_kind) { | 1585 Token::Kind op_kind) { |
| 1561 if (!ShouldInlineSimd()) { | 1586 if (!ShouldInlineSimd()) { |
| 1562 return false; | 1587 return false; |
| 1563 } | 1588 } |
| 1564 ASSERT(call->ArgumentCount() == 2); | 1589 ASSERT(call->ArgumentCount() == 2); |
| 1565 Definition* left = call->ArgumentAt(0); | 1590 Definition* left = call->ArgumentAt(0); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 if (!ic_data.HasOneTarget()) { | 1708 if (!ic_data.HasOneTarget()) { |
| 1684 // Target is not only StringBase_get_isEmpty. | 1709 // Target is not only StringBase_get_isEmpty. |
| 1685 return false; | 1710 return false; |
| 1686 } | 1711 } |
| 1687 InlineStringIsEmptyGetter(call); | 1712 InlineStringIsEmptyGetter(call); |
| 1688 return true; | 1713 return true; |
| 1689 case MethodRecognizer::kFloat32x4ShuffleX: | 1714 case MethodRecognizer::kFloat32x4ShuffleX: |
| 1690 case MethodRecognizer::kFloat32x4ShuffleY: | 1715 case MethodRecognizer::kFloat32x4ShuffleY: |
| 1691 case MethodRecognizer::kFloat32x4ShuffleZ: | 1716 case MethodRecognizer::kFloat32x4ShuffleZ: |
| 1692 case MethodRecognizer::kFloat32x4ShuffleW: | 1717 case MethodRecognizer::kFloat32x4ShuffleW: |
| 1718 case MethodRecognizer::kFloat32x4GetSignMask: |
| 1693 if (!ic_data.HasReceiverClassId(kFloat32x4Cid) || | 1719 if (!ic_data.HasReceiverClassId(kFloat32x4Cid) || |
| 1694 !ic_data.HasOneTarget()) { | 1720 !ic_data.HasOneTarget()) { |
| 1695 return false; | 1721 return false; |
| 1696 } | 1722 } |
| 1697 return InlineFloat32x4Getter(call, recognized_kind); | 1723 return InlineFloat32x4Getter(call, recognized_kind); |
| 1698 case MethodRecognizer::kUint32x4GetFlagX: | 1724 case MethodRecognizer::kUint32x4GetFlagX: |
| 1699 case MethodRecognizer::kUint32x4GetFlagY: | 1725 case MethodRecognizer::kUint32x4GetFlagY: |
| 1700 case MethodRecognizer::kUint32x4GetFlagZ: | 1726 case MethodRecognizer::kUint32x4GetFlagZ: |
| 1701 case MethodRecognizer::kUint32x4GetFlagW: { | 1727 case MethodRecognizer::kUint32x4GetFlagW: |
| 1728 case MethodRecognizer::kUint32x4GetSignMask: { |
| 1702 if (!ic_data.HasReceiverClassId(kUint32x4Cid) || | 1729 if (!ic_data.HasReceiverClassId(kUint32x4Cid) || |
| 1703 !ic_data.HasOneTarget()) { | 1730 !ic_data.HasOneTarget()) { |
| 1704 return false; | 1731 return false; |
| 1705 } | 1732 } |
| 1706 return InlineUint32x4Getter(call, recognized_kind); | 1733 return InlineUint32x4Getter(call, recognized_kind); |
| 1707 } | 1734 } |
| 1708 default: | 1735 default: |
| 1709 ASSERT(recognized_kind == MethodRecognizer::kUnknown); | 1736 ASSERT(recognized_kind == MethodRecognizer::kUnknown); |
| 1710 } | 1737 } |
| 1711 return false; | 1738 return false; |
| (...skipping 4791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6503 Float32x4ConstructorInstr* instr) { | 6530 Float32x4ConstructorInstr* instr) { |
| 6504 SetValue(instr, non_constant_); | 6531 SetValue(instr, non_constant_); |
| 6505 } | 6532 } |
| 6506 | 6533 |
| 6507 | 6534 |
| 6508 void ConstantPropagator::VisitFloat32x4Shuffle(Float32x4ShuffleInstr* instr) { | 6535 void ConstantPropagator::VisitFloat32x4Shuffle(Float32x4ShuffleInstr* instr) { |
| 6509 SetValue(instr, non_constant_); | 6536 SetValue(instr, non_constant_); |
| 6510 } | 6537 } |
| 6511 | 6538 |
| 6512 | 6539 |
| 6540 void ConstantPropagator::VisitSimd32x4GetSignMask( |
| 6541 Simd32x4GetSignMaskInstr* instr) { |
| 6542 SetValue(instr, non_constant_); |
| 6543 } |
| 6544 |
| 6545 |
| 6513 void ConstantPropagator::VisitFloat32x4Zero(Float32x4ZeroInstr* instr) { | 6546 void ConstantPropagator::VisitFloat32x4Zero(Float32x4ZeroInstr* instr) { |
| 6514 SetValue(instr, non_constant_); | 6547 SetValue(instr, non_constant_); |
| 6515 } | 6548 } |
| 6516 | 6549 |
| 6517 | 6550 |
| 6518 void ConstantPropagator::VisitFloat32x4Splat(Float32x4SplatInstr* instr) { | 6551 void ConstantPropagator::VisitFloat32x4Splat(Float32x4SplatInstr* instr) { |
| 6519 SetValue(instr, non_constant_); | 6552 SetValue(instr, non_constant_); |
| 6520 } | 6553 } |
| 6521 | 6554 |
| 6522 | 6555 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6554 void ConstantPropagator::VisitFloat32x4With(Float32x4WithInstr* instr) { | 6587 void ConstantPropagator::VisitFloat32x4With(Float32x4WithInstr* instr) { |
| 6555 SetValue(instr, non_constant_); | 6588 SetValue(instr, non_constant_); |
| 6556 } | 6589 } |
| 6557 | 6590 |
| 6558 | 6591 |
| 6559 void ConstantPropagator::VisitFloat32x4ToUint32x4( | 6592 void ConstantPropagator::VisitFloat32x4ToUint32x4( |
| 6560 Float32x4ToUint32x4Instr* instr) { | 6593 Float32x4ToUint32x4Instr* instr) { |
| 6561 SetValue(instr, non_constant_); | 6594 SetValue(instr, non_constant_); |
| 6562 } | 6595 } |
| 6563 | 6596 |
| 6597 |
| 6564 void ConstantPropagator::VisitFloat32x4TwoArgShuffle( | 6598 void ConstantPropagator::VisitFloat32x4TwoArgShuffle( |
| 6565 Float32x4TwoArgShuffleInstr* instr) { | 6599 Float32x4TwoArgShuffleInstr* instr) { |
| 6566 SetValue(instr, non_constant_); | 6600 SetValue(instr, non_constant_); |
| 6567 } | 6601 } |
| 6568 | 6602 |
| 6569 | 6603 |
| 6570 void ConstantPropagator::VisitUint32x4BoolConstructor( | 6604 void ConstantPropagator::VisitUint32x4BoolConstructor( |
| 6571 Uint32x4BoolConstructorInstr* instr) { | 6605 Uint32x4BoolConstructorInstr* instr) { |
| 6572 SetValue(instr, non_constant_); | 6606 SetValue(instr, non_constant_); |
| 6573 } | 6607 } |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7535 } | 7569 } |
| 7536 | 7570 |
| 7537 // Insert materializations at environment uses. | 7571 // Insert materializations at environment uses. |
| 7538 for (intptr_t i = 0; i < exits.length(); i++) { | 7572 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7539 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7573 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7540 } | 7574 } |
| 7541 } | 7575 } |
| 7542 | 7576 |
| 7543 | 7577 |
| 7544 } // namespace dart | 7578 } // namespace dart |
| OLD | NEW |