| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 // Insert type guards if the method is likely to be called in a | 211 // Insert type guards if the method is likely to be called in a |
| 212 // loop. | 212 // loop. |
| 213 return calledInLoop; | 213 return calledInLoop; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Returns whether an invocation of [selector] on [receiver] will throw a | 216 // Returns whether an invocation of [selector] on [receiver] will throw a |
| 217 // [ArgumentError] if the argument is not of the right type. | 217 // [ArgumentError] if the argument is not of the right type. |
| 218 bool willThrowArgumentError(Selector selector, HInstruction receiver) { | 218 bool willThrowArgumentError(Selector selector, |
| 219 HInstruction receiver, |
| 220 HType speculativeType) { |
| 219 if (receiver != null && (receiver.isInteger() || receiver.isString())) { | 221 if (receiver != null && (receiver.isInteger() || receiver.isString())) { |
| 220 return selector.isOperator() && selector.name != const SourceString('=='); | 222 return selector.isOperator() |
| 223 && selector.name != const SourceString('==') |
| 224 && (speculativeType.isNumber() && !speculativeType.isInteger()); |
| 221 } | 225 } |
| 222 return false; | 226 return false; |
| 223 } | 227 } |
| 224 | 228 |
| 225 // Returns whether an invocation of [selector] will throw a | 229 // Returns whether an invocation of [selector] will throw a |
| 226 // [NoSuchMethodError] if the receiver is not of the type | 230 // [NoSuchMethodError] if the receiver is not of the type |
| 227 // [speculativeType]. | 231 // [speculativeType]. |
| 228 bool willThrowNoSuchMethodErrorIfNot(Selector selector, | 232 bool willThrowNoSuchMethodErrorIfNot(Selector selector, |
| 229 HType speculativeType) { | 233 HType speculativeType) { |
| 230 return compiler.world.hasSingleMatch(selector) | 234 return compiler.world.hasSingleMatch(selector) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // will throw [NoSuchMethodError] or [ArgumentError]. | 287 // will throw [NoSuchMethodError] or [ArgumentError]. |
| 284 Selector selector = firstUser.selector; | 288 Selector selector = firstUser.selector; |
| 285 Selector receiverSelectorOnThrow = null; | 289 Selector receiverSelectorOnThrow = null; |
| 286 HInstruction receiver = firstUser.getDartReceiver(compiler); | 290 HInstruction receiver = firstUser.getDartReceiver(compiler); |
| 287 bool willThrow = false; | 291 bool willThrow = false; |
| 288 if (receiver == instruction) { | 292 if (receiver == instruction) { |
| 289 if (willThrowNoSuchMethodErrorIfNot(selector, speculativeType)) { | 293 if (willThrowNoSuchMethodErrorIfNot(selector, speculativeType)) { |
| 290 receiverSelectorOnThrow = selector; | 294 receiverSelectorOnThrow = selector; |
| 291 willThrow = true; | 295 willThrow = true; |
| 292 } | 296 } |
| 293 } else if (willThrowArgumentError(selector, receiver)) { | 297 } else if (willThrowArgumentError(selector, receiver, speculativeType)) { |
| 294 willThrow = true; | 298 willThrow = true; |
| 295 } | 299 } |
| 296 | 300 |
| 297 if (!willThrow) return false; | 301 if (!willThrow) return false; |
| 298 | 302 |
| 299 HTypeConversion check = new HTypeConversion( | 303 HTypeConversion check = new HTypeConversion( |
| 300 null, | 304 null, |
| 301 receiverSelectorOnThrow == null | 305 receiverSelectorOnThrow == null |
| 302 ? HTypeConversion.ARGUMENT_TYPE_CHECK | 306 ? HTypeConversion.ARGUMENT_TYPE_CHECK |
| 303 : HTypeConversion.RECEIVER_TYPE_CHECK, | 307 : HTypeConversion.RECEIVER_TYPE_CHECK, |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 hasComplexBailoutTargets = true; | 736 hasComplexBailoutTargets = true; |
| 733 } | 737 } |
| 734 } else { | 738 } else { |
| 735 hasComplexBailoutTargets = true; | 739 hasComplexBailoutTargets = true; |
| 736 blocks.forEach((HBasicBlock block) { | 740 blocks.forEach((HBasicBlock block) { |
| 737 block.bailoutTargets.add(target); | 741 block.bailoutTargets.add(target); |
| 738 }); | 742 }); |
| 739 } | 743 } |
| 740 } | 744 } |
| 741 } | 745 } |
| OLD | NEW |