Chromium Code Reviews| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 // Update all instructions that are liveIns in [header] to have a | 278 // Update all instructions that are liveIns in [header] to have a |
| 279 // range that covers the loop. | 279 // range that covers the loop. |
| 280 env.liveInstructions.forEach((HInstruction instruction, int id) { | 280 env.liveInstructions.forEach((HInstruction instruction, int id) { |
| 281 LiveInterval range = env.liveIntervals.putIfAbsent( | 281 LiveInterval range = env.liveIntervals.putIfAbsent( |
| 282 instruction, () => new LiveInterval()); | 282 instruction, () => new LiveInterval()); |
| 283 range.loopUpdate(env.startId, lastId); | 283 range.loopUpdate(env.startId, lastId); |
| 284 env.liveInstructions[instruction] = lastId; | 284 env.liveInstructions[instruction] = lastId; |
| 285 }); | 285 }); |
| 286 | 286 |
| 287 env.removeLoopMarker(header); | 287 env.removeLoopMarker(header); |
| 288 | 288 |
| 289 // Update all liveIns set to contain the liveIns of [header]. | 289 // Update all liveIns set to contain the liveIns of [header]. |
| 290 liveInstructions.forEach((HBasicBlock block, LiveEnvironment other) { | 290 liveInstructions.forEach((HBasicBlock block, LiveEnvironment other) { |
| 291 if (other.loopMarkers.containsKey(header)) { | 291 if (other.loopMarkers.containsKey(header)) { |
| 292 env.liveInstructions.forEach((HInstruction instruction, int id) { | 292 env.liveInstructions.forEach((HInstruction instruction, int id) { |
| 293 other.liveInstructions[instruction] = id; | 293 other.liveInstructions[instruction] = id; |
| 294 }); | 294 }); |
| 295 other.removeLoopMarker(header); | 295 other.removeLoopMarker(header); |
| 296 env.loopMarkers.forEach((k, v) { other.loopMarkers[k] = v; }); | 296 env.loopMarkers.forEach((k, v) { other.loopMarkers[k] = v; }); |
| 297 } | 297 } |
| 298 }); | 298 }); |
| 299 } | 299 } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 handleInstruction(instruction, namer); | 556 handleInstruction(instruction, namer); |
| 557 }); | 557 }); |
| 558 } | 558 } |
| 559 | 559 |
| 560 /** | 560 /** |
| 561 * Returns whether [instruction] needs a name. Instructions that | 561 * Returns whether [instruction] needs a name. Instructions that |
| 562 * have no users or that are generated at use site does not need a name. | 562 * have no users or that are generated at use site does not need a name. |
| 563 */ | 563 */ |
| 564 bool needsName(HInstruction instruction) { | 564 bool needsName(HInstruction instruction) { |
| 565 if (instruction.usedBy.isEmpty()) return false; | 565 if (instruction.usedBy.isEmpty()) return false; |
| 566 // TODO(ngeoffray): parameters are being generated at use site, | 566 // TODO(ngeoffray): locals/parameters are being generated at use site, |
| 567 // but we need a name for parameters. We should probably not make | 567 // but we need a name for parameters. We should probably not make |
|
kasperl
2012/06/19 11:19:45
parameters -> them
floitsch
2012/06/19 11:31:33
Done.
| |
| 568 // them generate at use site to make things simpler. | 568 // them generate at use site to make things simpler. |
| 569 if (instruction is HParameterValue && instruction is !HThis) return true; | 569 if (instruction is HLocalValue && instruction is !HThis) return true; |
| 570 if (generateAtUseSite.contains(instruction)) return false; | 570 if (generateAtUseSite.contains(instruction)) return false; |
| 571 // A [HCheck] instruction that has control flow needs a name only if its | 571 // A [HCheck] instruction that has control flow needs a name only if its |
| 572 // checked input needs a name (e.g. a check [HConstant] does not | 572 // checked input needs a name (e.g. a check [HConstant] does not |
| 573 // need a name). | 573 // need a name). |
| 574 if (instruction is HCheck && instruction.isControlFlow()) { | 574 if (instruction is HCheck && instruction.isControlFlow()) { |
| 575 HCheck check = instruction; | 575 HCheck check = instruction; |
| 576 return needsName(instruction.checkedInput); | 576 return needsName(instruction.checkedInput); |
| 577 } | 577 } |
| 578 return true; | 578 return true; |
| 579 } | 579 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 if (!needsName(input)) { | 612 if (!needsName(input)) { |
| 613 names.addAssignment(predecessor, input, phi); | 613 names.addAssignment(predecessor, input, phi); |
| 614 } else { | 614 } else { |
| 615 names.addCopy(predecessor, input, phi); | 615 names.addCopy(predecessor, input, phi); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 | 618 |
| 619 namer.allocateName(phi); | 619 namer.allocateName(phi); |
| 620 } | 620 } |
| 621 } | 621 } |
| OLD | NEW |