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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 2932023003: Refactor LoopHandler to avoid calling KernelAstAdapter.getNode (Closed)
Patch Set: Created 3 years, 6 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
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 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 } 1737 }
1738 1738
1739 loopHandler.handleLoop(node, () {}, buildCondition, () {}, () { 1739 loopHandler.handleLoop(node, () {}, buildCondition, () {}, () {
1740 visit(node.body); 1740 visit(node.body);
1741 }); 1741 });
1742 } 1742 }
1743 1743
1744 visitDoWhile(ast.DoWhile node) { 1744 visitDoWhile(ast.DoWhile node) {
1745 assert(isReachable); 1745 assert(isReachable);
1746 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler); 1746 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler);
1747 localsHandler.startLoop(node); 1747 ClosureScope scopeData = localsHandler.closureData.capturingScopes[node];
1748 localsHandler.startLoop(scopeData);
Emily Fortuna 2017/06/09 20:12:26 great minds think alike? I actually have a CL tha
Johnni Winther 2017/06/12 08:02:52 I'll wait for your CL to land
1748 loopDepth++; 1749 loopDepth++;
1749 JumpHandler jumpHandler = loopHandler.beginLoopHeader(node); 1750 JumpHandler jumpHandler = loopHandler.beginLoopHeader(node);
1750 HLoopInformation loopInfo = current.loopInformation; 1751 HLoopInformation loopInfo = current.loopInformation;
1751 HBasicBlock loopEntryBlock = current; 1752 HBasicBlock loopEntryBlock = current;
1752 HBasicBlock bodyEntryBlock = current; 1753 HBasicBlock bodyEntryBlock = current;
1753 JumpTarget target = elements.getTargetDefinition(node); 1754 JumpTarget target = elements.getTargetDefinition(node);
1754 bool hasContinues = target != null && target.isContinueTarget; 1755 bool hasContinues = target != null && target.isContinueTarget;
1755 if (hasContinues) { 1756 if (hasContinues) {
1756 // Add extra block to hang labels on. 1757 // Add extra block to hang labels on.
1757 // It doesn't currently work if they are on the same block as the 1758 // It doesn't currently work if they are on the same block as the
1758 // HLoopInfo. The handling of HLabeledBlockInformation will visit a 1759 // HLoopInfo. The handling of HLabeledBlockInformation will visit a
1759 // SubGraph that starts at the same block again, so the HLoopInfo is 1760 // SubGraph that starts at the same block again, so the HLoopInfo is
1760 // either handled twice, or it's handled after the labeled block info, 1761 // either handled twice, or it's handled after the labeled block info,
1761 // both of which generate the wrong code. 1762 // both of which generate the wrong code.
1762 // Using a separate block is just a simple workaround. 1763 // Using a separate block is just a simple workaround.
1763 bodyEntryBlock = openNewBlock(); 1764 bodyEntryBlock = openNewBlock();
1764 } 1765 }
1765 localsHandler.enterLoopBody(node); 1766 localsHandler.enterLoopBody(scopeData);
1766 visit(node.body); 1767 visit(node.body);
1767 1768
1768 // If there are no continues we could avoid the creation of the condition 1769 // If there are no continues we could avoid the creation of the condition
1769 // block. This could also lead to a block having multiple entries and exits. 1770 // block. This could also lead to a block having multiple entries and exits.
1770 HBasicBlock bodyExitBlock; 1771 HBasicBlock bodyExitBlock;
1771 bool isAbortingBody = false; 1772 bool isAbortingBody = false;
1772 if (current != null) { 1773 if (current != null) {
1773 bodyExitBlock = close(new HGoto()); 1774 bodyExitBlock = close(new HGoto());
1774 } else { 1775 } else {
1775 isAbortingBody = true; 1776 isAbortingBody = true;
(...skipping 5060 matching lines...) Expand 10 before | Expand all | Expand 10 after
6836 this.oldReturnLocal, 6837 this.oldReturnLocal,
6837 this.oldReturnType, 6838 this.oldReturnType,
6838 this.oldResolvedAst, 6839 this.oldResolvedAst,
6839 this.oldStack, 6840 this.oldStack,
6840 this.oldLocalsHandler, 6841 this.oldLocalsHandler,
6841 this.inTryStatement, 6842 this.inTryStatement,
6842 this.allFunctionsCalledOnce, 6843 this.allFunctionsCalledOnce,
6843 this.oldElementInferenceResults) 6844 this.oldElementInferenceResults)
6844 : super(function); 6845 : super(function);
6845 } 6846 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698