| 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 |
| 11 /** | 11 /** |
| 12 * Keeps track of the execution environment for instructions. An | 12 * Keeps track of the execution environment for instructions. An |
| 13 * execution environment contains the SSA instructions that are live. | 13 * execution environment contains the SSA instructions that are live. |
| 14 */ | 14 */ |
| 15 class Environment { | 15 class Environment { |
| 16 final Set<HInstruction> lives; | 16 final Set<HInstruction> lives; |
| 17 final Set<HBasicBlock> loopMarkers; | 17 final Set<HBasicBlock> loopMarkers; |
| 18 Environment() : lives = new Set<HInstruction>(), | 18 Environment() : lives = new Set<HInstruction>(), |
| 19 loopMarkers = new Set<HBasicBlock>(); | 19 loopMarkers = new Set<HBasicBlock>(); |
| 20 Environment.from(Environment other) | 20 Environment.from(Environment other) |
| 21 : lives = new Set<HInstruction>.from(other.lives), | 21 : lives = new Set<HInstruction>.from(other.lives), |
| 22 loopMarkers = new Set<HBasicBlock>.from(other.loopMarkers); | 22 loopMarkers = new Set<HBasicBlock>.from(other.loopMarkers); |
| 23 | 23 |
| 24 void remove(HInstruction instruction) { | 24 void remove(HInstruction instruction) { |
| 25 lives.remove(instruction); | 25 lives.remove(instruction); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void add(HInstruction instruction) { | 28 void add(HInstruction instruction) { |
| 29 // If the instruction is a type guard, we add its checked input | 29 // If the instruction is a check, we add its checked input |
| 30 // instead. This allows sharing the same environment between | 30 // instead. This allows sharing the same environment between |
| 31 // different type guards. | 31 // different type guards. |
| 32 // | 32 // |
| 33 // Also, we don't need to add code motion invariant instructions | 33 // Also, we don't need to add code motion invariant instructions |
| 34 // in the live set (because we generate them at use-site), except | 34 // in the live set (because we generate them at use-site), except |
| 35 // for parameters that are not 'this', which is always passed as | 35 // for parameters that are not 'this', which is always passed as |
| 36 // the receiver. | 36 // the receiver. |
| 37 if (instruction is HTypeGuard) { | 37 if (instruction is HCheck) { |
| 38 add(instruction.checkedInput); | 38 add(instruction.checkedInput); |
| 39 } else if (!instruction.isCodeMotionInvariant() | 39 } else if (!instruction.isCodeMotionInvariant() |
| 40 || (instruction is HParameterValue && instruction is !HThis)) { | 40 || (instruction is HParameterValue && instruction is !HThis)) { |
| 41 lives.add(instruction); | 41 lives.add(instruction); |
| 42 } else { | 42 } else { |
| 43 for (int i = 0, len = instruction.inputs.length; i < len; i++) { | 43 for (int i = 0, len = instruction.inputs.length; i < len; i++) { |
| 44 add(instruction.inputs[i]); | 44 add(instruction.inputs[i]); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 } | 47 } |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 hasComplexBailoutTargets = true; | 537 hasComplexBailoutTargets = true; |
| 538 } | 538 } |
| 539 } else { | 539 } else { |
| 540 hasComplexBailoutTargets = true; | 540 hasComplexBailoutTargets = true; |
| 541 blocks.forEach((HBasicBlock block) { | 541 blocks.forEach((HBasicBlock block) { |
| 542 block.bailoutTargets.add(target); | 542 block.bailoutTargets.add(target); |
| 543 }); | 543 }); |
| 544 } | 544 } |
| 545 } | 545 } |
| 546 } | 546 } |
| OLD | NEW |