| 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 /** | 5 /** |
| 6 * The [LiveRange] class covers a range where an instruction is live. | 6 * The [LiveRange] class covers a range where an instruction is live. |
| 7 */ | 7 */ |
| 8 class LiveRange { | 8 class LiveRange { |
| 9 final int start; | 9 final int start; |
| 10 // [end] is not final because it can be updated due to loops. | 10 // [end] is not final because it can be updated due to loops. |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Update all instructions that are liveIns in [header] to have a | 277 // Update all instructions that are liveIns in [header] to have a |
| 278 // range that covers the loop. | 278 // range that covers the loop. |
| 279 env.liveInstructions.forEach((HInstruction instruction, int id) { | 279 env.liveInstructions.forEach((HInstruction instruction, int id) { |
| 280 LiveInterval range = env.liveIntervals.putIfAbsent( | 280 LiveInterval range = env.liveIntervals.putIfAbsent( |
| 281 instruction, () => new LiveInterval()); | 281 instruction, () => new LiveInterval()); |
| 282 range.loopUpdate(env.startId, lastId); | 282 range.loopUpdate(env.startId, lastId); |
| 283 env.liveInstructions[instruction] = lastId; | 283 env.liveInstructions[instruction] = lastId; |
| 284 }); | 284 }); |
| 285 | 285 |
| 286 env.removeLoopMarker(header); | 286 env.removeLoopMarker(header); |
| 287 | 287 |
| 288 // Update all liveIns set to contain the liveIns of [header]. | 288 // Update all liveIns set to contain the liveIns of [header]. |
| 289 liveInstructions.forEach((HBasicBlock block, LiveEnvironment other) { | 289 liveInstructions.forEach((HBasicBlock block, LiveEnvironment other) { |
| 290 if (other.loopMarkers.containsKey(header)) { | 290 if (other.loopMarkers.containsKey(header)) { |
| 291 env.liveInstructions.forEach((HInstruction instruction, int id) { | 291 env.liveInstructions.forEach((HInstruction instruction, int id) { |
| 292 other.liveInstructions[instruction] = id; | 292 other.liveInstructions[instruction] = id; |
| 293 }); | 293 }); |
| 294 other.removeLoopMarker(header); | 294 other.removeLoopMarker(header); |
| 295 env.loopMarkers.forEach((k, v) { other.loopMarkers[k] = v; }); | 295 env.loopMarkers.forEach((k, v) { other.loopMarkers[k] = v; }); |
| 296 } | 296 } |
| 297 }); | 297 }); |
| 298 } | 298 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 if (generateAtUseSite.contains(instruction)) return false; | 549 if (generateAtUseSite.contains(instruction)) return false; |
| 550 // A [HCheck] instruction that has control flow needs a name only if its | 550 // A [HCheck] instruction that has control flow needs a name only if its |
| 551 // checked input needs a name (e.g. a check [HConstant] does not | 551 // checked input needs a name (e.g. a check [HConstant] does not |
| 552 // need a name). | 552 // need a name). |
| 553 if (instruction is HCheck && instruction.isControlFlow()) { | 553 if (instruction is HCheck && instruction.isControlFlow()) { |
| 554 HCheck check = instruction; | 554 HCheck check = instruction; |
| 555 return needsName(instruction.checkedInput); | 555 return needsName(instruction.checkedInput); |
| 556 } | 556 } |
| 557 return true; | 557 return true; |
| 558 } | 558 } |
| 559 | 559 |
| 560 /** | 560 /** |
| 561 * Returns whether [instruction] dies at the instruction [at]. | 561 * Returns whether [instruction] dies at the instruction [at]. |
| 562 */ | 562 */ |
| 563 bool diesAt(HInstruction instruction, HInstruction at) { | 563 bool diesAt(HInstruction instruction, HInstruction at) { |
| 564 LiveInterval atInterval = liveIntervals[at]; | 564 LiveInterval atInterval = liveIntervals[at]; |
| 565 LiveInterval instructionInterval = liveIntervals[instruction]; | 565 LiveInterval instructionInterval = liveIntervals[instruction]; |
| 566 int start = atInterval.start; | 566 int start = atInterval.start; |
| 567 return instructionInterval.diesAt(start); | 567 return instructionInterval.diesAt(start); |
| 568 } | 568 } |
| 569 | 569 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 591 if (!needsName(input)) { | 591 if (!needsName(input)) { |
| 592 names.addAssignment(predecessor, input, phi); | 592 names.addAssignment(predecessor, input, phi); |
| 593 } else { | 593 } else { |
| 594 names.addCopy(predecessor, input, phi); | 594 names.addCopy(predecessor, input, phi); |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 | 597 |
| 598 namer.allocateName(phi); | 598 namer.allocateName(phi); |
| 599 } | 599 } |
| 600 } | 600 } |
| OLD | NEW |