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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 /** | 7 /** |
8 * The [LiveRange] class covers a range where an instruction is live. | 8 * The [LiveRange] class covers a range where an instruction is live. |
9 */ | 9 */ |
10 class LiveRange { | 10 class LiveRange { |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 /** | 439 /** |
440 * Allocates variable names for instructions, making sure they don't collide. | 440 * Allocates variable names for instructions, making sure they don't collide. |
441 */ | 441 */ |
442 class VariableNamer { | 442 class VariableNamer { |
443 final VariableNames names; | 443 final VariableNames names; |
444 final Set<String> usedNames; | 444 final Set<String> usedNames; |
445 final Map<Element, String> parameterNames; | 445 final Map<Element, String> parameterNames; |
446 final List<String> freeTemporaryNames; | 446 final List<String> freeTemporaryNames; |
447 int temporaryIndex = 0; | 447 int temporaryIndex = 0; |
448 static final RegExp regexp = new RegExp('t[0-9]+'); | |
449 | 448 |
450 VariableNamer(LiveEnvironment environment, this.names, this.parameterNames) | 449 VariableNamer(LiveEnvironment environment, this.names, this.parameterNames) |
451 : usedNames = new Set<String>(), | 450 : usedNames = new Set<String>(), |
452 freeTemporaryNames = new List<String>() { | 451 freeTemporaryNames = new List<String>() { |
453 // [VariableNames.swapTemp] is used when there is a cycle in a copy handler. | 452 // [VariableNames.swapTemp] is used when there is a cycle in a copy handler. |
454 // Therefore we make sure no one uses it. | 453 // Therefore we make sure no one uses it. |
455 usedNames.add(names.swapTemp); | 454 usedNames.add(names.swapTemp); |
456 // [VariableNames.stateName] is being used throughout a bailout function. | 455 // [VariableNames.stateName] is being used throughout a bailout function. |
457 // Whenever a bailout-target is reached we set the state-variable to 0. We | 456 // Whenever a bailout-target is reached we set the state-variable to 0. We |
458 // must therefore not have any local variable that could clash with the | 457 // must therefore not have any local variable that could clash with the |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 names.ownName[instruction] = name; | 543 names.ownName[instruction] = name; |
545 return name; | 544 return name; |
546 } | 545 } |
547 | 546 |
548 /** | 547 /** |
549 * Frees [instruction]'s name so it can be used for other instructions. | 548 * Frees [instruction]'s name so it can be used for other instructions. |
550 */ | 549 */ |
551 void freeName(HInstruction instruction) { | 550 void freeName(HInstruction instruction) { |
552 String ownName = names.ownName[instruction]; | 551 String ownName = names.ownName[instruction]; |
553 if (ownName != null) { | 552 if (ownName != null) { |
| 553 RegExp regexp = const RegExp('t[0-9]+'); |
554 // We check if we have already looked for temporary names | 554 // We check if we have already looked for temporary names |
555 // because if we haven't, chances are the temporary we allocate | 555 // because if we haven't, chances are the temporary we allocate |
556 // in this block can match a phi with the same name in the | 556 // in this block can match a phi with the same name in the |
557 // successor block. | 557 // successor block. |
558 if (temporaryIndex != 0 && regexp.hasMatch(ownName)) { | 558 if (temporaryIndex != 0 && regexp.hasMatch(ownName)) { |
559 freeTemporaryNames.addLast(ownName); | 559 freeTemporaryNames.addLast(ownName); |
560 } | 560 } |
561 usedNames.remove(ownName); | 561 usedNames.remove(ownName); |
562 } | 562 } |
563 } | 563 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 if (!needsName(input)) { | 675 if (!needsName(input)) { |
676 names.addAssignment(predecessor, input, phi); | 676 names.addAssignment(predecessor, input, phi); |
677 } else { | 677 } else { |
678 names.addCopy(predecessor, input, phi); | 678 names.addCopy(predecessor, input, phi); |
679 } | 679 } |
680 } | 680 } |
681 | 681 |
682 namer.allocateName(phi); | 682 namer.allocateName(phi); |
683 } | 683 } |
684 } | 684 } |
OLD | NEW |