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 import '../closure.dart'; | 5 import '../closure.dart'; |
6 import '../common.dart'; | 6 import '../common.dart'; |
7 import '../common_elements.dart' show CommonElements; | 7 import '../common_elements.dart' show CommonElements; |
8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 assert( | 1410 assert( |
1411 identical(oldInstruction, _source), | 1411 identical(oldInstruction, _source), |
1412 'Input ${index} of ${user} changed.' | 1412 'Input ${index} of ${user} changed.' |
1413 '\n Found: ${oldInstruction}\n Expected: ${_source}'); | 1413 '\n Found: ${oldInstruction}\n Expected: ${_source}'); |
1414 user.inputs[index] = newInstruction; | 1414 user.inputs[index] = newInstruction; |
1415 oldInstruction.usedBy.remove(user); | 1415 oldInstruction.usedBy.remove(user); |
1416 newInstruction.usedBy.add(user); | 1416 newInstruction.usedBy.add(user); |
1417 } | 1417 } |
1418 } | 1418 } |
1419 | 1419 |
| 1420 bool get isSingleton => _instructions.length == 1; |
| 1421 |
| 1422 HInstruction get single => _instructions.single; |
| 1423 |
1420 void _addUse(HInstruction user, int inputIndex) { | 1424 void _addUse(HInstruction user, int inputIndex) { |
1421 _instructions.add(user); | 1425 _instructions.add(user); |
1422 _indexes.add(inputIndex); | 1426 _indexes.add(inputIndex); |
1423 } | 1427 } |
1424 | 1428 |
1425 void _compute(HInstruction source, HInstruction dominator, | 1429 void _compute(HInstruction source, HInstruction dominator, |
1426 bool excludeDominator, bool excludePhiOutEdges) { | 1430 bool excludeDominator, bool excludePhiOutEdges) { |
1427 // Keep track of all instructions that we have to deal with later and count | 1431 // Keep track of all instructions that we have to deal with later and count |
1428 // the number of them that are in the current block. | 1432 // the number of them that are in the current block. |
1429 Set<HInstruction> users = new Setlet<HInstruction>(); | 1433 Set<HInstruction> users = new Setlet<HInstruction>(); |
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3039 return kind == other.kind && | 3043 return kind == other.kind && |
3040 typeExpression == other.typeExpression && | 3044 typeExpression == other.typeExpression && |
3041 checkedType == other.checkedType && | 3045 checkedType == other.checkedType && |
3042 receiverTypeCheckSelector == other.receiverTypeCheckSelector; | 3046 receiverTypeCheckSelector == other.receiverTypeCheckSelector; |
3043 } | 3047 } |
3044 } | 3048 } |
3045 | 3049 |
3046 /// The [HTypeKnown] instruction marks a value with a refined type. | 3050 /// The [HTypeKnown] instruction marks a value with a refined type. |
3047 class HTypeKnown extends HCheck { | 3051 class HTypeKnown extends HCheck { |
3048 TypeMask knownType; | 3052 TypeMask knownType; |
3049 bool _isMovable; | 3053 final bool _isMovable; |
3050 | 3054 |
3051 HTypeKnown.pinned(TypeMask knownType, HInstruction input) | 3055 HTypeKnown.pinned(TypeMask knownType, HInstruction input) |
3052 : this.knownType = knownType, | 3056 : this.knownType = knownType, |
3053 this._isMovable = false, | 3057 this._isMovable = false, |
3054 super(<HInstruction>[input], knownType); | 3058 super(<HInstruction>[input], knownType); |
3055 | 3059 |
3056 HTypeKnown.witnessed( | 3060 HTypeKnown.witnessed( |
3057 TypeMask knownType, HInstruction input, HInstruction witness) | 3061 TypeMask knownType, HInstruction input, HInstruction witness) |
3058 : this.knownType = knownType, | 3062 : this.knownType = knownType, |
3059 this._isMovable = true, | 3063 this._isMovable = true, |
3060 super(<HInstruction>[input, witness], knownType); | 3064 super(<HInstruction>[input, witness], knownType); |
3061 | 3065 |
3062 toString() => 'TypeKnown $knownType'; | 3066 toString() => 'TypeKnown $knownType'; |
3063 accept(HVisitor visitor) => visitor.visitTypeKnown(this); | 3067 accept(HVisitor visitor) => visitor.visitTypeKnown(this); |
3064 | 3068 |
3065 bool isJsStatement() => false; | 3069 bool isJsStatement() => false; |
3066 bool isControlFlow() => false; | 3070 bool isControlFlow() => false; |
3067 bool canThrow() => false; | 3071 bool canThrow() => false; |
3068 | 3072 |
| 3073 bool get isPinned => inputs.length == 1; |
| 3074 |
3069 HInstruction get witness => inputs.length == 2 ? inputs[1] : null; | 3075 HInstruction get witness => inputs.length == 2 ? inputs[1] : null; |
3070 | 3076 |
3071 int typeCode() => HInstruction.TYPE_KNOWN_TYPECODE; | 3077 int typeCode() => HInstruction.TYPE_KNOWN_TYPECODE; |
3072 bool typeEquals(HInstruction other) => other is HTypeKnown; | 3078 bool typeEquals(HInstruction other) => other is HTypeKnown; |
3073 bool isCodeMotionInvariant() => true; | 3079 bool isCodeMotionInvariant() => true; |
3074 bool get isMovable => _isMovable && useGvn(); | 3080 bool get isMovable => _isMovable && useGvn(); |
3075 | 3081 |
3076 bool dataEquals(HTypeKnown other) { | 3082 bool dataEquals(HTypeKnown other) { |
3077 return knownType == other.knownType && | 3083 return knownType == other.knownType && |
3078 instructionType == other.instructionType; | 3084 instructionType == other.instructionType; |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3522 // ignore: MISSING_RETURN | 3528 // ignore: MISSING_RETURN |
3523 String get kindAsString { | 3529 String get kindAsString { |
3524 switch (kind) { | 3530 switch (kind) { |
3525 case TypeInfoExpressionKind.COMPLETE: | 3531 case TypeInfoExpressionKind.COMPLETE: |
3526 return 'COMPLETE'; | 3532 return 'COMPLETE'; |
3527 case TypeInfoExpressionKind.INSTANCE: | 3533 case TypeInfoExpressionKind.INSTANCE: |
3528 return 'INSTANCE'; | 3534 return 'INSTANCE'; |
3529 } | 3535 } |
3530 } | 3536 } |
3531 } | 3537 } |
OLD | NEW |