| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 HType speculativeType) { | 105 HType speculativeType) { |
| 106 // If the type itself is not valuable, do not generate a guard for it. | 106 // If the type itself is not valuable, do not generate a guard for it. |
| 107 if (!typeValuable(speculativeType)) return false; | 107 if (!typeValuable(speculativeType)) return false; |
| 108 | 108 |
| 109 // Do not insert a type guard if the instruction has a type | 109 // Do not insert a type guard if the instruction has a type |
| 110 // annotation that disagrees with the speculated type. | 110 // annotation that disagrees with the speculated type. |
| 111 Element source = instruction.sourceElement; | 111 Element source = instruction.sourceElement; |
| 112 if (source != null) { | 112 if (source != null) { |
| 113 DartType sourceType = source.computeType(compiler); | 113 DartType sourceType = source.computeType(compiler); |
| 114 DartType speculatedType = speculativeType.computeType(compiler); | 114 DartType speculatedType = speculativeType.computeType(compiler); |
| 115 if (speculatedType != null && | 115 JavaScriptBackend backend = compiler.backend; |
| 116 !compiler.types.isAssignable(speculatedType, sourceType)) { | 116 if (speculatedType != null) { |
| 117 return false; | 117 // Use the num type instead of JSNumber because JSNumber |
| 118 // is not assignment compatible with int and double, but we |
| 119 // still want to generate a type guard. |
| 120 if (speculatedType.element == backend.jsNumberClass) { |
| 121 speculatedType = compiler.numClass.computeType(compiler); |
| 122 } |
| 123 if (!compiler.types.isAssignable(speculatedType, sourceType)) { |
| 124 return false; |
| 125 } |
| 118 } | 126 } |
| 119 } | 127 } |
| 120 | 128 |
| 121 // Insert type guards for recursive methods. | 129 // Insert type guards for recursive methods. |
| 122 if (isRecursiveMethod) return true; | 130 if (isRecursiveMethod) return true; |
| 123 | 131 |
| 124 // Insert type guards if there are uses in loops. | 132 // Insert type guards if there are uses in loops. |
| 125 bool isNested(HBasicBlock inner, HBasicBlock outer) { | 133 bool isNested(HBasicBlock inner, HBasicBlock outer) { |
| 126 if (identical(inner, outer)) return false; | 134 if (identical(inner, outer)) return false; |
| 127 if (outer == null) return true; | 135 if (outer == null) return true; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 hasComplexBailoutTargets = true; | 621 hasComplexBailoutTargets = true; |
| 614 } | 622 } |
| 615 } else { | 623 } else { |
| 616 hasComplexBailoutTargets = true; | 624 hasComplexBailoutTargets = true; |
| 617 blocks.forEach((HBasicBlock block) { | 625 blocks.forEach((HBasicBlock block) { |
| 618 block.bailoutTargets.add(target); | 626 block.bailoutTargets.add(target); |
| 619 }); | 627 }); |
| 620 } | 628 } |
| 621 } | 629 } |
| 622 } | 630 } |
| OLD | NEW |