| 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 class BailoutInfo { | 5 class BailoutInfo { |
| 6 int instructionId; | 6 int instructionId; |
| 7 int bailoutId; | 7 int bailoutId; |
| 8 BailoutInfo(this.instructionId, this.bailoutId); | 8 BailoutInfo(this.instructionId, this.bailoutId); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // generation of a bailout method. | 155 // generation of a bailout method. |
| 156 if (instruction is HIndex && | 156 if (instruction is HIndex && |
| 157 (instruction as HIndex).isBuiltin(types) && | 157 (instruction as HIndex).isBuiltin(types) && |
| 158 hasTypeGuards) { | 158 hasTypeGuards) { |
| 159 HBasicBlock loopHeader = instruction.block.enclosingLoopHeader; | 159 HBasicBlock loopHeader = instruction.block.enclosingLoopHeader; |
| 160 if (loopHeader != null && loopHeader.parentLoopHeader != null) { | 160 if (loopHeader != null && loopHeader.parentLoopHeader != null) { |
| 161 return true; | 161 return true; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 // If the instruction is used by a phi where a guard would be |
| 166 // valuable, put the guard on that instruction. |
| 167 for (HInstruction user in instruction.usedBy) { |
| 168 if (user is HPhi |
| 169 && user.block.id > instruction.id |
| 170 && typeGuardWouldBeValuable(user, speculativeType)) { |
| 171 return true; |
| 172 } |
| 173 } |
| 174 |
| 165 // Insert type guards if the method is likely to be called in a | 175 // Insert type guards if the method is likely to be called in a |
| 166 // loop. | 176 // loop. |
| 167 return calledInLoop; | 177 return calledInLoop; |
| 168 } | 178 } |
| 169 | 179 |
| 170 bool shouldInsertTypeGuard(HInstruction instruction, | 180 bool shouldInsertTypeGuard(HInstruction instruction, |
| 171 HType speculativeType, | 181 HType speculativeType, |
| 172 HType computedType) { | 182 HType computedType) { |
| 173 if (!speculativeType.isUseful()) return false; | 183 if (!speculativeType.isUseful()) return false; |
| 174 // If the types agree we don't need to check. | 184 // If the types agree we don't need to check. |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 hasComplexBailoutTargets = true; | 537 hasComplexBailoutTargets = true; |
| 528 } | 538 } |
| 529 } else { | 539 } else { |
| 530 hasComplexBailoutTargets = true; | 540 hasComplexBailoutTargets = true; |
| 531 blocks.forEach((HBasicBlock block) { | 541 blocks.forEach((HBasicBlock block) { |
| 532 block.bailoutTargets.add(target); | 542 block.bailoutTargets.add(target); |
| 533 }); | 543 }); |
| 534 } | 544 } |
| 535 } | 545 } |
| 536 } | 546 } |
| OLD | NEW |