| 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 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 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 SubtractOperation get operation() => const SubtractOperation(); | 1483 SubtractOperation get operation() => const SubtractOperation(); |
| 1484 int typeCode() => 9; | 1484 int typeCode() => 9; |
| 1485 bool typeEquals(other) => other is HSubtract; | 1485 bool typeEquals(other) => other is HSubtract; |
| 1486 bool dataEquals(HInstruction other) => true; | 1486 bool dataEquals(HInstruction other) => true; |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 /** | 1489 /** |
| 1490 * An [HSwitch] instruction has one input for the incoming | 1490 * An [HSwitch] instruction has one input for the incoming |
| 1491 * value, and one input per constant that it can switch on. | 1491 * value, and one input per constant that it can switch on. |
| 1492 * Its block has one successor per constant, and one for the default. | 1492 * Its block has one successor per constant, and one for the default. |
| 1493 * If the switch didn't have a default case, the last successor is | |
| 1494 * the join block. | |
| 1495 */ | 1493 */ |
| 1496 class HSwitch extends HControlFlow { | 1494 class HSwitch extends HControlFlow { |
| 1497 HSwitch(List<HInstruction> inputs) : super(inputs); | 1495 HSwitch(List<HInstruction> inputs) : super(inputs); |
| 1498 | 1496 |
| 1499 HConstant constant(int index) => inputs[index + 1]; | 1497 HConstant constant(int index) => inputs[index + 1]; |
| 1500 HInstruction get expression() => inputs[0]; | 1498 HInstruction get expression() => inputs[0]; |
| 1501 | 1499 |
| 1500 /** |
| 1501 * Provides the target to jump to if none of the constants match |
| 1502 * the expression. If the switch had no default case, this is the |
| 1503 * following join-block. |
| 1504 */ |
| 1502 HBasicBlock get defaultTarget() => block.successors.last(); | 1505 HBasicBlock get defaultTarget() => block.successors.last(); |
| 1503 | 1506 |
| 1504 accept(HVisitor visitor) => visitor.visitSwitch(this); | 1507 accept(HVisitor visitor) => visitor.visitSwitch(this); |
| 1505 | 1508 |
| 1506 String toString() => "HSwitch cases = $inputs"; | 1509 String toString() => "HSwitch cases = $inputs"; |
| 1507 } | 1510 } |
| 1508 | 1511 |
| 1509 class HTruncatingDivide extends HBinaryArithmetic { | 1512 class HTruncatingDivide extends HBinaryArithmetic { |
| 1510 HTruncatingDivide(HStatic target, HInstruction left, HInstruction right) | 1513 HTruncatingDivide(HStatic target, HInstruction left, HInstruction right) |
| 1511 : super(target, left, right); | 1514 : super(target, left, right); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 bool typeEquals(other) => other is HNot; | 1828 bool typeEquals(other) => other is HNot; |
| 1826 bool dataEquals(HInstruction other) => true; | 1829 bool dataEquals(HInstruction other) => true; |
| 1827 } | 1830 } |
| 1828 | 1831 |
| 1829 /** | 1832 /** |
| 1830 * An [HLocalValue] represents a local. Unlike [HParameterValue]s its | 1833 * An [HLocalValue] represents a local. Unlike [HParameterValue]s its |
| 1831 * first use must be in an HLocalSet. That is, [HParameterValue]s have a | 1834 * first use must be in an HLocalSet. That is, [HParameterValue]s have a |
| 1832 * value from the start, whereas [HLocalValue]s need to be initialized first. | 1835 * value from the start, whereas [HLocalValue]s need to be initialized first. |
| 1833 */ | 1836 */ |
| 1834 class HLocalValue extends HInstruction { | 1837 class HLocalValue extends HInstruction { |
| 1835 HLocalValue(element) : super(<HInstruction>[]) { | 1838 HLocalValue(Element element) : super(<HInstruction>[]) { |
| 1836 sourceElement = element; | 1839 sourceElement = element; |
| 1837 } | 1840 } |
| 1838 | 1841 |
| 1839 void prepareGvn() { | 1842 void prepareGvn() { |
| 1840 assert(!hasSideEffects()); | 1843 assert(!hasSideEffects()); |
| 1841 } | 1844 } |
| 1842 toString() => 'local ${sourceElement.name}'; | 1845 toString() => 'local ${sourceElement.name}'; |
| 1843 accept(HVisitor visitor) => visitor.visitLocalValue(this); | 1846 accept(HVisitor visitor) => visitor.visitLocalValue(this); |
| 1844 bool isCodeMotionInvariant() => true; | 1847 bool isCodeMotionInvariant() => true; |
| 1845 } | 1848 } |
| 1846 | 1849 |
| 1847 class HParameterValue extends HLocalValue { | 1850 class HParameterValue extends HLocalValue { |
| 1848 HParameterValue(element) : super(element); | 1851 HParameterValue(Element element) : super(element); |
| 1849 | 1852 |
| 1850 toString() => 'parameter ${sourceElement.name}'; | 1853 toString() => 'parameter ${sourceElement.name}'; |
| 1851 accept(HVisitor visitor) => visitor.visitParameterValue(this); | 1854 accept(HVisitor visitor) => visitor.visitParameterValue(this); |
| 1852 } | 1855 } |
| 1853 | 1856 |
| 1854 class HThis extends HParameterValue { | 1857 class HThis extends HParameterValue { |
| 1855 HThis([HType type = HType.UNKNOWN]) : super(null) { | 1858 HThis([HType type = HType.UNKNOWN]) : super(null) { |
| 1856 guaranteedType = type; | 1859 guaranteedType = type; |
| 1857 } | 1860 } |
| 1858 toString() => 'this'; | 1861 toString() => 'this'; |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 toString() => "$expression is $typeExpression"; | 2250 toString() => "$expression is $typeExpression"; |
| 2248 } | 2251 } |
| 2249 | 2252 |
| 2250 class HTypeConversion extends HCheck { | 2253 class HTypeConversion extends HCheck { |
| 2251 HType type; | 2254 HType type; |
| 2252 final int kind; | 2255 final int kind; |
| 2253 | 2256 |
| 2254 static final int NO_CHECK = 0; | 2257 static final int NO_CHECK = 0; |
| 2255 static final int CHECKED_MODE_CHECK = 1; | 2258 static final int CHECKED_MODE_CHECK = 1; |
| 2256 static final int ARGUMENT_TYPE_CHECK = 2; | 2259 static final int ARGUMENT_TYPE_CHECK = 2; |
| 2260 static final int CAST_TYPE_CHECK = 3; |
| 2257 | 2261 |
| 2258 HTypeConversion(HType type, HInstruction input) | 2262 HTypeConversion(this.type, HInstruction input, [this.kind = NO_CHECK]) |
| 2259 : this.internal(type, input, NO_CHECK); | |
| 2260 HTypeConversion.checkedModeCheck(HType type, HInstruction input) | |
| 2261 : this.internal(type, input, CHECKED_MODE_CHECK); | |
| 2262 HTypeConversion.argumentTypeCheck(HType type, HInstruction input) | |
| 2263 : this.internal(type, input, ARGUMENT_TYPE_CHECK); | |
| 2264 | |
| 2265 HTypeConversion.internal(this.type, HInstruction input, this.kind) | |
| 2266 : super(<HInstruction>[input]) { | 2263 : super(<HInstruction>[input]) { |
| 2267 sourceElement = input.sourceElement; | 2264 sourceElement = input.sourceElement; |
| 2268 } | 2265 } |
| 2266 HTypeConversion.checkedModeCheck(HType type, HInstruction input) |
| 2267 : this(type, input, CHECKED_MODE_CHECK); |
| 2268 HTypeConversion.argumentTypeCheck(HType type, HInstruction input) |
| 2269 : this(type, input, ARGUMENT_TYPE_CHECK); |
| 2270 HTypeConversion.castCheck(HType type, HInstruction input) |
| 2271 : this(type, intpu, CAST_TYPE_CHECK); |
| 2269 | 2272 |
| 2270 bool isChecked() => kind != NO_CHECK; | 2273 |
| 2271 bool isCheckedModeCheck() => kind == CHECKED_MODE_CHECK; | 2274 bool get isChecked() => kind != NO_CHECK; |
| 2272 bool isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK; | 2275 bool get isCheckedModeCheck() => kind == CHECKED_MODE_CHECK; |
| 2276 bool get isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK; |
| 2277 bool get isCastTypeCheck() => kind == CAST_TYPE_CHECK; |
| 2273 | 2278 |
| 2274 HType get guaranteedType() => type; | 2279 HType get guaranteedType() => type; |
| 2275 | 2280 |
| 2276 accept(HVisitor visitor) => visitor.visitTypeConversion(this); | 2281 accept(HVisitor visitor) => visitor.visitTypeConversion(this); |
| 2277 | 2282 |
| 2278 bool isStatement() => kind == ARGUMENT_TYPE_CHECK; | 2283 bool isStatement() => kind == ARGUMENT_TYPE_CHECK; |
| 2279 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; | 2284 bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK; |
| 2280 | 2285 |
| 2281 int typeCode() => 28; | 2286 int typeCode() => 28; |
| 2282 bool typeEquals(HInstruction other) => other is HTypeConversion; | 2287 bool typeEquals(HInstruction other) => other is HTypeConversion; |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2619 HBasicBlock get start() => expression.start; | 2624 HBasicBlock get start() => expression.start; |
| 2620 HBasicBlock get end() { | 2625 HBasicBlock get end() { |
| 2621 // We don't create a switch block if there are no cases. | 2626 // We don't create a switch block if there are no cases. |
| 2622 assert(!statements.isEmpty()); | 2627 assert(!statements.isEmpty()); |
| 2623 return statements.last().end; | 2628 return statements.last().end; |
| 2624 } | 2629 } |
| 2625 | 2630 |
| 2626 bool accept(HStatementInformationVisitor visitor) => | 2631 bool accept(HStatementInformationVisitor visitor) => |
| 2627 visitor.visitSwitchInfo(this); | 2632 visitor.visitSwitchInfo(this); |
| 2628 } | 2633 } |
| OLD | NEW |