| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 visitBitAnd(HBitAnd node); | 7 R visitBitAnd(HBitAnd node); |
| 8 R visitBitNot(HBitNot node); | 8 R visitBitNot(HBitNot node); |
| 9 R visitBitOr(HBitOr node); | 9 R visitBitOr(HBitOr node); |
| 10 R visitBitXor(HBitXor node); | 10 R visitBitXor(HBitXor node); |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 return candidateType; | 835 return candidateType; |
| 836 } | 836 } |
| 837 | 837 |
| 838 HType computeDesiredInputType(HInstruction input) => HType.UNKNOWN; | 838 HType computeDesiredInputType(HInstruction input) => HType.UNKNOWN; |
| 839 | 839 |
| 840 // Returns whether the instruction does produce the type it claims. | 840 // Returns whether the instruction does produce the type it claims. |
| 841 // For most instructions, this returns false. A type guard will be | 841 // For most instructions, this returns false. A type guard will be |
| 842 // inserted to make sure the users get the right type in. | 842 // inserted to make sure the users get the right type in. |
| 843 bool hasExpectedType() => false; | 843 bool hasExpectedType() => false; |
| 844 | 844 |
| 845 // Re-compute and update the type of the instruction. Returns | |
| 846 // whether or not the type was changed. | |
| 847 bool updateType() { | |
| 848 if (type.isConflicting()) return false; | |
| 849 HType newType = computeType(); | |
| 850 HType desiredType = computeDesiredType(); | |
| 851 HType combined = newType.combine(desiredType); | |
| 852 if (combined.isKnown()) newType = combined; | |
| 853 | |
| 854 bool changed = (type != newType); | |
| 855 if (type.isUnknown()) { | |
| 856 type = newType; | |
| 857 return changed; | |
| 858 } else if (changed) { | |
| 859 type = type.combine(newType); | |
| 860 return changed; | |
| 861 } | |
| 862 return false; | |
| 863 } | |
| 864 | |
| 865 bool isInBasicBlock() => block !== null; | 845 bool isInBasicBlock() => block !== null; |
| 866 | 846 |
| 867 String inputsToString() { | 847 String inputsToString() { |
| 868 void addAsCommaSeparated(StringBuffer buffer, List<HInstruction> list) { | 848 void addAsCommaSeparated(StringBuffer buffer, List<HInstruction> list) { |
| 869 for (int i = 0; i < list.length; i++) { | 849 for (int i = 0; i < list.length; i++) { |
| 870 if (i != 0) buffer.add(', '); | 850 if (i != 0) buffer.add(', '); |
| 871 buffer.add("@${list[i].id}"); | 851 buffer.add("@${list[i].id}"); |
| 872 } | 852 } |
| 873 } | 853 } |
| 874 | 854 |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 return type; | 1773 return type; |
| 1794 } | 1774 } |
| 1795 | 1775 |
| 1796 bool hasExpectedType() { | 1776 bool hasExpectedType() { |
| 1797 for (int i = 0; i < inputs.length; i++) { | 1777 for (int i = 0; i < inputs.length; i++) { |
| 1798 if (type.combine(inputs[i].type).isConflicting()) return false; | 1778 if (type.combine(inputs[i].type).isConflicting()) return false; |
| 1799 } | 1779 } |
| 1800 return true; | 1780 return true; |
| 1801 } | 1781 } |
| 1802 | 1782 |
| 1803 void setInitialTypeForLoopPhi() { | |
| 1804 assert(block.isLoopHeader()); | |
| 1805 assert(type.isUnknown()); | |
| 1806 type = inputs[0].type; | |
| 1807 } | |
| 1808 | |
| 1809 bool isLogicalOperator() => logicalOperatorType != IS_NOT_LOGICAL_OPERATOR; | 1783 bool isLogicalOperator() => logicalOperatorType != IS_NOT_LOGICAL_OPERATOR; |
| 1810 | 1784 |
| 1811 String logicalOperator() { | 1785 String logicalOperator() { |
| 1812 assert(isLogicalOperator()); | 1786 assert(isLogicalOperator()); |
| 1813 if (logicalOperatorType == IS_AND) return "&&"; | 1787 if (logicalOperatorType == IS_AND) return "&&"; |
| 1814 assert(logicalOperatorType == IS_OR); | 1788 assert(logicalOperatorType == IS_OR); |
| 1815 return "||"; | 1789 return "||"; |
| 1816 } | 1790 } |
| 1817 | 1791 |
| 1818 toString() => 'phi'; | 1792 toString() => 'phi'; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 class HIfBlockInformation { | 2048 class HIfBlockInformation { |
| 2075 final HIf branch; | 2049 final HIf branch; |
| 2076 final SubGraph thenGraph; | 2050 final SubGraph thenGraph; |
| 2077 final SubGraph elseGraph; | 2051 final SubGraph elseGraph; |
| 2078 final HBasicBlock joinBlock; | 2052 final HBasicBlock joinBlock; |
| 2079 HIfBlockInformation(this.branch, | 2053 HIfBlockInformation(this.branch, |
| 2080 this.thenGraph, | 2054 this.thenGraph, |
| 2081 this.elseGraph, | 2055 this.elseGraph, |
| 2082 this.joinBlock); | 2056 this.joinBlock); |
| 2083 } | 2057 } |
| OLD | NEW |