| 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 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
| 9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 * exclude local values from the result when they are no longer in scope. | 603 * exclude local values from the result when they are no longer in scope. |
| 604 */ | 604 */ |
| 605 LocalsHandler mergeMultiple(List<LocalsHandler> localsHandlers, | 605 LocalsHandler mergeMultiple(List<LocalsHandler> localsHandlers, |
| 606 HBasicBlock joinBlock) { | 606 HBasicBlock joinBlock) { |
| 607 assert(localsHandlers.length > 0); | 607 assert(localsHandlers.length > 0); |
| 608 if (localsHandlers.length == 1) return localsHandlers[0]; | 608 if (localsHandlers.length == 1) return localsHandlers[0]; |
| 609 Map<Element, HInstruction> joinedLocals = | 609 Map<Element, HInstruction> joinedLocals = |
| 610 new LinkedHashMap<Element,HInstruction>(); | 610 new LinkedHashMap<Element,HInstruction>(); |
| 611 HInstruction thisValue = null; | 611 HInstruction thisValue = null; |
| 612 directLocals.forEach((Element element, HInstruction instruction) { | 612 directLocals.forEach((Element element, HInstruction instruction) { |
| 613 if (!identical(element, closureData.thisElement)) { | 613 if (element != closureData.thisElement) { |
| 614 HPhi phi = new HPhi.noInputs(element); | 614 HPhi phi = new HPhi.noInputs(element); |
| 615 joinedLocals[element] = phi; | 615 joinedLocals[element] = phi; |
| 616 joinBlock.addPhi(phi); | 616 joinBlock.addPhi(phi); |
| 617 } else { | 617 } else { |
| 618 // We know that "this" never changes, if it's there. | 618 // We know that "this" never changes, if it's there. |
| 619 // Save it for later. While merging, there is no phi for "this", | 619 // Save it for later. While merging, there is no phi for "this", |
| 620 // so we don't have to special case it in the merge loop. | 620 // so we don't have to special case it in the merge loop. |
| 621 thisValue = instruction; | 621 thisValue = instruction; |
| 622 } | 622 } |
| 623 }); | 623 }); |
| 624 for (LocalsHandler handler in localsHandlers) { | 624 for (LocalsHandler handler in localsHandlers) { |
| 625 handler.directLocals.forEach((Element element, HInstruction instruction) { | 625 handler.directLocals.forEach((Element element, HInstruction instruction) { |
| 626 HPhi phi = joinedLocals[element]; | 626 HPhi phi = joinedLocals[element]; |
| 627 if (phi != null) { | 627 if (phi != null) { |
| 628 phi.addInput(instruction); | 628 phi.addInput(instruction); |
| 629 } | 629 } |
| 630 }); | 630 }); |
| 631 } | 631 } |
| 632 if (thisValue != null) { | 632 if (thisValue != null) { |
| 633 // If there was a "this" for the scope, add it to the new locals. | 633 // If there was a "this" for the scope, add it to the new locals. |
| 634 joinedLocals[closureData.thisElement] = thisValue; | 634 joinedLocals[closureData.thisElement] = thisValue; |
| 635 } | 635 } |
| 636 directLocals = joinedLocals; | 636 |
| 637 // Remove locals that are not in all handlers. |
| 638 directLocals = new LinkedHashMap<Element, HInstruction>(); |
| 639 joinedLocals.forEach((element, instruction) { |
| 640 if (instruction is HPhi |
| 641 && instruction.inputs.length != localsHandlers.length) { |
| 642 joinBlock.removePhi(instruction); |
| 643 } else { |
| 644 directLocals[element] = instruction; |
| 645 } |
| 646 }); |
| 637 return this; | 647 return this; |
| 638 } | 648 } |
| 639 } | 649 } |
| 640 | 650 |
| 641 | 651 |
| 642 // Represents a single break/continue instruction. | 652 // Represents a single break/continue instruction. |
| 643 class JumpHandlerEntry { | 653 class JumpHandlerEntry { |
| 644 final HJump jumpInstruction; | 654 final HJump jumpInstruction; |
| 645 final LocalsHandler locals; | 655 final LocalsHandler locals; |
| 646 bool isBreak() => jumpInstruction is HBreak; | 656 bool isBreak() => jumpInstruction is HBreak; |
| (...skipping 4557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5204 new HSubGraphBlockInformation(elseBranch.graph)); | 5214 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5205 | 5215 |
| 5206 HBasicBlock conditionStartBlock = conditionBranch.block; | 5216 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5207 conditionStartBlock.setBlockFlow(info, joinBlock); | 5217 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5208 SubGraph conditionGraph = conditionBranch.graph; | 5218 SubGraph conditionGraph = conditionBranch.graph; |
| 5209 HIf branch = conditionGraph.end.last; | 5219 HIf branch = conditionGraph.end.last; |
| 5210 assert(branch is HIf); | 5220 assert(branch is HIf); |
| 5211 branch.blockInformation = conditionStartBlock.blockFlow; | 5221 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5212 } | 5222 } |
| 5213 } | 5223 } |
| OLD | NEW |