| 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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 | 9 |
| 10 String buildJavaScriptFunction(FunctionElement element, | 10 String buildJavaScriptFunction(FunctionElement element, |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 | 1304 |
| 1305 visitGoto(HGoto node) { | 1305 visitGoto(HGoto node) { |
| 1306 assert(currentBlock.successors.length == 1); | 1306 assert(currentBlock.successors.length == 1); |
| 1307 List<HBasicBlock> dominated = currentBlock.dominatedBlocks; | 1307 List<HBasicBlock> dominated = currentBlock.dominatedBlocks; |
| 1308 // With the exception of the entry-node which dominates its successor | 1308 // With the exception of the entry-node which dominates its successor |
| 1309 // and the exit node, no block finishing with a 'goto' can have more than | 1309 // and the exit node, no block finishing with a 'goto' can have more than |
| 1310 // one dominated block (since it has only one successor). | 1310 // one dominated block (since it has only one successor). |
| 1311 // If the successor is dominated by another block, then the other block | 1311 // If the successor is dominated by another block, then the other block |
| 1312 // is responsible for visiting the successor. | 1312 // is responsible for visiting the successor. |
| 1313 if (dominated.isEmpty()) return; | 1313 if (dominated.isEmpty()) return; |
| 1314 if (dominated.length > 2) unreachable(); | 1314 if (dominated.length > 2) { |
| 1315 compiler.internalError('dominated.length = ${dominated.length}', |
| 1316 instruction: node); |
| 1317 } |
| 1315 if (dominated.length == 2 && currentBlock !== currentGraph.entry) { | 1318 if (dominated.length == 2 && currentBlock !== currentGraph.entry) { |
| 1316 unreachable(); | 1319 compiler.internalError('currentBlock !== currentGraph.entry', |
| 1320 instruction: node); |
| 1317 } | 1321 } |
| 1318 assert(dominated[0] == currentBlock.successors[0]); | 1322 assert(dominated[0] == currentBlock.successors[0]); |
| 1319 visitBasicBlock(dominated[0]); | 1323 visitBasicBlock(dominated[0]); |
| 1320 } | 1324 } |
| 1321 | 1325 |
| 1322 // Used to write the name of labels. | 1326 // Used to write the name of labels. |
| 1323 void writeLabel(LabelElement label) { | 1327 void writeLabel(LabelElement label) { |
| 1324 buffer.add('\$${label.labelName}\$${label.target.nestingLevel}'); | 1328 buffer.add('\$${label.labelName}\$${label.target.nestingLevel}'); |
| 1325 } | 1329 } |
| 1326 | 1330 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 if (!tryCallAction(continueAction, target)) { | 1385 if (!tryCallAction(continueAction, target)) { |
| 1382 addIndented("continue;\n"); | 1386 addIndented("continue;\n"); |
| 1383 } | 1387 } |
| 1384 } | 1388 } |
| 1385 } | 1389 } |
| 1386 | 1390 |
| 1387 visitTry(HTry node) { | 1391 visitTry(HTry node) { |
| 1388 // We should never get here. Try/catch/finally is always handled using block | 1392 // We should never get here. Try/catch/finally is always handled using block |
| 1389 // information in [visitTryInfo], or not at all, in the case of the bailout | 1393 // information in [visitTryInfo], or not at all, in the case of the bailout |
| 1390 // generator. | 1394 // generator. |
| 1391 unreachable(); | 1395 compiler.internalError('visitTry should not be called', instruction: node); |
| 1392 } | 1396 } |
| 1393 | 1397 |
| 1394 visitIf(HIf node) { | 1398 visitIf(HIf node) { |
| 1395 if (subGraph !== null && node.block === subGraph.end) { | 1399 if (subGraph !== null && node.block === subGraph.end) { |
| 1396 if (isGeneratingExpression()) { | 1400 if (isGeneratingExpression()) { |
| 1397 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); | 1401 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); |
| 1398 } | 1402 } |
| 1399 return; | 1403 return; |
| 1400 } | 1404 } |
| 1401 HInstruction condition = node.inputs[0]; | 1405 HInstruction condition = node.inputs[0]; |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2309 } else if (node.isIndexablePrimitive()) { | 2313 } else if (node.isIndexablePrimitive()) { |
| 2310 buffer.add('if ('); | 2314 buffer.add('if ('); |
| 2311 checkString(input, '!=='); | 2315 checkString(input, '!=='); |
| 2312 buffer.add(' && ('); | 2316 buffer.add(' && ('); |
| 2313 checkObject(input, '!=='); | 2317 checkObject(input, '!=='); |
| 2314 buffer.add('||'); | 2318 buffer.add('||'); |
| 2315 checkArray(input, '!=='); | 2319 checkArray(input, '!=='); |
| 2316 buffer.add(')) '); | 2320 buffer.add(')) '); |
| 2317 bailout(node, 'Not a string or array'); | 2321 bailout(node, 'Not a string or array'); |
| 2318 } else { | 2322 } else { |
| 2319 unreachable(); | 2323 compiler.internalError('Unexpected type guard', instruction: input); |
| 2320 } | 2324 } |
| 2321 buffer.add(';\n'); | 2325 buffer.add(';\n'); |
| 2322 } | 2326 } |
| 2323 | 2327 |
| 2324 void beginLoop(HBasicBlock block) { | 2328 void beginLoop(HBasicBlock block) { |
| 2325 addIndentation(); | 2329 addIndentation(); |
| 2326 HLoopInformation info = block.loopInformation; | 2330 HLoopInformation info = block.loopInformation; |
| 2327 for (LabelElement label in info.labels) { | 2331 for (LabelElement label in info.labels) { |
| 2328 writeLabel(label); | 2332 writeLabel(label); |
| 2329 buffer.add(":"); | 2333 buffer.add(":"); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2613 startBailoutSwitch(); | 2617 startBailoutSwitch(); |
| 2614 } | 2618 } |
| 2615 } | 2619 } |
| 2616 | 2620 |
| 2617 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2621 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2618 if (labeledBlockInfo.body.start.hasGuards()) { | 2622 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2619 endBailoutSwitch(); | 2623 endBailoutSwitch(); |
| 2620 } | 2624 } |
| 2621 } | 2625 } |
| 2622 } | 2626 } |
| OLD | NEW |