Chromium Code Reviews| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class HVisitor<R> { | 7 abstract class HVisitor<R> { |
| 8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
| 9 R visitBailoutTarget(HBailoutTarget node); | 9 R visitBailoutTarget(HBailoutTarget node); |
| 10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 bool isPrimitive() => instructionType.isPrimitive(); | 896 bool isPrimitive() => instructionType.isPrimitive(); |
| 897 bool canBeNull() => instructionType.canBeNull(); | 897 bool canBeNull() => instructionType.canBeNull(); |
| 898 bool canBePrimitive(Compiler compiler) => | 898 bool canBePrimitive(Compiler compiler) => |
| 899 instructionType.canBePrimitive(compiler); | 899 instructionType.canBePrimitive(compiler); |
| 900 | 900 |
| 901 /** | 901 /** |
| 902 * Type of the unstruction. | 902 * Type of the unstruction. |
| 903 */ | 903 */ |
| 904 HType instructionType = HType.UNKNOWN; | 904 HType instructionType = HType.UNKNOWN; |
| 905 | 905 |
| 906 Selector get selector => null; | |
| 907 HInstruction getDartReceiver(Compiler compiler) => null; | |
| 908 | |
| 906 bool isInBasicBlock() => block != null; | 909 bool isInBasicBlock() => block != null; |
| 907 | 910 |
| 908 String inputsToString() { | 911 String inputsToString() { |
| 909 void addAsCommaSeparated(StringBuffer buffer, List<HInstruction> list) { | 912 void addAsCommaSeparated(StringBuffer buffer, List<HInstruction> list) { |
| 910 for (int i = 0; i < list.length; i++) { | 913 for (int i = 0; i < list.length; i++) { |
| 911 if (i != 0) buffer.write(', '); | 914 if (i != 0) buffer.write(', '); |
| 912 buffer.write("@${list[i].id}"); | 915 buffer.write("@${list[i].id}"); |
| 913 } | 916 } |
| 914 } | 917 } |
| 915 | 918 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 return new HTypeConversion(type, kind, HType.UNKNOWN, this); | 1131 return new HTypeConversion(type, kind, HType.UNKNOWN, this); |
| 1129 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { | 1132 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { |
| 1130 // Boolean conversion checks work on non-nullable booleans. | 1133 // Boolean conversion checks work on non-nullable booleans. |
| 1131 return new HTypeConversion(type, kind, HType.BOOLEAN, this); | 1134 return new HTypeConversion(type, kind, HType.BOOLEAN, this); |
| 1132 } else { | 1135 } else { |
| 1133 HType subtype = new HType.subtype(type, compiler); | 1136 HType subtype = new HType.subtype(type, compiler); |
| 1134 return new HTypeConversion(type, kind, subtype, this); | 1137 return new HTypeConversion(type, kind, subtype, this); |
| 1135 } | 1138 } |
| 1136 } | 1139 } |
| 1137 | 1140 |
| 1138 /** | 1141 /** |
| 1139 * Return whether the instructions do not belong to a loop or | 1142 * Return whether the instructions do not belong to a loop or |
| 1140 * belong to the same loop. | 1143 * belong to the same loop. |
| 1141 */ | 1144 */ |
| 1142 bool hasSameLoopHeaderAs(HInstruction other) { | 1145 bool hasSameLoopHeaderAs(HInstruction other) { |
| 1143 return block.enclosingLoopHeader == other.block.enclosingLoopHeader; | 1146 return block.enclosingLoopHeader == other.block.enclosingLoopHeader; |
| 1144 } | 1147 } |
| 1145 } | 1148 } |
| 1146 | 1149 |
| 1147 class HBoolify extends HInstruction { | 1150 class HBoolify extends HInstruction { |
| 1148 HBoolify(HInstruction value) : super(<HInstruction>[value]) { | 1151 HBoolify(HInstruction value) : super(<HInstruction>[value]) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1220 isEnabled = false; | 1223 isEnabled = false; |
| 1221 instructionType = guarded.instructionType; | 1224 instructionType = guarded.instructionType; |
| 1222 } | 1225 } |
| 1223 | 1226 |
| 1224 bool isControlFlow() => true; | 1227 bool isControlFlow() => true; |
| 1225 bool isJsStatement() => isEnabled; | 1228 bool isJsStatement() => isEnabled; |
| 1226 bool canThrow() => isEnabled; | 1229 bool canThrow() => isEnabled; |
| 1227 | 1230 |
| 1228 // A [HTypeGuard] cannot be moved anywhere in the graph, otherwise | 1231 // A [HTypeGuard] cannot be moved anywhere in the graph, otherwise |
| 1229 // instructions that have side effects could end up before the guard | 1232 // instructions that have side effects could end up before the guard |
| 1230 // in the otpimized version, and after the guard in a bailout | 1233 // in the optimized version, and after the guard in a bailout |
| 1231 // version. | 1234 // version. |
| 1232 bool isPure() => false; | 1235 bool isPure() => false; |
| 1233 | 1236 |
| 1234 accept(HVisitor visitor) => visitor.visitTypeGuard(this); | 1237 accept(HVisitor visitor) => visitor.visitTypeGuard(this); |
| 1235 int typeCode() => HInstruction.TYPE_GUARD_TYPECODE; | 1238 int typeCode() => HInstruction.TYPE_GUARD_TYPECODE; |
| 1236 bool typeEquals(other) => other is HTypeGuard; | 1239 bool typeEquals(other) => other is HTypeGuard; |
| 1237 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; | 1240 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; |
| 1238 } | 1241 } |
| 1239 | 1242 |
| 1240 class HBoundsCheck extends HCheck { | 1243 class HBoundsCheck extends HCheck { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1558 } | 1561 } |
| 1559 | 1562 |
| 1560 class HForeignNew extends HForeign { | 1563 class HForeignNew extends HForeign { |
| 1561 ClassElement element; | 1564 ClassElement element; |
| 1562 HForeignNew(this.element, HType type, List<HInstruction> inputs) | 1565 HForeignNew(this.element, HType type, List<HInstruction> inputs) |
| 1563 : super(const LiteralDartString("new"), type, inputs); | 1566 : super(const LiteralDartString("new"), type, inputs); |
| 1564 accept(HVisitor visitor) => visitor.visitForeignNew(this); | 1567 accept(HVisitor visitor) => visitor.visitForeignNew(this); |
| 1565 } | 1568 } |
| 1566 | 1569 |
| 1567 abstract class HInvokeBinary extends HInstruction { | 1570 abstract class HInvokeBinary extends HInstruction { |
| 1568 HInvokeBinary(HInstruction left, HInstruction right) | 1571 Selector selector; |
|
kasperl
2013/04/23 06:12:43
final?
ngeoffray
2013/04/23 08:06:04
Done.
| |
| 1572 HInvokeBinary(HInstruction left, HInstruction right, this.selector) | |
| 1569 : super(<HInstruction>[left, right]) { | 1573 : super(<HInstruction>[left, right]) { |
| 1570 clearAllSideEffects(); | 1574 clearAllSideEffects(); |
| 1571 setUseGvn(); | 1575 setUseGvn(); |
| 1572 } | 1576 } |
| 1573 | 1577 |
| 1574 HInstruction get left => inputs[0]; | 1578 HInstruction get left => inputs[0]; |
| 1575 HInstruction get right => inputs[1]; | 1579 HInstruction get right => inputs[1]; |
| 1576 | 1580 |
| 1577 BinaryOperation operation(ConstantSystem constantSystem); | 1581 BinaryOperation operation(ConstantSystem constantSystem); |
| 1578 } | 1582 } |
| 1579 | 1583 |
| 1580 abstract class HBinaryArithmetic extends HInvokeBinary { | 1584 abstract class HBinaryArithmetic extends HInvokeBinary { |
| 1581 HBinaryArithmetic(HInstruction left, HInstruction right) : super(left, right); | 1585 HBinaryArithmetic(left, right, selector) : super(left, right, selector); |
| 1582 BinaryOperation operation(ConstantSystem constantSystem); | 1586 BinaryOperation operation(ConstantSystem constantSystem); |
| 1583 } | 1587 } |
| 1584 | 1588 |
| 1585 class HAdd extends HBinaryArithmetic { | 1589 class HAdd extends HBinaryArithmetic { |
| 1586 HAdd(HInstruction left, HInstruction right) : super(left, right); | 1590 HAdd(left, right, selector) : super(left, right, selector); |
| 1587 accept(HVisitor visitor) => visitor.visitAdd(this); | 1591 accept(HVisitor visitor) => visitor.visitAdd(this); |
| 1588 | 1592 |
| 1589 BinaryOperation operation(ConstantSystem constantSystem) | 1593 BinaryOperation operation(ConstantSystem constantSystem) |
| 1590 => constantSystem.add; | 1594 => constantSystem.add; |
| 1591 int typeCode() => HInstruction.ADD_TYPECODE; | 1595 int typeCode() => HInstruction.ADD_TYPECODE; |
| 1592 bool typeEquals(other) => other is HAdd; | 1596 bool typeEquals(other) => other is HAdd; |
| 1593 bool dataEquals(HInstruction other) => true; | 1597 bool dataEquals(HInstruction other) => true; |
| 1594 } | 1598 } |
| 1595 | 1599 |
| 1596 class HDivide extends HBinaryArithmetic { | 1600 class HDivide extends HBinaryArithmetic { |
| 1597 HDivide(HInstruction left, HInstruction right) : super(left, right) { | 1601 HDivide(left, right, selector) : super(left, right, selector) { |
| 1598 instructionType = HType.DOUBLE; | 1602 instructionType = HType.DOUBLE; |
| 1599 } | 1603 } |
| 1600 accept(HVisitor visitor) => visitor.visitDivide(this); | 1604 accept(HVisitor visitor) => visitor.visitDivide(this); |
| 1601 | 1605 |
| 1602 BinaryOperation operation(ConstantSystem constantSystem) | 1606 BinaryOperation operation(ConstantSystem constantSystem) |
| 1603 => constantSystem.divide; | 1607 => constantSystem.divide; |
| 1604 int typeCode() => HInstruction.DIVIDE_TYPECODE; | 1608 int typeCode() => HInstruction.DIVIDE_TYPECODE; |
| 1605 bool typeEquals(other) => other is HDivide; | 1609 bool typeEquals(other) => other is HDivide; |
| 1606 bool dataEquals(HInstruction other) => true; | 1610 bool dataEquals(HInstruction other) => true; |
| 1607 } | 1611 } |
| 1608 | 1612 |
| 1609 class HMultiply extends HBinaryArithmetic { | 1613 class HMultiply extends HBinaryArithmetic { |
| 1610 HMultiply(HInstruction left, HInstruction right) : super(left, right); | 1614 HMultiply(left, right, selector) : super(left, right, selector); |
| 1611 accept(HVisitor visitor) => visitor.visitMultiply(this); | 1615 accept(HVisitor visitor) => visitor.visitMultiply(this); |
| 1612 | 1616 |
| 1613 BinaryOperation operation(ConstantSystem operations) | 1617 BinaryOperation operation(ConstantSystem operations) |
| 1614 => operations.multiply; | 1618 => operations.multiply; |
| 1615 int typeCode() => HInstruction.MULTIPLY_TYPECODE; | 1619 int typeCode() => HInstruction.MULTIPLY_TYPECODE; |
| 1616 bool typeEquals(other) => other is HMultiply; | 1620 bool typeEquals(other) => other is HMultiply; |
| 1617 bool dataEquals(HInstruction other) => true; | 1621 bool dataEquals(HInstruction other) => true; |
| 1618 } | 1622 } |
| 1619 | 1623 |
| 1620 class HSubtract extends HBinaryArithmetic { | 1624 class HSubtract extends HBinaryArithmetic { |
| 1621 HSubtract(HInstruction left, HInstruction right) : super(left, right); | 1625 HSubtract(left, right, selector) : super(left, right, selector); |
| 1622 accept(HVisitor visitor) => visitor.visitSubtract(this); | 1626 accept(HVisitor visitor) => visitor.visitSubtract(this); |
| 1623 | 1627 |
| 1624 BinaryOperation operation(ConstantSystem constantSystem) | 1628 BinaryOperation operation(ConstantSystem constantSystem) |
| 1625 => constantSystem.subtract; | 1629 => constantSystem.subtract; |
| 1626 int typeCode() => HInstruction.SUBTRACT_TYPECODE; | 1630 int typeCode() => HInstruction.SUBTRACT_TYPECODE; |
| 1627 bool typeEquals(other) => other is HSubtract; | 1631 bool typeEquals(other) => other is HSubtract; |
| 1628 bool dataEquals(HInstruction other) => true; | 1632 bool dataEquals(HInstruction other) => true; |
| 1629 } | 1633 } |
| 1630 | 1634 |
| 1631 /** | 1635 /** |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1645 * following join-block. | 1649 * following join-block. |
| 1646 */ | 1650 */ |
| 1647 HBasicBlock get defaultTarget => block.successors.last; | 1651 HBasicBlock get defaultTarget => block.successors.last; |
| 1648 | 1652 |
| 1649 accept(HVisitor visitor) => visitor.visitSwitch(this); | 1653 accept(HVisitor visitor) => visitor.visitSwitch(this); |
| 1650 | 1654 |
| 1651 String toString() => "HSwitch cases = $inputs"; | 1655 String toString() => "HSwitch cases = $inputs"; |
| 1652 } | 1656 } |
| 1653 | 1657 |
| 1654 abstract class HBinaryBitOp extends HInvokeBinary { | 1658 abstract class HBinaryBitOp extends HInvokeBinary { |
| 1655 HBinaryBitOp(HInstruction left, HInstruction right) : super(left, right) { | 1659 HBinaryBitOp(left, right, selector) : super(left, right, selector) { |
| 1656 instructionType = HType.INTEGER; | 1660 instructionType = HType.INTEGER; |
| 1657 } | 1661 } |
| 1658 } | 1662 } |
| 1659 | 1663 |
| 1660 class HShiftLeft extends HBinaryBitOp { | 1664 class HShiftLeft extends HBinaryBitOp { |
| 1661 HShiftLeft(HInstruction left, HInstruction right) : super(left, right); | 1665 HShiftLeft(left, right, selector) : super(left, right, selector); |
| 1662 accept(HVisitor visitor) => visitor.visitShiftLeft(this); | 1666 accept(HVisitor visitor) => visitor.visitShiftLeft(this); |
| 1663 | 1667 |
| 1664 BinaryOperation operation(ConstantSystem constantSystem) | 1668 BinaryOperation operation(ConstantSystem constantSystem) |
| 1665 => constantSystem.shiftLeft; | 1669 => constantSystem.shiftLeft; |
| 1666 int typeCode() => HInstruction.SHIFT_LEFT_TYPECODE; | 1670 int typeCode() => HInstruction.SHIFT_LEFT_TYPECODE; |
| 1667 bool typeEquals(other) => other is HShiftLeft; | 1671 bool typeEquals(other) => other is HShiftLeft; |
| 1668 bool dataEquals(HInstruction other) => true; | 1672 bool dataEquals(HInstruction other) => true; |
| 1669 } | 1673 } |
| 1670 | 1674 |
| 1671 class HBitOr extends HBinaryBitOp { | 1675 class HBitOr extends HBinaryBitOp { |
| 1672 HBitOr(HInstruction left, HInstruction right) : super(left, right); | 1676 HBitOr(left, right, selector) : super(left, right, selector); |
| 1673 accept(HVisitor visitor) => visitor.visitBitOr(this); | 1677 accept(HVisitor visitor) => visitor.visitBitOr(this); |
| 1674 | 1678 |
| 1675 BinaryOperation operation(ConstantSystem constantSystem) | 1679 BinaryOperation operation(ConstantSystem constantSystem) |
| 1676 => constantSystem.bitOr; | 1680 => constantSystem.bitOr; |
| 1677 int typeCode() => HInstruction.BIT_OR_TYPECODE; | 1681 int typeCode() => HInstruction.BIT_OR_TYPECODE; |
| 1678 bool typeEquals(other) => other is HBitOr; | 1682 bool typeEquals(other) => other is HBitOr; |
| 1679 bool dataEquals(HInstruction other) => true; | 1683 bool dataEquals(HInstruction other) => true; |
| 1680 } | 1684 } |
| 1681 | 1685 |
| 1682 class HBitAnd extends HBinaryBitOp { | 1686 class HBitAnd extends HBinaryBitOp { |
| 1683 HBitAnd(HInstruction left, HInstruction right) : super(left, right); | 1687 HBitAnd(left, right, selector) : super(left, right, selector); |
| 1684 accept(HVisitor visitor) => visitor.visitBitAnd(this); | 1688 accept(HVisitor visitor) => visitor.visitBitAnd(this); |
| 1685 | 1689 |
| 1686 BinaryOperation operation(ConstantSystem constantSystem) | 1690 BinaryOperation operation(ConstantSystem constantSystem) |
| 1687 => constantSystem.bitAnd; | 1691 => constantSystem.bitAnd; |
| 1688 int typeCode() => HInstruction.BIT_AND_TYPECODE; | 1692 int typeCode() => HInstruction.BIT_AND_TYPECODE; |
| 1689 bool typeEquals(other) => other is HBitAnd; | 1693 bool typeEquals(other) => other is HBitAnd; |
| 1690 bool dataEquals(HInstruction other) => true; | 1694 bool dataEquals(HInstruction other) => true; |
| 1691 } | 1695 } |
| 1692 | 1696 |
| 1693 class HBitXor extends HBinaryBitOp { | 1697 class HBitXor extends HBinaryBitOp { |
| 1694 HBitXor(HInstruction left, HInstruction right) : super(left, right); | 1698 HBitXor(left, right, selector) : super(left, right, selector); |
| 1695 accept(HVisitor visitor) => visitor.visitBitXor(this); | 1699 accept(HVisitor visitor) => visitor.visitBitXor(this); |
| 1696 | 1700 |
| 1697 BinaryOperation operation(ConstantSystem constantSystem) | 1701 BinaryOperation operation(ConstantSystem constantSystem) |
| 1698 => constantSystem.bitXor; | 1702 => constantSystem.bitXor; |
| 1699 int typeCode() => HInstruction.BIT_XOR_TYPECODE; | 1703 int typeCode() => HInstruction.BIT_XOR_TYPECODE; |
| 1700 bool typeEquals(other) => other is HBitXor; | 1704 bool typeEquals(other) => other is HBitXor; |
| 1701 bool dataEquals(HInstruction other) => true; | 1705 bool dataEquals(HInstruction other) => true; |
| 1702 } | 1706 } |
| 1703 | 1707 |
| 1704 abstract class HInvokeUnary extends HInstruction { | 1708 abstract class HInvokeUnary extends HInstruction { |
| 1705 HInvokeUnary(HInstruction input) : super(<HInstruction>[input]) { | 1709 final Selector selector; |
| 1710 HInvokeUnary(HInstruction input, this.selector) | |
| 1711 : super(<HInstruction>[input]) { | |
| 1706 clearAllSideEffects(); | 1712 clearAllSideEffects(); |
| 1707 setUseGvn(); | 1713 setUseGvn(); |
| 1708 } | 1714 } |
| 1709 | 1715 |
| 1710 HInstruction get operand => inputs[0]; | 1716 HInstruction get operand => inputs[0]; |
| 1711 | 1717 |
| 1712 UnaryOperation operation(ConstantSystem constantSystem); | 1718 UnaryOperation operation(ConstantSystem constantSystem); |
| 1713 } | 1719 } |
| 1714 | 1720 |
| 1715 class HNegate extends HInvokeUnary { | 1721 class HNegate extends HInvokeUnary { |
| 1716 HNegate(HInstruction input) : super(input); | 1722 HNegate(input, selector) : super(input, selector); |
| 1717 accept(HVisitor visitor) => visitor.visitNegate(this); | 1723 accept(HVisitor visitor) => visitor.visitNegate(this); |
| 1718 | 1724 |
| 1719 UnaryOperation operation(ConstantSystem constantSystem) | 1725 UnaryOperation operation(ConstantSystem constantSystem) |
| 1720 => constantSystem.negate; | 1726 => constantSystem.negate; |
| 1721 int typeCode() => HInstruction.NEGATE_TYPECODE; | 1727 int typeCode() => HInstruction.NEGATE_TYPECODE; |
| 1722 bool typeEquals(other) => other is HNegate; | 1728 bool typeEquals(other) => other is HNegate; |
| 1723 bool dataEquals(HInstruction other) => true; | 1729 bool dataEquals(HInstruction other) => true; |
| 1724 } | 1730 } |
| 1725 | 1731 |
| 1726 class HBitNot extends HInvokeUnary { | 1732 class HBitNot extends HInvokeUnary { |
| 1727 HBitNot(HInstruction input) : super(input) { | 1733 HBitNot(input, selector) : super(input, selector) { |
| 1728 instructionType = HType.INTEGER; | 1734 instructionType = HType.INTEGER; |
| 1729 } | 1735 } |
| 1730 accept(HVisitor visitor) => visitor.visitBitNot(this); | 1736 accept(HVisitor visitor) => visitor.visitBitNot(this); |
| 1731 | 1737 |
| 1732 UnaryOperation operation(ConstantSystem constantSystem) | 1738 UnaryOperation operation(ConstantSystem constantSystem) |
| 1733 => constantSystem.bitNot; | 1739 => constantSystem.bitNot; |
| 1734 int typeCode() => HInstruction.BIT_NOT_TYPECODE; | 1740 int typeCode() => HInstruction.BIT_NOT_TYPECODE; |
| 1735 bool typeEquals(other) => other is HBitNot; | 1741 bool typeEquals(other) => other is HBitNot; |
| 1736 bool dataEquals(HInstruction other) => true; | 1742 bool dataEquals(HInstruction other) => true; |
| 1737 } | 1743 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1951 assert(logicalOperatorType == IS_OR); | 1957 assert(logicalOperatorType == IS_OR); |
| 1952 return "||"; | 1958 return "||"; |
| 1953 } | 1959 } |
| 1954 | 1960 |
| 1955 toString() => 'phi'; | 1961 toString() => 'phi'; |
| 1956 accept(HVisitor visitor) => visitor.visitPhi(this); | 1962 accept(HVisitor visitor) => visitor.visitPhi(this); |
| 1957 } | 1963 } |
| 1958 | 1964 |
| 1959 abstract class HRelational extends HInvokeBinary { | 1965 abstract class HRelational extends HInvokeBinary { |
| 1960 bool usesBoolifiedInterceptor = false; | 1966 bool usesBoolifiedInterceptor = false; |
| 1961 HRelational(HInstruction left, HInstruction right) : super(left, right) { | 1967 HRelational(left, right, selector) : super(left, right, selector) { |
| 1962 instructionType = HType.BOOLEAN; | 1968 instructionType = HType.BOOLEAN; |
| 1963 } | 1969 } |
| 1964 } | 1970 } |
| 1965 | 1971 |
| 1966 class HIdentity extends HRelational { | 1972 class HIdentity extends HRelational { |
| 1967 HIdentity(HInstruction left, HInstruction right) : super(left, right); | 1973 HIdentity(left, right, [selector]) : super(left, right, selector); |
| 1968 accept(HVisitor visitor) => visitor.visitIdentity(this); | 1974 accept(HVisitor visitor) => visitor.visitIdentity(this); |
| 1969 | 1975 |
| 1970 BinaryOperation operation(ConstantSystem constantSystem) | 1976 BinaryOperation operation(ConstantSystem constantSystem) |
| 1971 => constantSystem.identity; | 1977 => constantSystem.identity; |
| 1972 int typeCode() => HInstruction.IDENTITY_TYPECODE; | 1978 int typeCode() => HInstruction.IDENTITY_TYPECODE; |
| 1973 bool typeEquals(other) => other is HIdentity; | 1979 bool typeEquals(other) => other is HIdentity; |
| 1974 bool dataEquals(HInstruction other) => true; | 1980 bool dataEquals(HInstruction other) => true; |
| 1975 } | 1981 } |
| 1976 | 1982 |
| 1977 class HGreater extends HRelational { | 1983 class HGreater extends HRelational { |
| 1978 HGreater(HInstruction left, HInstruction right) : super(left, right); | 1984 HGreater(left, right, selector) : super(left, right, selector); |
| 1979 accept(HVisitor visitor) => visitor.visitGreater(this); | 1985 accept(HVisitor visitor) => visitor.visitGreater(this); |
| 1980 | 1986 |
| 1981 BinaryOperation operation(ConstantSystem constantSystem) | 1987 BinaryOperation operation(ConstantSystem constantSystem) |
| 1982 => constantSystem.greater; | 1988 => constantSystem.greater; |
| 1983 int typeCode() => HInstruction.GREATER_TYPECODE; | 1989 int typeCode() => HInstruction.GREATER_TYPECODE; |
| 1984 bool typeEquals(other) => other is HGreater; | 1990 bool typeEquals(other) => other is HGreater; |
| 1985 bool dataEquals(HInstruction other) => true; | 1991 bool dataEquals(HInstruction other) => true; |
| 1986 } | 1992 } |
| 1987 | 1993 |
| 1988 class HGreaterEqual extends HRelational { | 1994 class HGreaterEqual extends HRelational { |
| 1989 HGreaterEqual(HInstruction left, HInstruction right) : super(left, right); | 1995 HGreaterEqual(left, right, selector) : super(left, right, selector); |
| 1990 accept(HVisitor visitor) => visitor.visitGreaterEqual(this); | 1996 accept(HVisitor visitor) => visitor.visitGreaterEqual(this); |
| 1991 | 1997 |
| 1992 BinaryOperation operation(ConstantSystem constantSystem) | 1998 BinaryOperation operation(ConstantSystem constantSystem) |
| 1993 => constantSystem.greaterEqual; | 1999 => constantSystem.greaterEqual; |
| 1994 int typeCode() => HInstruction.GREATER_EQUAL_TYPECODE; | 2000 int typeCode() => HInstruction.GREATER_EQUAL_TYPECODE; |
| 1995 bool typeEquals(other) => other is HGreaterEqual; | 2001 bool typeEquals(other) => other is HGreaterEqual; |
| 1996 bool dataEquals(HInstruction other) => true; | 2002 bool dataEquals(HInstruction other) => true; |
| 1997 } | 2003 } |
| 1998 | 2004 |
| 1999 class HLess extends HRelational { | 2005 class HLess extends HRelational { |
| 2000 HLess(HInstruction left, HInstruction right) : super(left, right); | 2006 HLess(left, right, selector) : super(left, right, selector); |
| 2001 accept(HVisitor visitor) => visitor.visitLess(this); | 2007 accept(HVisitor visitor) => visitor.visitLess(this); |
| 2002 | 2008 |
| 2003 BinaryOperation operation(ConstantSystem constantSystem) | 2009 BinaryOperation operation(ConstantSystem constantSystem) |
| 2004 => constantSystem.less; | 2010 => constantSystem.less; |
| 2005 int typeCode() => HInstruction.LESS_TYPECODE; | 2011 int typeCode() => HInstruction.LESS_TYPECODE; |
| 2006 bool typeEquals(other) => other is HLess; | 2012 bool typeEquals(other) => other is HLess; |
| 2007 bool dataEquals(HInstruction other) => true; | 2013 bool dataEquals(HInstruction other) => true; |
| 2008 } | 2014 } |
| 2009 | 2015 |
| 2010 class HLessEqual extends HRelational { | 2016 class HLessEqual extends HRelational { |
| 2011 HLessEqual(HInstruction left, HInstruction right) : super(left, right); | 2017 HLessEqual(left, right, selector) : super(left, right, selector); |
| 2012 accept(HVisitor visitor) => visitor.visitLessEqual(this); | 2018 accept(HVisitor visitor) => visitor.visitLessEqual(this); |
| 2013 | 2019 |
| 2014 BinaryOperation operation(ConstantSystem constantSystem) | 2020 BinaryOperation operation(ConstantSystem constantSystem) |
| 2015 => constantSystem.lessEqual; | 2021 => constantSystem.lessEqual; |
| 2016 int typeCode() => HInstruction.LESS_EQUAL_TYPECODE; | 2022 int typeCode() => HInstruction.LESS_EQUAL_TYPECODE; |
| 2017 bool typeEquals(other) => other is HLessEqual; | 2023 bool typeEquals(other) => other is HLessEqual; |
| 2018 bool dataEquals(HInstruction other) => true; | 2024 bool dataEquals(HInstruction other) => true; |
| 2019 } | 2025 } |
| 2020 | 2026 |
| 2021 class HReturn extends HControlFlow { | 2027 class HReturn extends HControlFlow { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2145 } | 2151 } |
| 2146 toString() => 'literal list'; | 2152 toString() => 'literal list'; |
| 2147 accept(HVisitor visitor) => visitor.visitLiteralList(this); | 2153 accept(HVisitor visitor) => visitor.visitLiteralList(this); |
| 2148 } | 2154 } |
| 2149 | 2155 |
| 2150 /** | 2156 /** |
| 2151 * The primitive array indexing operation. Note that this instruction | 2157 * The primitive array indexing operation. Note that this instruction |
| 2152 * does not throw because we generate the checks explicitly. | 2158 * does not throw because we generate the checks explicitly. |
| 2153 */ | 2159 */ |
| 2154 class HIndex extends HInstruction { | 2160 class HIndex extends HInstruction { |
| 2155 HIndex(HInstruction receiver, HInstruction index) | 2161 final Selector selector; |
| 2162 HIndex(HInstruction receiver, HInstruction index, this.selector) | |
| 2156 : super(<HInstruction>[receiver, index]) { | 2163 : super(<HInstruction>[receiver, index]) { |
| 2157 clearAllSideEffects(); | 2164 clearAllSideEffects(); |
| 2158 setDependsOnIndexStore(); | 2165 setDependsOnIndexStore(); |
| 2159 setUseGvn(); | 2166 setUseGvn(); |
| 2160 } | 2167 } |
| 2161 | 2168 |
| 2162 String toString() => 'index operator'; | 2169 String toString() => 'index operator'; |
| 2163 accept(HVisitor visitor) => visitor.visitIndex(this); | 2170 accept(HVisitor visitor) => visitor.visitIndex(this); |
| 2164 | 2171 |
| 2165 HInstruction get receiver => inputs[0]; | 2172 HInstruction get receiver => inputs[0]; |
| 2166 HInstruction get index => inputs[1]; | 2173 HInstruction get index => inputs[1]; |
| 2167 | 2174 |
| 2168 int typeCode() => HInstruction.INDEX_TYPECODE; | 2175 int typeCode() => HInstruction.INDEX_TYPECODE; |
| 2169 bool typeEquals(HInstruction other) => other is HIndex; | 2176 bool typeEquals(HInstruction other) => other is HIndex; |
| 2170 bool dataEquals(HIndex other) => true; | 2177 bool dataEquals(HIndex other) => true; |
| 2171 } | 2178 } |
| 2172 | 2179 |
| 2173 /** | 2180 /** |
| 2174 * The primitive array assignment operation. Note that this instruction | 2181 * The primitive array assignment operation. Note that this instruction |
| 2175 * does not throw because we generate the checks explicitly. | 2182 * does not throw because we generate the checks explicitly. |
| 2176 */ | 2183 */ |
| 2177 class HIndexAssign extends HInstruction { | 2184 class HIndexAssign extends HInstruction { |
| 2185 final Selector selector; | |
| 2178 HIndexAssign(HInstruction receiver, | 2186 HIndexAssign(HInstruction receiver, |
| 2179 HInstruction index, | 2187 HInstruction index, |
| 2180 HInstruction value) | 2188 HInstruction value, |
| 2189 this.selector) | |
| 2181 : super(<HInstruction>[receiver, index, value]) { | 2190 : super(<HInstruction>[receiver, index, value]) { |
| 2182 clearAllSideEffects(); | 2191 clearAllSideEffects(); |
| 2183 setChangesIndex(); | 2192 setChangesIndex(); |
| 2184 } | 2193 } |
| 2185 String toString() => 'index assign operator'; | 2194 String toString() => 'index assign operator'; |
| 2186 accept(HVisitor visitor) => visitor.visitIndexAssign(this); | 2195 accept(HVisitor visitor) => visitor.visitIndexAssign(this); |
| 2187 | 2196 |
| 2188 HInstruction get receiver => inputs[0]; | 2197 HInstruction get receiver => inputs[0]; |
| 2189 HInstruction get index => inputs[1]; | 2198 HInstruction get index => inputs[1]; |
| 2190 HInstruction get value => inputs[2]; | 2199 HInstruction get value => inputs[2]; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2232 bool dataEquals(HIs other) { | 2241 bool dataEquals(HIs other) { |
| 2233 return typeExpression == other.typeExpression | 2242 return typeExpression == other.typeExpression |
| 2234 && nullOk == other.nullOk | 2243 && nullOk == other.nullOk |
| 2235 && kind == other.kind; | 2244 && kind == other.kind; |
| 2236 } | 2245 } |
| 2237 } | 2246 } |
| 2238 | 2247 |
| 2239 class HTypeConversion extends HCheck { | 2248 class HTypeConversion extends HCheck { |
| 2240 final DartType typeExpression; | 2249 final DartType typeExpression; |
| 2241 final int kind; | 2250 final int kind; |
| 2251 final Selector receiverTypeCheckSelector; | |
| 2242 | 2252 |
| 2243 static const int NO_CHECK = 0; | 2253 static const int NO_CHECK = 0; |
| 2244 static const int CHECKED_MODE_CHECK = 1; | 2254 static const int CHECKED_MODE_CHECK = 1; |
| 2245 static const int ARGUMENT_TYPE_CHECK = 2; | 2255 static const int ARGUMENT_TYPE_CHECK = 2; |
| 2246 static const int CAST_TYPE_CHECK = 3; | 2256 static const int CAST_TYPE_CHECK = 3; |
| 2247 static const int BOOLEAN_CONVERSION_CHECK = 4; | 2257 static const int BOOLEAN_CONVERSION_CHECK = 4; |
| 2258 static const int RECEIVER_TYPE_CHECK = 5; | |
| 2248 | 2259 |
| 2249 HTypeConversion(this.typeExpression, this.kind, | 2260 HTypeConversion(this.typeExpression, this.kind, |
| 2250 HType type, HInstruction input) | 2261 HType type, HInstruction input, |
| 2262 [this.receiverTypeCheckSelector]) | |
| 2251 : super(<HInstruction>[input]) { | 2263 : super(<HInstruction>[input]) { |
| 2264 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); | |
| 2252 sourceElement = input.sourceElement; | 2265 sourceElement = input.sourceElement; |
| 2253 instructionType = type; | 2266 instructionType = type; |
| 2254 } | 2267 } |
| 2255 | 2268 |
| 2256 bool get isChecked => kind != NO_CHECK; | 2269 bool get isChecked => kind != NO_CHECK; |
| 2257 bool get isCheckedModeCheck { | 2270 bool get isCheckedModeCheck { |
| 2258 return kind == CHECKED_MODE_CHECK | 2271 return kind == CHECKED_MODE_CHECK |
| 2259 || kind == BOOLEAN_CONVERSION_CHECK; | 2272 || kind == BOOLEAN_CONVERSION_CHECK; |
| 2260 } | 2273 } |
| 2261 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; | 2274 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; |
| 2275 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK; | |
| 2262 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; | 2276 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; |
| 2263 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK; | 2277 bool get isBooleanConversionCheck => kind == BOOLEAN_CONVERSION_CHECK; |
| 2264 | 2278 |
| 2265 accept(HVisitor visitor) => visitor.visitTypeConversion(this); | 2279 accept(HVisitor visitor) => visitor.visitTypeConversion(this); |
| 2266 | 2280 |
| 2267 bool isJsStatement() => kind == ARGUMENT_TYPE_CHECK; | 2281 bool isJsStatement() => isControlFlow(); |
| 2268 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; | 2282 bool isControlFlow() => isArgumentTypeCheck || isReceiverTypeCheck; |
| 2269 bool canThrow() => isChecked; | 2283 bool canThrow() => isChecked; |
| 2270 | 2284 |
| 2271 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE; | 2285 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE; |
| 2272 bool typeEquals(HInstruction other) => other is HTypeConversion; | 2286 bool typeEquals(HInstruction other) => other is HTypeConversion; |
| 2273 | 2287 |
| 2274 bool dataEquals(HTypeConversion other) { | 2288 bool dataEquals(HTypeConversion other) { |
| 2275 return kind == other.kind | 2289 return kind == other.kind |
| 2276 && typeExpression == other.typeExpression | 2290 && typeExpression == other.typeExpression |
| 2277 && instructionType == other.instructionType; | 2291 && instructionType == other.instructionType; |
| 2278 } | 2292 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2651 HBasicBlock get start => expression.start; | 2665 HBasicBlock get start => expression.start; |
| 2652 HBasicBlock get end { | 2666 HBasicBlock get end { |
| 2653 // We don't create a switch block if there are no cases. | 2667 // We don't create a switch block if there are no cases. |
| 2654 assert(!statements.isEmpty); | 2668 assert(!statements.isEmpty); |
| 2655 return statements.last.end; | 2669 return statements.last.end; |
| 2656 } | 2670 } |
| 2657 | 2671 |
| 2658 bool accept(HStatementInformationVisitor visitor) => | 2672 bool accept(HStatementInformationVisitor visitor) => |
| 2659 visitor.visitSwitchInfo(this); | 2673 visitor.visitSwitchInfo(this); |
| 2660 } | 2674 } |
| OLD | NEW |