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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 environment.clear(); | 269 environment.clear(); |
270 visitInstruction(instruction); | 270 visitInstruction(instruction); |
271 } | 271 } |
272 | 272 |
273 void visitControlFlow(HControlFlow instruction) { | 273 void visitControlFlow(HControlFlow instruction) { |
274 compiler.internalError('Control flow instructions already dealt with.', | 274 compiler.internalError('Control flow instructions already dealt with.', |
275 instruction: instruction); | 275 instruction: instruction); |
276 } | 276 } |
277 | 277 |
278 bool shouldCaptureEnvironment(HInstruction instruction) { | 278 bool shouldCaptureEnvironment(HInstruction instruction) { |
279 return instruction.type.isKnown() && !instruction.hasExpectedType(); | 279 HType propagatedType = instruction.propagatedType; |
| 280 return propagatedType.isUseful() |
| 281 && propagatedType != instruction.computeTypeFromInputTypes(); |
280 } | 282 } |
281 | 283 |
282 void insertCapturedEnvironments() { | 284 void insertCapturedEnvironments() { |
283 work.guards = <HTypeGuard>[]; | 285 work.guards = <HTypeGuard>[]; |
284 int state = 1; | 286 int state = 1; |
285 capturedEnvironments.forEach((HInstruction instruction, Environment env) { | 287 capturedEnvironments.forEach((HInstruction instruction, Environment env) { |
286 List<HInstruction> inputs = env.buildAndSetLast(instruction); | 288 List<HInstruction> inputs = env.buildAndSetLast(instruction); |
287 HTypeGuard guard = new HTypeGuard(state++, inputs); | 289 HTypeGuard guard = new HTypeGuard(state++, inputs); |
288 work.guards.add(guard); | 290 work.guards.add(guard); |
289 instruction.block.rewrite(instruction, guard); | 291 instruction.block.rewrite(instruction, guard); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 compiler.internalError('Control flow instructions already dealt with.', | 361 compiler.internalError('Control flow instructions already dealt with.', |
360 instruction: instruction); | 362 instruction: instruction); |
361 } | 363 } |
362 | 364 |
363 visitTypeGuard(HTypeGuard guard) { | 365 visitTypeGuard(HTypeGuard guard) { |
364 blocks.forEach((HBasicBlock block) { | 366 blocks.forEach((HBasicBlock block) { |
365 block.guards.add(guard); | 367 block.guards.add(guard); |
366 }); | 368 }); |
367 } | 369 } |
368 } | 370 } |
OLD | NEW |