| 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 class BailoutInfo { | 7 class BailoutInfo { |
| 8 int instructionId; | 8 int instructionId; |
| 9 int bailoutId; | 9 int bailoutId; |
| 10 BailoutInfo(this.instructionId, this.bailoutId); | 10 BailoutInfo(this.instructionId, this.bailoutId); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // speculated types. | 103 // speculated types. |
| 104 work.guards.forEach((HTypeGuard guard) { guard.disable(); }); | 104 work.guards.forEach((HTypeGuard guard) { guard.disable(); }); |
| 105 | 105 |
| 106 propagator = new SsaNonSpeculativeTypePropagator(compiler); | 106 propagator = new SsaNonSpeculativeTypePropagator(compiler); |
| 107 propagator.visitGraph(graph); | 107 propagator.visitGraph(graph); |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Primitive types that are not null are valuable. These include | 110 // Primitive types that are not null are valuable. These include |
| 111 // indexable arrays. | 111 // indexable arrays. |
| 112 bool typeValuable(HType type) { | 112 bool typeValuable(HType type) { |
| 113 return type.isPrimitive() && !type.isNull(); | 113 return type.isPrimitive(compiler) && !type.isNull(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool get hasTypeGuards => work.guards.length != 0; | 116 bool get hasTypeGuards => work.guards.length != 0; |
| 117 | 117 |
| 118 bool isUsedWithIncompatibleSelector(HInstruction instruction, | 118 bool isUsedWithIncompatibleSelector(HInstruction instruction, |
| 119 HType speculativeType) { | 119 HType speculativeType) { |
| 120 for (HInstruction user in instruction.usedBy) { | 120 for (HInstruction user in instruction.usedBy) { |
| 121 if (user is HCheck | 121 if (user is HCheck |
| 122 && isUsedWithIncompatibleSelector(user, speculativeType)) { | 122 && isUsedWithIncompatibleSelector(user, speculativeType)) { |
| 123 return true; | 123 return true; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Insert type guards if the method is likely to be called in a | 212 // Insert type guards if the method is likely to be called in a |
| 213 // loop. | 213 // loop. |
| 214 return calledInLoop; | 214 return calledInLoop; |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Returns whether an invocation of [selector] on [receiver] will throw a | 217 // Returns whether an invocation of [selector] on [receiver] will throw a |
| 218 // [ArgumentError] if the argument is not of the right type. | 218 // [ArgumentError] if the argument is not of the right type. |
| 219 bool willThrowArgumentError(Selector selector, | 219 bool willThrowArgumentError(Selector selector, |
| 220 HInstruction receiver, | 220 HInstruction receiver, |
| 221 HType speculativeType) { | 221 HType speculativeType) { |
| 222 if (receiver != null && (receiver.isInteger() || receiver.isString())) { | 222 if (receiver != null |
| 223 && (receiver.isInteger() || receiver.isString(compiler))) { |
| 223 return selector.isOperator() | 224 return selector.isOperator() |
| 224 && selector.name != const SourceString('==') | 225 && selector.name != const SourceString('==') |
| 225 && (speculativeType.isNumber() && !speculativeType.isInteger()); | 226 && (speculativeType.isNumber() && !speculativeType.isInteger()); |
| 226 } | 227 } |
| 227 return false; | 228 return false; |
| 228 } | 229 } |
| 229 | 230 |
| 230 // Returns whether an invocation of [selector] will throw a | 231 // Returns whether an invocation of [selector] will throw a |
| 231 // [NoSuchMethodError] if the receiver is not of the type | 232 // [NoSuchMethodError] if the receiver is not of the type |
| 232 // [speculativeType]. | 233 // [speculativeType]. |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 hasComplexBailoutTargets = true; | 744 hasComplexBailoutTargets = true; |
| 744 } | 745 } |
| 745 } else { | 746 } else { |
| 746 hasComplexBailoutTargets = true; | 747 hasComplexBailoutTargets = true; |
| 747 blocks.forEach((HBasicBlock block) { | 748 blocks.forEach((HBasicBlock block) { |
| 748 block.bailoutTargets.add(target); | 749 block.bailoutTargets.add(target); |
| 749 }); | 750 }); |
| 750 } | 751 } |
| 751 } | 752 } |
| 752 } | 753 } |
| OLD | NEW |