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

Side by Side Diff: frog/leg/ssa/builder.dart

Issue 9720024: If there were breaks in a loop, we must not restore the saved localsHandler before entering the loo… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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/co19/co19-leg.status » ('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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 } 1032 }
1033 1033
1034 /** 1034 /**
1035 * Ends the loop: 1035 * Ends the loop:
1036 * - creates a new block and adds it as successor to the [branchBlock]. 1036 * - creates a new block and adds it as successor to the [branchBlock].
1037 * - opens the new block (setting as [current]). 1037 * - opens the new block (setting as [current]).
1038 * - notifies the locals handler that we're exiting a loop. 1038 * - notifies the locals handler that we're exiting a loop.
1039 */ 1039 */
1040 void endLoop(HBasicBlock loopEntry, 1040 void endLoop(HBasicBlock loopEntry,
1041 HBasicBlock branchBlock, 1041 HBasicBlock branchBlock,
1042 BreakHandler breakHandler) { 1042 BreakHandler breakHandler,
1043 LocalsHandler savedLocals) {
1043 HBasicBlock loopExitBlock = addNewBlock(); 1044 HBasicBlock loopExitBlock = addNewBlock();
1044 assert(branchBlock.successors.length == 1); 1045 assert(branchBlock.successors.length == 1);
1045 List<LocalsHandler> breakLocals = <LocalsHandler>[]; 1046 List<LocalsHandler> breakLocals = <LocalsHandler>[];
1046 breakHandler.forEachBreak((HBreak breakInstruction, LocalsHandler locals) { 1047 breakHandler.forEachBreak((HBreak breakInstruction, LocalsHandler locals) {
1047 breakInstruction.block.addSuccessor(loopExitBlock); 1048 breakInstruction.block.addSuccessor(loopExitBlock);
1048 breakLocals.add(locals); 1049 breakLocals.add(locals);
1049 }); 1050 });
1050 branchBlock.addSuccessor(loopExitBlock); 1051 branchBlock.addSuccessor(loopExitBlock);
1051 open(loopExitBlock); 1052 open(loopExitBlock);
1052 localsHandler.endLoop(loopEntry); 1053 localsHandler.endLoop(loopEntry);
1053 if (!breakLocals.isEmpty()) { 1054 if (!breakLocals.isEmpty()) {
1054 breakLocals.add(localsHandler); 1055 breakLocals.add(localsHandler);
floitsch 2012/03/17 22:25:00 add(savedLocals);
ngeoffray 2012/03/18 12:03:45 Thanks for the suggestion. Done.
1055 localsHandler = localsHandler.mergeMultiple(breakLocals, loopExitBlock); 1056 localsHandler = localsHandler.mergeMultiple(breakLocals, loopExitBlock);
1057 } else if (savedLocals != null) {
1058 localsHandler = savedLocals;
1056 } 1059 }
1057 } 1060 }
1058 1061
1059 // For while loops, initializer and update are null. 1062 // For while loops, initializer and update are null.
1060 visitLoop(Node loop, Node initializer, Expression condition, NodeList updates, 1063 visitLoop(Node loop, Node initializer, Expression condition, NodeList updates,
1061 Node body) { 1064 Node body) {
1062 // Generate: 1065 // Generate:
1063 // <initializer> 1066 // <initializer>
1064 // loop-entry: 1067 // loop-entry:
1065 // if (!<condition>) goto loop-exit; 1068 // if (!<condition>) goto loop-exit;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 // The result of the update instruction isn't used, and can just 1128 // The result of the update instruction isn't used, and can just
1126 // be dropped. 1129 // be dropped.
1127 HInstruction updateInstruction = pop(); 1130 HInstruction updateInstruction = pop();
1128 } 1131 }
1129 } 1132 }
1130 updateBlock = close(new HGoto()); 1133 updateBlock = close(new HGoto());
1131 // The back-edge completing the cycle. 1134 // The back-edge completing the cycle.
1132 updateBlock.addSuccessor(conditionBlock); 1135 updateBlock.addSuccessor(conditionBlock);
1133 conditionBlock.postProcessLoopHeader(); 1136 conditionBlock.postProcessLoopHeader();
1134 1137
1135 endLoop(conditionBlock, conditionExitBlock, breakHandler); 1138 endLoop(conditionBlock, conditionExitBlock, breakHandler, savedLocals);
1136 localsHandler = savedLocals;
1137 } 1139 }
1138 1140
1139 visitFor(For node) { 1141 visitFor(For node) {
1140 assert(node.body !== null); 1142 assert(node.body !== null);
1141 visitLoop(node, node.initializer, node.condition, node.update, node.body); 1143 visitLoop(node, node.initializer, node.condition, node.update, node.body);
1142 } 1144 }
1143 1145
1144 visitWhile(While node) { 1146 visitWhile(While node) {
1145 visitLoop(node, null, node.condition, null, node.body); 1147 visitLoop(node, null, node.condition, null, node.body);
1146 } 1148 }
(...skipping 13 matching lines...) Expand all
1160 bodyExitBlock.addSuccessor(conditionBlock); 1162 bodyExitBlock.addSuccessor(conditionBlock);
1161 open(conditionBlock); 1163 open(conditionBlock);
1162 visit(node.condition); 1164 visit(node.condition);
1163 assert(!isAborted()); 1165 assert(!isAborted());
1164 conditionBlock = close(new HLoopBranch(popBoolified(), 1166 conditionBlock = close(new HLoopBranch(popBoolified(),
1165 HLoopBranch.DO_WHILE_LOOP)); 1167 HLoopBranch.DO_WHILE_LOOP));
1166 1168
1167 conditionBlock.addSuccessor(loopEntryBlock); // The back-edge. 1169 conditionBlock.addSuccessor(loopEntryBlock); // The back-edge.
1168 loopEntryBlock.postProcessLoopHeader(); 1170 loopEntryBlock.postProcessLoopHeader();
1169 1171
1170 endLoop(loopEntryBlock, conditionBlock, breakHandler); 1172 endLoop(loopEntryBlock, conditionBlock, breakHandler, null);
floitsch 2012/03/17 22:25:00 localsHandler
ngeoffray 2012/03/18 12:03:45 Done.
1171 } 1173 }
1172 1174
1173 visitFunctionExpression(FunctionExpression node) { 1175 visitFunctionExpression(FunctionExpression node) {
1174 ClosureData nestedClosureData = closureDataCache[node]; 1176 ClosureData nestedClosureData = closureDataCache[node];
1175 assert(nestedClosureData !== null); 1177 assert(nestedClosureData !== null);
1176 assert(nestedClosureData.closureClassElement !== null); 1178 assert(nestedClosureData.closureClassElement !== null);
1177 ClassElement closureClassElement = 1179 ClassElement closureClassElement =
1178 nestedClosureData.closureClassElement; 1180 nestedClosureData.closureClassElement;
1179 FunctionElement callElement = nestedClosureData.callElement; 1181 FunctionElement callElement = nestedClosureData.callElement;
1180 compiler.enqueue(new WorkItem.toCodegen(callElement, elements)); 1182 compiler.enqueue(new WorkItem.toCodegen(callElement, elements));
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 // update block is the jump-target for continue statements. We could avoid 2190 // update block is the jump-target for continue statements. We could avoid
2189 // the creation if there is no continue, but for now we always create it. 2191 // the creation if there is no continue, but for now we always create it.
2190 HBasicBlock updateBlock = addNewBlock(); 2192 HBasicBlock updateBlock = addNewBlock();
2191 bodyBlock.addSuccessor(updateBlock); 2193 bodyBlock.addSuccessor(updateBlock);
2192 open(updateBlock); 2194 open(updateBlock);
2193 updateBlock = close(new HGoto()); 2195 updateBlock = close(new HGoto());
2194 // The back-edge completing the cycle. 2196 // The back-edge completing the cycle.
2195 updateBlock.addSuccessor(conditionBlock); 2197 updateBlock.addSuccessor(conditionBlock);
2196 conditionBlock.postProcessLoopHeader(); 2198 conditionBlock.postProcessLoopHeader();
2197 2199
2198 endLoop(conditionBlock, conditionExitBlock, breakHandler); 2200 endLoop(conditionBlock, conditionExitBlock, breakHandler, savedLocals);
2199 localsHandler = savedLocals;
2200 breakHandler.close(); 2201 breakHandler.close();
2201 } 2202 }
2202 2203
2203 visitLabeledStatement(LabeledStatement node) { 2204 visitLabeledStatement(LabeledStatement node) {
2204 Statement body = node.getBody(); 2205 Statement body = node.getBody();
2205 if (body is Loop || body is SwitchStatement) { 2206 if (body is Loop || body is SwitchStatement) {
2206 // Loops and switches handle their own labels. 2207 // Loops and switches handle their own labels.
2207 visit(body); 2208 visit(body);
2208 return; 2209 return;
2209 } 2210 }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 buildBody() { 2547 buildBody() {
2547 // TODO(lrn): Make sure to take continue into account. 2548 // TODO(lrn): Make sure to take continue into account.
2548 visit(body); 2549 visit(body);
2549 if (isAborted()) { 2550 if (isAborted()) {
2550 compiler.reportWarning(body, "aborting loop body"); 2551 compiler.reportWarning(body, "aborting loop body");
2551 } 2552 }
2552 } 2553 }
2553 handleIf(buildBody, null); 2554 handleIf(buildBody, null);
2554 } 2555 }
2555 } 2556 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698