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