| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void visitControlFlow(HControlFlow instruction) { | 215 void visitControlFlow(HControlFlow instruction) { |
| 216 compiler.internalError('Control flow instructions already dealt with.', | 216 compiler.internalError('Control flow instructions already dealt with.', |
| 217 instruction: instruction); | 217 instruction: instruction); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * Visits the graph and replaces guards with guards that capture the | 222 * Visits the graph and replaces guards with guards that capture the |
| 223 * environment. | 223 * environment. |
| 224 */ | 224 */ |
| 225 class SsaTypeGuardBuilder extends SsaEnvironmentBuilder { | 225 class SsaTypeGuardBuilder extends SsaEnvironmentBuilder implements OptimizationP
hase { |
| 226 |
| 227 final String name = 'SsaTypeGuardBuilder'; |
| 226 | 228 |
| 227 SsaTypeGuardBuilder(Compiler compiler) : super(compiler); | 229 SsaTypeGuardBuilder(Compiler compiler) : super(compiler); |
| 228 | 230 |
| 229 void tryInsertTypeGuard(HInstruction instruction, | 231 void tryInsertTypeGuard(HInstruction instruction, |
| 230 HInstruction insertionPoint) { | 232 HInstruction insertionPoint) { |
| 231 // If we found a type for the instruction, but the instruction | 233 // If we found a type for the instruction, but the instruction |
| 232 // does not know if it produces that type, add a type guard. | 234 // does not know if it produces that type, add a type guard. |
| 233 if (instruction.type.isKnown() && !instruction.hasExpectedType()) { | 235 if (instruction.type.isKnown() && !instruction.hasExpectedType()) { |
| 234 // The type guard expects the guarded instruction to be at the | 236 // The type guard expects the guarded instruction to be at the |
| 235 // end of the inputs. | 237 // end of the inputs. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 253 void visitPhi(HPhi phi) { | 255 void visitPhi(HPhi phi) { |
| 254 tryInsertTypeGuard(phi, phi.block.first); | 256 tryInsertTypeGuard(phi, phi.block.first); |
| 255 super.visitPhi(phi); | 257 super.visitPhi(phi); |
| 256 } | 258 } |
| 257 } | 259 } |
| 258 | 260 |
| 259 /* | 261 /* |
| 260 * Visits the graph and inserts [HBailoutTarget] instructions where | 262 * Visits the graph and inserts [HBailoutTarget] instructions where |
| 261 * the optimized version had [HTypeGuard] instructions. | 263 * the optimized version had [HTypeGuard] instructions. |
| 262 */ | 264 */ |
| 263 class SsaBailoutBuilder extends SsaEnvironmentBuilder { | 265 class SsaBailoutBuilder extends SsaEnvironmentBuilder implements OptimizationPha
se { |
| 264 final Map<int, BailoutInfo> bailouts; | 266 final Map<int, BailoutInfo> bailouts; |
| 267 final String name = 'SsaBailoutBuilder'; |
| 265 | 268 |
| 266 SsaBailoutBuilder(Compiler compiler, this.bailouts) : super(compiler); | 269 SsaBailoutBuilder(Compiler compiler, this.bailouts) : super(compiler); |
| 267 | 270 |
| 268 void checkBailout(HInstruction instruction, HInstruction insertionPoint) { | 271 void checkBailout(HInstruction instruction, HInstruction insertionPoint) { |
| 269 BailoutInfo info = bailouts[instruction.id]; | 272 BailoutInfo info = bailouts[instruction.id]; |
| 270 if (info != null) { | 273 if (info != null) { |
| 271 List<HInstruction> inputs = environment.buildAndSetLast(instruction); | 274 List<HInstruction> inputs = environment.buildAndSetLast(instruction); |
| 272 HBailoutTarget bailout = new HBailoutTarget(info.bailoutId, inputs); | 275 HBailoutTarget bailout = new HBailoutTarget(info.bailoutId, inputs); |
| 273 instruction.block.addBefore(insertionPoint, bailout); | 276 instruction.block.addBefore(insertionPoint, bailout); |
| 274 } | 277 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 compiler.internalError('Control flow instructions already dealt with.', | 352 compiler.internalError('Control flow instructions already dealt with.', |
| 350 instruction: instruction); | 353 instruction: instruction); |
| 351 } | 354 } |
| 352 | 355 |
| 353 visitBailoutTarget(HBailoutTarget target) { | 356 visitBailoutTarget(HBailoutTarget target) { |
| 354 blocks.forEach((HBasicBlock block) { | 357 blocks.forEach((HBasicBlock block) { |
| 355 block.bailouts.add(target); | 358 block.bailouts.add(target); |
| 356 }); | 359 }); |
| 357 } | 360 } |
| 358 } | 361 } |
| OLD | NEW |