| 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 11 matching lines...) Expand all Loading... |
| 22 */ | 22 */ |
| 23 class LiveInterval { | 23 class LiveInterval { |
| 24 /** | 24 /** |
| 25 * The id where there instruction is defined. | 25 * The id where there instruction is defined. |
| 26 */ | 26 */ |
| 27 int start; | 27 int start; |
| 28 final List<LiveRange> ranges; | 28 final List<LiveRange> ranges; |
| 29 LiveInterval() : ranges = <LiveRange>[]; | 29 LiveInterval() : ranges = <LiveRange>[]; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Update all ranges that are contained in [start, end[ to | 32 * Update all ranges that are contained in [from, to[ to |
| 33 * die at [end]. | 33 * die at [to]. |
| 34 */ | 34 */ |
| 35 void loopUpdate(int start, int end) { | 35 void loopUpdate(int from, int to) { |
| 36 for (LiveRange range in ranges) { | 36 for (LiveRange range in ranges) { |
| 37 if (start <= range.start && range.end < end) { | 37 if (from <= range.start && range.end < to) { |
| 38 range.end = end; | 38 range.end = to; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Add a new range to this interval. | 44 * Add a new range to this interval. |
| 45 */ | 45 */ |
| 46 void add(LiveRange interval) { | 46 void add(LiveRange interval) { |
| 47 ranges.add(interval); | 47 ranges.add(interval); |
| 48 } | 48 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 String allocateName(HInstruction instruction) { | 434 String allocateName(HInstruction instruction) { |
| 435 String name; | 435 String name; |
| 436 if (instruction is HCheck) { | 436 if (instruction is HCheck) { |
| 437 // Special case the check instruction to use the name of its | 437 // Special case the check instruction to use the name of its |
| 438 // checked instruction. | 438 // checked instruction. |
| 439 HCheck check = instruction; | 439 HCheck check = instruction; |
| 440 name = names.ownName[check.checkedInput]; | 440 name = names.ownName[check.checkedInput]; |
| 441 // If the name is null, then the checked input is being | 441 // If the name is null, then the checked input is being |
| 442 // generated at use site, and we don't need a name for the check | 442 // generated at use site, and we don't need a name for the check |
| 443 // instruction. | 443 // instruction. |
| 444 if (name == null) return; | 444 if (name == null) return null; |
| 445 } else if (instruction is HParameterValue) { | 445 } else if (instruction is HParameterValue) { |
| 446 HParameterValue parameter = instruction; | 446 HParameterValue parameter = instruction; |
| 447 name = parameterNames[parameter.element]; | 447 name = parameterNames[parameter.element]; |
| 448 if (name == null) { | 448 if (name == null) { |
| 449 name = allocateWithHint(parameter.element.name.slowToString()); | 449 name = allocateWithHint(parameter.element.name.slowToString()); |
| 450 } | 450 } |
| 451 } else if (instruction.sourceElement !== null) { | 451 } else if (instruction.sourceElement !== null) { |
| 452 name = allocateWithHint(instruction.sourceElement.name.slowToString()); | 452 name = allocateWithHint(instruction.sourceElement.name.slowToString()); |
| 453 } else { | 453 } else { |
| 454 // We could not find an element for the instruction. If the | 454 // We could not find an element for the instruction. If the |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 if (!needsName(input)) { | 571 if (!needsName(input)) { |
| 572 names.addAssignment(predecessor, input, phi); | 572 names.addAssignment(predecessor, input, phi); |
| 573 } else { | 573 } else { |
| 574 names.addCopy(predecessor, input, phi); | 574 names.addCopy(predecessor, input, phi); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 namer.allocateName(phi); | 578 namer.allocateName(phi); |
| 579 } | 579 } |
| 580 } | 580 } |
| OLD | NEW |