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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 382 |
383 VariableNames(Map<Element, String> parameterNames) | 383 VariableNames(Map<Element, String> parameterNames) |
384 : ownName = new Map<HInstruction, String>(), | 384 : ownName = new Map<HInstruction, String>(), |
385 copyHandlers = new Map<HBasicBlock, CopyHandler>(), | 385 copyHandlers = new Map<HBasicBlock, CopyHandler>(), |
386 swapTemp = computeFreshWithPrefix("t", parameterNames), | 386 swapTemp = computeFreshWithPrefix("t", parameterNames), |
387 stateName = computeFreshWithPrefix("state", parameterNames); | 387 stateName = computeFreshWithPrefix("state", parameterNames); |
388 | 388 |
389 /** Returns a fresh variable with the given prefix. */ | 389 /** Returns a fresh variable with the given prefix. */ |
390 static String computeFreshWithPrefix(String prefix, | 390 static String computeFreshWithPrefix(String prefix, |
391 Map<Element, String> parameterNames) { | 391 Map<Element, String> parameterNames) { |
392 Set<String> parameters = new Set<String>.from(parameterNames.getValues()); | 392 Set<String> parameters = new Set<String>.from(parameterNames.values); |
393 String name = '${prefix}0'; | 393 String name = '${prefix}0'; |
394 int i = 1; | 394 int i = 1; |
395 while (parameters.contains(name)) name = '$prefix${i++}'; | 395 while (parameters.contains(name)) name = '$prefix${i++}'; |
396 return name; | 396 return name; |
397 } | 397 } |
398 | 398 |
399 String getName(HInstruction instruction) { | 399 String getName(HInstruction instruction) { |
400 return ownName[instruction]; | 400 return ownName[instruction]; |
401 } | 401 } |
402 | 402 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 if (!needsName(input)) { | 650 if (!needsName(input)) { |
651 names.addAssignment(predecessor, input, phi); | 651 names.addAssignment(predecessor, input, phi); |
652 } else { | 652 } else { |
653 names.addCopy(predecessor, input, phi); | 653 names.addCopy(predecessor, input, phi); |
654 } | 654 } |
655 } | 655 } |
656 | 656 |
657 namer.allocateName(phi); | 657 namer.allocateName(phi); |
658 } | 658 } |
659 } | 659 } |
OLD | NEW |