| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 interface HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBailoutTarget(HBailoutTarget node); | 7 R visitBailoutTarget(HBailoutTarget node); |
| 8 R visitBitAnd(HBitAnd node); | 8 R visitBitAnd(HBitAnd node); |
| 9 R visitBitNot(HBitNot node); | 9 R visitBitNot(HBitNot node); |
| 10 R visitBitOr(HBitOr node); | 10 R visitBitOr(HBitOr node); |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 accept(HVisitor visitor) => visitor.visitForeignNew(this); | 1450 accept(HVisitor visitor) => visitor.visitForeignNew(this); |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 class HInvokeBinary extends HInvokeStatic { | 1453 class HInvokeBinary extends HInvokeStatic { |
| 1454 HInvokeBinary(HStatic target, HInstruction left, HInstruction right) | 1454 HInvokeBinary(HStatic target, HInstruction left, HInstruction right) |
| 1455 : super(<HInstruction>[target, left, right]); | 1455 : super(<HInstruction>[target, left, right]); |
| 1456 | 1456 |
| 1457 HInstruction get left() => inputs[1]; | 1457 HInstruction get left() => inputs[1]; |
| 1458 HInstruction get right() => inputs[2]; | 1458 HInstruction get right() => inputs[2]; |
| 1459 | 1459 |
| 1460 abstract BinaryOperation get operation(); | 1460 abstract BinaryOperation operation(FoldingOperations foldingOperations); |
| 1461 abstract get builtin(); | 1461 abstract get builtin(); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 class HBinaryArithmetic extends HInvokeBinary { | 1464 class HBinaryArithmetic extends HInvokeBinary { |
| 1465 HBinaryArithmetic(HStatic target, HInstruction left, HInstruction right) | 1465 HBinaryArithmetic(HStatic target, HInstruction left, HInstruction right) |
| 1466 : super(target, left, right); | 1466 : super(target, left, right); |
| 1467 | 1467 |
| 1468 void prepareGvn() { | 1468 void prepareGvn() { |
| 1469 // An arithmetic expression can take part in global value | 1469 // An arithmetic expression can take part in global value |
| 1470 // numbering and do not have any side-effects if we know that all | 1470 // numbering and do not have any side-effects if we know that all |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 if (input == right && left.isNumber()) return HType.NUMBER; | 1508 if (input == right && left.isNumber()) return HType.NUMBER; |
| 1509 return HType.UNKNOWN; | 1509 return HType.UNKNOWN; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 HType get likelyType() { | 1512 HType get likelyType() { |
| 1513 if (left.isTypeUnknown()) return HType.NUMBER; | 1513 if (left.isTypeUnknown()) return HType.NUMBER; |
| 1514 return HType.UNKNOWN; | 1514 return HType.UNKNOWN; |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 // TODO(1603): The class should be marked as abstract. | 1517 // TODO(1603): The class should be marked as abstract. |
| 1518 abstract BinaryOperation get operation(); | 1518 abstract BinaryOperation operation(FoldingOperations foldingOperations); |
| 1519 } | 1519 } |
| 1520 | 1520 |
| 1521 class HAdd extends HBinaryArithmetic { | 1521 class HAdd extends HBinaryArithmetic { |
| 1522 HAdd(HStatic target, HInstruction left, HInstruction right) | 1522 HAdd(HStatic target, HInstruction left, HInstruction right) |
| 1523 : super(target, left, right); | 1523 : super(target, left, right); |
| 1524 accept(HVisitor visitor) => visitor.visitAdd(this); | 1524 accept(HVisitor visitor) => visitor.visitAdd(this); |
| 1525 | 1525 |
| 1526 AddOperation get operation() => const AddOperation(); | 1526 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1527 => foldingOperations.add; |
| 1527 int typeCode() => 5; | 1528 int typeCode() => 5; |
| 1528 bool typeEquals(other) => other is HAdd; | 1529 bool typeEquals(other) => other is HAdd; |
| 1529 bool dataEquals(HInstruction other) => true; | 1530 bool dataEquals(HInstruction other) => true; |
| 1530 } | 1531 } |
| 1531 | 1532 |
| 1532 class HDivide extends HBinaryArithmetic { | 1533 class HDivide extends HBinaryArithmetic { |
| 1533 HDivide(HStatic target, HInstruction left, HInstruction right) | 1534 HDivide(HStatic target, HInstruction left, HInstruction right) |
| 1534 : super(target, left, right); | 1535 : super(target, left, right); |
| 1535 accept(HVisitor visitor) => visitor.visitDivide(this); | 1536 accept(HVisitor visitor) => visitor.visitDivide(this); |
| 1536 | 1537 |
| 1537 HType computeTypeFromInputTypes() { | 1538 HType computeTypeFromInputTypes() { |
| 1538 if (left.isNumber()) return HType.DOUBLE; | 1539 if (left.isNumber()) return HType.DOUBLE; |
| 1539 return HType.UNKNOWN; | 1540 return HType.UNKNOWN; |
| 1540 } | 1541 } |
| 1541 | 1542 |
| 1542 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1543 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1543 // A division can never return an integer. So don't ask for integer inputs. | 1544 // A division can never return an integer. So don't ask for integer inputs. |
| 1544 if (propagatedType.isInteger()) return HType.UNKNOWN; | 1545 if (propagatedType.isInteger()) return HType.UNKNOWN; |
| 1545 return super.computeDesiredTypeForNonTargetInput(input); | 1546 return super.computeDesiredTypeForNonTargetInput(input); |
| 1546 } | 1547 } |
| 1547 | 1548 |
| 1548 DivideOperation get operation() => const DivideOperation(); | 1549 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1550 => foldingOperations.divide; |
| 1549 int typeCode() => 6; | 1551 int typeCode() => 6; |
| 1550 bool typeEquals(other) => other is HDivide; | 1552 bool typeEquals(other) => other is HDivide; |
| 1551 bool dataEquals(HInstruction other) => true; | 1553 bool dataEquals(HInstruction other) => true; |
| 1552 } | 1554 } |
| 1553 | 1555 |
| 1554 class HModulo extends HBinaryArithmetic { | 1556 class HModulo extends HBinaryArithmetic { |
| 1555 HModulo(HStatic target, HInstruction left, HInstruction right) | 1557 HModulo(HStatic target, HInstruction left, HInstruction right) |
| 1556 : super(target, left, right); | 1558 : super(target, left, right); |
| 1557 accept(HVisitor visitor) => visitor.visitModulo(this); | 1559 accept(HVisitor visitor) => visitor.visitModulo(this); |
| 1558 | 1560 |
| 1559 ModuloOperation get operation() => const ModuloOperation(); | 1561 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1562 => foldingOperations.modulo; |
| 1560 int typeCode() => 7; | 1563 int typeCode() => 7; |
| 1561 bool typeEquals(other) => other is HModulo; | 1564 bool typeEquals(other) => other is HModulo; |
| 1562 bool dataEquals(HInstruction other) => true; | 1565 bool dataEquals(HInstruction other) => true; |
| 1563 } | 1566 } |
| 1564 | 1567 |
| 1565 class HMultiply extends HBinaryArithmetic { | 1568 class HMultiply extends HBinaryArithmetic { |
| 1566 HMultiply(HStatic target, HInstruction left, HInstruction right) | 1569 HMultiply(HStatic target, HInstruction left, HInstruction right) |
| 1567 : super(target, left, right); | 1570 : super(target, left, right); |
| 1568 accept(HVisitor visitor) => visitor.visitMultiply(this); | 1571 accept(HVisitor visitor) => visitor.visitMultiply(this); |
| 1569 | 1572 |
| 1570 MultiplyOperation get operation() => const MultiplyOperation(); | 1573 BinaryOperation operation(FoldingOperations operations) |
| 1574 => operations.multiply; |
| 1571 int typeCode() => 8; | 1575 int typeCode() => 8; |
| 1572 bool typeEquals(other) => other is HMultiply; | 1576 bool typeEquals(other) => other is HMultiply; |
| 1573 bool dataEquals(HInstruction other) => true; | 1577 bool dataEquals(HInstruction other) => true; |
| 1574 } | 1578 } |
| 1575 | 1579 |
| 1576 class HSubtract extends HBinaryArithmetic { | 1580 class HSubtract extends HBinaryArithmetic { |
| 1577 HSubtract(HStatic target, HInstruction left, HInstruction right) | 1581 HSubtract(HStatic target, HInstruction left, HInstruction right) |
| 1578 : super(target, left, right); | 1582 : super(target, left, right); |
| 1579 accept(HVisitor visitor) => visitor.visitSubtract(this); | 1583 accept(HVisitor visitor) => visitor.visitSubtract(this); |
| 1580 | 1584 |
| 1581 SubtractOperation get operation() => const SubtractOperation(); | 1585 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1586 => foldingOperations.subtract; |
| 1582 int typeCode() => 9; | 1587 int typeCode() => 9; |
| 1583 bool typeEquals(other) => other is HSubtract; | 1588 bool typeEquals(other) => other is HSubtract; |
| 1584 bool dataEquals(HInstruction other) => true; | 1589 bool dataEquals(HInstruction other) => true; |
| 1585 } | 1590 } |
| 1586 | 1591 |
| 1587 /** | 1592 /** |
| 1588 * An [HSwitch] instruction has one input for the incoming | 1593 * An [HSwitch] instruction has one input for the incoming |
| 1589 * value, and one input per constant that it can switch on. | 1594 * value, and one input per constant that it can switch on. |
| 1590 * Its block has one successor per constant, and one for the default. | 1595 * Its block has one successor per constant, and one for the default. |
| 1591 */ | 1596 */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1605 accept(HVisitor visitor) => visitor.visitSwitch(this); | 1610 accept(HVisitor visitor) => visitor.visitSwitch(this); |
| 1606 | 1611 |
| 1607 String toString() => "HSwitch cases = $inputs"; | 1612 String toString() => "HSwitch cases = $inputs"; |
| 1608 } | 1613 } |
| 1609 | 1614 |
| 1610 class HTruncatingDivide extends HBinaryArithmetic { | 1615 class HTruncatingDivide extends HBinaryArithmetic { |
| 1611 HTruncatingDivide(HStatic target, HInstruction left, HInstruction right) | 1616 HTruncatingDivide(HStatic target, HInstruction left, HInstruction right) |
| 1612 : super(target, left, right); | 1617 : super(target, left, right); |
| 1613 accept(HVisitor visitor) => visitor.visitTruncatingDivide(this); | 1618 accept(HVisitor visitor) => visitor.visitTruncatingDivide(this); |
| 1614 | 1619 |
| 1615 TruncatingDivideOperation get operation() | 1620 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1616 => const TruncatingDivideOperation(); | 1621 => foldingOperations.truncatingDivide; |
| 1617 int typeCode() => 10; | 1622 int typeCode() => 10; |
| 1618 bool typeEquals(other) => other is HTruncatingDivide; | 1623 bool typeEquals(other) => other is HTruncatingDivide; |
| 1619 bool dataEquals(HInstruction other) => true; | 1624 bool dataEquals(HInstruction other) => true; |
| 1620 } | 1625 } |
| 1621 | 1626 |
| 1622 | 1627 |
| 1623 // TODO(floitsch): Should HBinaryArithmetic really be the super class of | 1628 // TODO(floitsch): Should HBinaryArithmetic really be the super class of |
| 1624 // HBinaryBitOp? | 1629 // HBinaryBitOp? |
| 1625 class HBinaryBitOp extends HBinaryArithmetic { | 1630 class HBinaryBitOp extends HBinaryArithmetic { |
| 1626 HBinaryBitOp(HStatic target, HInstruction left, HInstruction right) | 1631 HBinaryBitOp(HStatic target, HInstruction left, HInstruction right) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 // Shift left cannot be mapped to the native operator unless the | 1665 // Shift left cannot be mapped to the native operator unless the |
| 1661 // shift count is guaranteed to be an integer in the [0,31] range. | 1666 // shift count is guaranteed to be an integer in the [0,31] range. |
| 1662 bool get builtin() { | 1667 bool get builtin() { |
| 1663 if (!left.isNumber() || !right.isConstantInteger()) return false; | 1668 if (!left.isNumber() || !right.isConstantInteger()) return false; |
| 1664 HConstant rightConstant = right; | 1669 HConstant rightConstant = right; |
| 1665 IntConstant intConstant = rightConstant.constant; | 1670 IntConstant intConstant = rightConstant.constant; |
| 1666 int count = intConstant.value; | 1671 int count = intConstant.value; |
| 1667 return count >= 0 && count <= 31; | 1672 return count >= 0 && count <= 31; |
| 1668 } | 1673 } |
| 1669 | 1674 |
| 1670 ShiftLeftOperation get operation() => const ShiftLeftOperation(); | 1675 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1676 => foldingOperations.shiftLeft; |
| 1671 int typeCode() => 11; | 1677 int typeCode() => 11; |
| 1672 bool typeEquals(other) => other is HShiftLeft; | 1678 bool typeEquals(other) => other is HShiftLeft; |
| 1673 bool dataEquals(HInstruction other) => true; | 1679 bool dataEquals(HInstruction other) => true; |
| 1674 } | 1680 } |
| 1675 | 1681 |
| 1676 class HShiftRight extends HBinaryBitOp { | 1682 class HShiftRight extends HBinaryBitOp { |
| 1677 HShiftRight(HStatic target, HInstruction left, HInstruction right) | 1683 HShiftRight(HStatic target, HInstruction left, HInstruction right) |
| 1678 : super(target, left, right); | 1684 : super(target, left, right); |
| 1679 accept(HVisitor visitor) => visitor.visitShiftRight(this); | 1685 accept(HVisitor visitor) => visitor.visitShiftRight(this); |
| 1680 | 1686 |
| 1681 // Shift right cannot be mapped to the native operator easily. | 1687 // Shift right cannot be mapped to the native operator easily. |
| 1682 bool get builtin() => false; | 1688 bool get builtin() => false; |
| 1683 | 1689 |
| 1684 ShiftRightOperation get operation() => const ShiftRightOperation(); | 1690 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1691 => foldingOperations.shiftRight; |
| 1685 int typeCode() => 12; | 1692 int typeCode() => 12; |
| 1686 bool typeEquals(other) => other is HShiftRight; | 1693 bool typeEquals(other) => other is HShiftRight; |
| 1687 bool dataEquals(HInstruction other) => true; | 1694 bool dataEquals(HInstruction other) => true; |
| 1688 } | 1695 } |
| 1689 | 1696 |
| 1690 class HBitOr extends HBinaryBitOp { | 1697 class HBitOr extends HBinaryBitOp { |
| 1691 HBitOr(HStatic target, HInstruction left, HInstruction right) | 1698 HBitOr(HStatic target, HInstruction left, HInstruction right) |
| 1692 : super(target, left, right); | 1699 : super(target, left, right); |
| 1693 accept(HVisitor visitor) => visitor.visitBitOr(this); | 1700 accept(HVisitor visitor) => visitor.visitBitOr(this); |
| 1694 | 1701 |
| 1695 BitOrOperation get operation() => const BitOrOperation(); | 1702 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1703 => foldingOperations.bitOr; |
| 1696 int typeCode() => 13; | 1704 int typeCode() => 13; |
| 1697 bool typeEquals(other) => other is HBitOr; | 1705 bool typeEquals(other) => other is HBitOr; |
| 1698 bool dataEquals(HInstruction other) => true; | 1706 bool dataEquals(HInstruction other) => true; |
| 1699 } | 1707 } |
| 1700 | 1708 |
| 1701 class HBitAnd extends HBinaryBitOp { | 1709 class HBitAnd extends HBinaryBitOp { |
| 1702 HBitAnd(HStatic target, HInstruction left, HInstruction right) | 1710 HBitAnd(HStatic target, HInstruction left, HInstruction right) |
| 1703 : super(target, left, right); | 1711 : super(target, left, right); |
| 1704 accept(HVisitor visitor) => visitor.visitBitAnd(this); | 1712 accept(HVisitor visitor) => visitor.visitBitAnd(this); |
| 1705 | 1713 |
| 1706 BitAndOperation get operation() => const BitAndOperation(); | 1714 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1715 => foldingOperations.bitAnd; |
| 1707 int typeCode() => 14; | 1716 int typeCode() => 14; |
| 1708 bool typeEquals(other) => other is HBitAnd; | 1717 bool typeEquals(other) => other is HBitAnd; |
| 1709 bool dataEquals(HInstruction other) => true; | 1718 bool dataEquals(HInstruction other) => true; |
| 1710 } | 1719 } |
| 1711 | 1720 |
| 1712 class HBitXor extends HBinaryBitOp { | 1721 class HBitXor extends HBinaryBitOp { |
| 1713 HBitXor(HStatic target, HInstruction left, HInstruction right) | 1722 HBitXor(HStatic target, HInstruction left, HInstruction right) |
| 1714 : super(target, left, right); | 1723 : super(target, left, right); |
| 1715 accept(HVisitor visitor) => visitor.visitBitXor(this); | 1724 accept(HVisitor visitor) => visitor.visitBitXor(this); |
| 1716 | 1725 |
| 1717 BitXorOperation get operation() => const BitXorOperation(); | 1726 BinaryOperation operation(FoldingOperations foldingOperations) |
| 1727 => foldingOperations.bitXor; |
| 1718 int typeCode() => 15; | 1728 int typeCode() => 15; |
| 1719 bool typeEquals(other) => other is HBitXor; | 1729 bool typeEquals(other) => other is HBitXor; |
| 1720 bool dataEquals(HInstruction other) => true; | 1730 bool dataEquals(HInstruction other) => true; |
| 1721 } | 1731 } |
| 1722 | 1732 |
| 1723 class HInvokeUnary extends HInvokeStatic { | 1733 class HInvokeUnary extends HInvokeStatic { |
| 1724 HInvokeUnary(HStatic target, HInstruction input) | 1734 HInvokeUnary(HStatic target, HInstruction input) |
| 1725 : super(<HInstruction>[target, input]); | 1735 : super(<HInstruction>[target, input]); |
| 1726 | 1736 |
| 1727 HInstruction get operand() => inputs[1]; | 1737 HInstruction get operand() => inputs[1]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1750 // If the outgoing type should be a number (integer, double or both) we | 1760 // If the outgoing type should be a number (integer, double or both) we |
| 1751 // want the outgoing type to be the input too. | 1761 // want the outgoing type to be the input too. |
| 1752 // If we don't know the outgoing type we try to make it a number. | 1762 // If we don't know the outgoing type we try to make it a number. |
| 1753 if (propagatedType.isNumber()) return propagatedType; | 1763 if (propagatedType.isNumber()) return propagatedType; |
| 1754 if (propagatedType.isUnknown()) return HType.NUMBER; | 1764 if (propagatedType.isUnknown()) return HType.NUMBER; |
| 1755 return HType.UNKNOWN; | 1765 return HType.UNKNOWN; |
| 1756 } | 1766 } |
| 1757 | 1767 |
| 1758 HType get likelyType() => HType.NUMBER; | 1768 HType get likelyType() => HType.NUMBER; |
| 1759 | 1769 |
| 1760 abstract UnaryOperation get operation(); | 1770 abstract UnaryOperation operation(FoldingOperations foldingOperations); |
| 1761 } | 1771 } |
| 1762 | 1772 |
| 1763 class HNegate extends HInvokeUnary { | 1773 class HNegate extends HInvokeUnary { |
| 1764 HNegate(HStatic target, HInstruction input) : super(target, input); | 1774 HNegate(HStatic target, HInstruction input) : super(target, input); |
| 1765 accept(HVisitor visitor) => visitor.visitNegate(this); | 1775 accept(HVisitor visitor) => visitor.visitNegate(this); |
| 1766 | 1776 |
| 1767 NegateOperation get operation() => const NegateOperation(); | 1777 UnaryOperation operation(FoldingOperations foldingOperations) |
| 1778 => foldingOperations.negate; |
| 1768 int typeCode() => 16; | 1779 int typeCode() => 16; |
| 1769 bool typeEquals(other) => other is HNegate; | 1780 bool typeEquals(other) => other is HNegate; |
| 1770 bool dataEquals(HInstruction other) => true; | 1781 bool dataEquals(HInstruction other) => true; |
| 1771 } | 1782 } |
| 1772 | 1783 |
| 1773 class HBitNot extends HInvokeUnary { | 1784 class HBitNot extends HInvokeUnary { |
| 1774 HBitNot(HStatic target, HInstruction input) : super(target, input); | 1785 HBitNot(HStatic target, HInstruction input) : super(target, input); |
| 1775 accept(HVisitor visitor) => visitor.visitBitNot(this); | 1786 accept(HVisitor visitor) => visitor.visitBitNot(this); |
| 1776 | 1787 |
| 1777 HType computeTypeFromInputTypes() { | 1788 HType computeTypeFromInputTypes() { |
| 1778 // All bitwise operations on primitive types either produce an | 1789 // All bitwise operations on primitive types either produce an |
| 1779 // integer or throw an error. | 1790 // integer or throw an error. |
| 1780 if (operand.isPrimitive()) return HType.INTEGER; | 1791 if (operand.isPrimitive()) return HType.INTEGER; |
| 1781 return HType.UNKNOWN; | 1792 return HType.UNKNOWN; |
| 1782 } | 1793 } |
| 1783 | 1794 |
| 1784 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1795 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1785 // Bit operations only work on integers. If there is no desired output | 1796 // Bit operations only work on integers. If there is no desired output |
| 1786 // type or if it as a number we want to get an integer as input. | 1797 // type or if it as a number we want to get an integer as input. |
| 1787 if (propagatedType.isUnknown() || propagatedType.isNumber()) { | 1798 if (propagatedType.isUnknown() || propagatedType.isNumber()) { |
| 1788 return HType.INTEGER; | 1799 return HType.INTEGER; |
| 1789 } | 1800 } |
| 1790 return HType.UNKNOWN; | 1801 return HType.UNKNOWN; |
| 1791 } | 1802 } |
| 1792 | 1803 |
| 1793 BitNotOperation get operation() => const BitNotOperation(); | 1804 UnaryOperation operation(FoldingOperations foldingOperations) |
| 1805 => foldingOperations.bitNot; |
| 1794 int typeCode() => 17; | 1806 int typeCode() => 17; |
| 1795 bool typeEquals(other) => other is HBitNot; | 1807 bool typeEquals(other) => other is HBitNot; |
| 1796 bool dataEquals(HInstruction other) => true; | 1808 bool dataEquals(HInstruction other) => true; |
| 1797 } | 1809 } |
| 1798 | 1810 |
| 1799 class HExit extends HControlFlow { | 1811 class HExit extends HControlFlow { |
| 1800 HExit() : super(const <HInstruction>[]); | 1812 HExit() : super(const <HInstruction>[]); |
| 1801 toString() => 'exit'; | 1813 toString() => 'exit'; |
| 1802 accept(HVisitor visitor) => visitor.visitExit(this); | 1814 accept(HVisitor visitor) => visitor.visitExit(this); |
| 1803 } | 1815 } |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2076 return HType.NUMBER; | 2088 return HType.NUMBER; |
| 2077 } | 2089 } |
| 2078 } | 2090 } |
| 2079 return HType.UNKNOWN; | 2091 return HType.UNKNOWN; |
| 2080 } | 2092 } |
| 2081 | 2093 |
| 2082 HType get likelyType() => HType.BOOLEAN; | 2094 HType get likelyType() => HType.BOOLEAN; |
| 2083 | 2095 |
| 2084 bool get builtin() => left.isNumber() && right.isNumber(); | 2096 bool get builtin() => left.isNumber() && right.isNumber(); |
| 2085 // TODO(1603): the class should be marked as abstract. | 2097 // TODO(1603): the class should be marked as abstract. |
| 2086 abstract BinaryOperation get operation(); | 2098 abstract BinaryOperation operation(FoldingOperations foldingOperations); |
| 2087 } | 2099 } |
| 2088 | 2100 |
| 2089 class HEquals extends HRelational { | 2101 class HEquals extends HRelational { |
| 2090 HEquals(HStatic target, HInstruction left, HInstruction right) | 2102 HEquals(HStatic target, HInstruction left, HInstruction right) |
| 2091 : super(target, left, right); | 2103 : super(target, left, right); |
| 2092 accept(HVisitor visitor) => visitor.visitEquals(this); | 2104 accept(HVisitor visitor) => visitor.visitEquals(this); |
| 2093 | 2105 |
| 2094 bool get builtin() { | 2106 bool get builtin() { |
| 2095 // All primitive types have === semantics. | 2107 // All primitive types have === semantics. |
| 2096 // Note that this includes all constants except the user-constructed | 2108 // Note that this includes all constants except the user-constructed |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2123 if (input == left && left.isIndexablePrimitive()) { | 2135 if (input == left && left.isIndexablePrimitive()) { |
| 2124 return HType.READABLE_ARRAY; | 2136 return HType.READABLE_ARRAY; |
| 2125 } | 2137 } |
| 2126 // String equality testing is much more common than array equality testing. | 2138 // String equality testing is much more common than array equality testing. |
| 2127 if (input == right && right.isIndexablePrimitive()) { | 2139 if (input == right && right.isIndexablePrimitive()) { |
| 2128 return HType.STRING; | 2140 return HType.STRING; |
| 2129 } | 2141 } |
| 2130 return HType.UNKNOWN; | 2142 return HType.UNKNOWN; |
| 2131 } | 2143 } |
| 2132 | 2144 |
| 2133 EqualsOperation get operation() => const EqualsOperation(); | 2145 BinaryOperation operation(FoldingOperations foldingOperations) |
| 2146 => foldingOperations.equal; |
| 2134 int typeCode() => 19; | 2147 int typeCode() => 19; |
| 2135 bool typeEquals(other) => other is HEquals; | 2148 bool typeEquals(other) => other is HEquals; |
| 2136 bool dataEquals(HInstruction other) => true; | 2149 bool dataEquals(HInstruction other) => true; |
| 2137 } | 2150 } |
| 2138 | 2151 |
| 2139 class HIdentity extends HRelational { | 2152 class HIdentity extends HRelational { |
| 2140 HIdentity(HStatic target, HInstruction left, HInstruction right) | 2153 HIdentity(HStatic target, HInstruction left, HInstruction right) |
| 2141 : super(target, left, right); | 2154 : super(target, left, right); |
| 2142 accept(HVisitor visitor) => visitor.visitIdentity(this); | 2155 accept(HVisitor visitor) => visitor.visitIdentity(this); |
| 2143 | 2156 |
| 2144 bool get builtin() => true; | 2157 bool get builtin() => true; |
| 2145 | 2158 |
| 2146 HType get guaranteedType() => HType.BOOLEAN; | 2159 HType get guaranteedType() => HType.BOOLEAN; |
| 2147 HType computeTypeFromInputTypes() => HType.BOOLEAN; | 2160 HType computeTypeFromInputTypes() => HType.BOOLEAN; |
| 2148 // Note that the identity operator really does not care for its input types. | 2161 // Note that the identity operator really does not care for its input types. |
| 2149 HType computeDesiredTypeForInput(HInstruction input) => HType.UNKNOWN; | 2162 HType computeDesiredTypeForInput(HInstruction input) => HType.UNKNOWN; |
| 2150 | 2163 |
| 2151 IdentityOperation get operation() => const IdentityOperation(); | 2164 BinaryOperation operation(FoldingOperations foldingOperations) |
| 2165 => foldingOperations.identity; |
| 2152 int typeCode() => 20; | 2166 int typeCode() => 20; |
| 2153 bool typeEquals(other) => other is HIdentity; | 2167 bool typeEquals(other) => other is HIdentity; |
| 2154 bool dataEquals(HInstruction other) => true; | 2168 bool dataEquals(HInstruction other) => true; |
| 2155 } | 2169 } |
| 2156 | 2170 |
| 2157 class HGreater extends HRelational { | 2171 class HGreater extends HRelational { |
| 2158 HGreater(HStatic target, HInstruction left, HInstruction right) | 2172 HGreater(HStatic target, HInstruction left, HInstruction right) |
| 2159 : super(target, left, right); | 2173 : super(target, left, right); |
| 2160 accept(HVisitor visitor) => visitor.visitGreater(this); | 2174 accept(HVisitor visitor) => visitor.visitGreater(this); |
| 2161 | 2175 |
| 2162 GreaterOperation get operation() => const GreaterOperation(); | 2176 BinaryOperation operation(FoldingOperations foldingOperations) |
| 2177 => foldingOperations.greater; |
| 2163 int typeCode() => 21; | 2178 int typeCode() => 21; |
| 2164 bool typeEquals(other) => other is HGreater; | 2179 bool typeEquals(other) => other is HGreater; |
| 2165 bool dataEquals(HInstruction other) => true; | 2180 bool dataEquals(HInstruction other) => true; |
| 2166 } | 2181 } |
| 2167 | 2182 |
| 2168 class HGreaterEqual extends HRelational { | 2183 class HGreaterEqual extends HRelational { |
| 2169 HGreaterEqual(HStatic target, HInstruction left, HInstruction right) | 2184 HGreaterEqual(HStatic target, HInstruction left, HInstruction right) |
| 2170 : super(target, left, right); | 2185 : super(target, left, right); |
| 2171 accept(HVisitor visitor) => visitor.visitGreaterEqual(this); | 2186 accept(HVisitor visitor) => visitor.visitGreaterEqual(this); |
| 2172 | 2187 |
| 2173 GreaterEqualOperation get operation() => const GreaterEqualOperation(); | 2188 BinaryOperation operation(FoldingOperations foldingOperations) |
| 2189 => foldingOperations.greaterEqual; |
| 2174 int typeCode() => 22; | 2190 int typeCode() => 22; |
| 2175 bool typeEquals(other) => other is HGreaterEqual; | 2191 bool typeEquals(other) => other is HGreaterEqual; |
| 2176 bool dataEquals(HInstruction other) => true; | 2192 bool dataEquals(HInstruction other) => true; |
| 2177 } | 2193 } |
| 2178 | 2194 |
| 2179 class HLess extends HRelational { | 2195 class HLess extends HRelational { |
| 2180 HLess(HStatic target, HInstruction left, HInstruction right) | 2196 HLess(HStatic target, HInstruction left, HInstruction right) |
| 2181 : super(target, left, right); | 2197 : super(target, left, right); |
| 2182 accept(HVisitor visitor) => visitor.visitLess(this); | 2198 accept(HVisitor visitor) => visitor.visitLess(this); |
| 2183 | 2199 |
| 2184 LessOperation get operation() => const LessOperation(); | 2200 BinaryOperation operation(FoldingOperations foldingOperations) |
| 2201 => foldingOperations.less; |
| 2185 int typeCode() => 23; | 2202 int typeCode() => 23; |
| 2186 bool typeEquals(other) => other is HLess; | 2203 bool typeEquals(other) => other is HLess; |
| 2187 bool dataEquals(HInstruction other) => true; | 2204 bool dataEquals(HInstruction other) => true; |
| 2188 } | 2205 } |
| 2189 | 2206 |
| 2190 class HLessEqual extends HRelational { | 2207 class HLessEqual extends HRelational { |
| 2191 HLessEqual(HStatic target, HInstruction left, HInstruction right) | 2208 HLessEqual(HStatic target, HInstruction left, HInstruction right) |
| 2192 : super(target, left, right); | 2209 : super(target, left, right); |
| 2193 accept(HVisitor visitor) => visitor.visitLessEqual(this); | 2210 accept(HVisitor visitor) => visitor.visitLessEqual(this); |
| 2194 | 2211 |
| 2195 LessEqualOperation get operation() => const LessEqualOperation(); | 2212 BinaryOperation operation(FoldingOperations foldingOperations) |
| 2213 => foldingOperations.lessEqual; |
| 2196 int typeCode() => 24; | 2214 int typeCode() => 24; |
| 2197 bool typeEquals(other) => other is HLessEqual; | 2215 bool typeEquals(other) => other is HLessEqual; |
| 2198 bool dataEquals(HInstruction other) => true; | 2216 bool dataEquals(HInstruction other) => true; |
| 2199 } | 2217 } |
| 2200 | 2218 |
| 2201 class HReturn extends HControlFlow { | 2219 class HReturn extends HControlFlow { |
| 2202 HReturn(value) : super(<HInstruction>[value]); | 2220 HReturn(value) : super(<HInstruction>[value]); |
| 2203 toString() => 'return'; | 2221 toString() => 'return'; |
| 2204 accept(HVisitor visitor) => visitor.visitReturn(this); | 2222 accept(HVisitor visitor) => visitor.visitReturn(this); |
| 2205 } | 2223 } |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2715 HBasicBlock get start() => expression.start; | 2733 HBasicBlock get start() => expression.start; |
| 2716 HBasicBlock get end() { | 2734 HBasicBlock get end() { |
| 2717 // We don't create a switch block if there are no cases. | 2735 // We don't create a switch block if there are no cases. |
| 2718 assert(!statements.isEmpty()); | 2736 assert(!statements.isEmpty()); |
| 2719 return statements.last().end; | 2737 return statements.last().end; |
| 2720 } | 2738 } |
| 2721 | 2739 |
| 2722 bool accept(HStatementInformationVisitor visitor) => | 2740 bool accept(HStatementInformationVisitor visitor) => |
| 2723 visitor.visitSwitchInfo(this); | 2741 visitor.visitSwitchInfo(this); |
| 2724 } | 2742 } |
| OLD | NEW |