Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 13877005: Fix invalid SSA graph generated by dart2js by using the savedLocals in a do/while (the ones before … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/do_while4_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 directLocals[element] = instruction;
642 } else {
kasperl 2013/04/11 11:49:49 else if?
ngeoffray 2013/04/11 11:57:48 I simplified the condition.
643 if (instruction.inputs.length != localsHandlers.length) {
644 joinBlock.removePhi(instruction);
645 } else {
646 directLocals[element] = instruction;
647 }
648 }
649 });
637 return this; 650 return this;
638 } 651 }
639 } 652 }
640 653
641 654
642 // Represents a single break/continue instruction. 655 // Represents a single break/continue instruction.
643 class JumpHandlerEntry { 656 class JumpHandlerEntry {
644 final HJump jumpInstruction; 657 final HJump jumpInstruction;
645 final LocalsHandler locals; 658 final LocalsHandler locals;
646 bool isBreak() => jumpInstruction is HBreak; 659 bool isBreak() => jumpInstruction is HBreak;
(...skipping 4557 matching lines...) Expand 10 before | Expand all | Expand 10 after
5204 new HSubGraphBlockInformation(elseBranch.graph)); 5217 new HSubGraphBlockInformation(elseBranch.graph));
5205 5218
5206 HBasicBlock conditionStartBlock = conditionBranch.block; 5219 HBasicBlock conditionStartBlock = conditionBranch.block;
5207 conditionStartBlock.setBlockFlow(info, joinBlock); 5220 conditionStartBlock.setBlockFlow(info, joinBlock);
5208 SubGraph conditionGraph = conditionBranch.graph; 5221 SubGraph conditionGraph = conditionBranch.graph;
5209 HIf branch = conditionGraph.end.last; 5222 HIf branch = conditionGraph.end.last;
5210 assert(branch is HIf); 5223 assert(branch is HIf);
5211 branch.blockInformation = conditionStartBlock.blockFlow; 5224 branch.blockInformation = conditionStartBlock.blockFlow;
5212 } 5225 }
5213 } 5226 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/do_while4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698