Chromium Code Reviews| 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 final JavaScriptBackend backend; | 6 final JavaScriptBackend backend; |
| 7 SsaCodeGeneratorTask(JavaScriptBackend backend) | 7 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 8 : this.backend = backend, | 8 : this.backend = backend, |
| 9 super(backend.compiler); | 9 super(backend.compiler); |
| 10 String get name() => 'SSA code generator'; | 10 String get name() => 'SSA code generator'; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 static final int STATE_EXPRESSION = 3; | 116 static final int STATE_EXPRESSION = 3; |
| 117 static final int STATE_DECLARATION = 4; | 117 static final int STATE_DECLARATION = 4; |
| 118 | 118 |
| 119 /** | 119 /** |
| 120 * When analyzing a [HStatementGraph] we try to recognize if it has | 120 * When analyzing a [HStatementGraph] we try to recognize if it has |
| 121 * the following properties. | 121 * the following properties. |
| 122 */ | 122 */ |
| 123 static final int ONE_STATEMENT = 0; | 123 static final int ONE_STATEMENT = 0; |
| 124 static final int ONE_EXPRESSION = 1; | 124 static final int ONE_EXPRESSION = 1; |
| 125 static final int EMPTY = 2; | 125 static final int EMPTY = 2; |
| 126 static final int MULTIPLE_STATEMENTS = 3; | 126 static final int IF_STATEMENT = 3; |
| 127 static final int MULTIPLE_STATEMENTS = 4; | |
| 127 | 128 |
| 128 /** | 129 /** |
| 129 * Returned by [expressionType] to tell how code can be generated for | 130 * Returned by [expressionType] to tell how code can be generated for |
| 130 * a subgraph. | 131 * a subgraph. |
| 131 * - [TYPE_STATEMENT] means that the graph must be generated as a statement, | 132 * - [TYPE_STATEMENT] means that the graph must be generated as a statement, |
| 132 * which is always possible. | 133 * which is always possible. |
| 133 * - [TYPE_EXPRESSION] means that the graph can be generated as an expression, | 134 * - [TYPE_EXPRESSION] means that the graph can be generated as an expression, |
| 134 * or possibly several comma-separated expressions. | 135 * or possibly several comma-separated expressions. |
| 135 * - [TYPE_DECLARATION] means that the graph can be generated as an | 136 * - [TYPE_DECLARATION] means that the graph can be generated as an |
| 136 * expression, and that it only generates expressions of the form | 137 * expression, and that it only generates expressions of the form |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 * Set of variables that have already been declared. | 169 * Set of variables that have already been declared. |
| 169 */ | 170 */ |
| 170 final Set<String> declaredVariables; | 171 final Set<String> declaredVariables; |
| 171 | 172 |
| 172 Element equalsNullElement; | 173 Element equalsNullElement; |
| 173 Element boolifiedEqualsNullElement; | 174 Element boolifiedEqualsNullElement; |
| 174 int indent = 0; | 175 int indent = 0; |
| 175 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE; | 176 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE; |
| 176 JSBinaryOperatorPrecedence unsignedShiftPrecedences; | 177 JSBinaryOperatorPrecedence unsignedShiftPrecedences; |
| 177 HGraph currentGraph; | 178 HGraph currentGraph; |
| 179 | |
| 178 /** | 180 /** |
| 179 * Whether the code-generation should try to generate an expression | 181 * Whether the code-generation should try to generate an expression |
| 180 * instead of a sequence of statements. | 182 * instead of a sequence of statements. |
| 181 */ | 183 */ |
| 182 int generationState = STATE_STATEMENT; | 184 int generationState = STATE_STATEMENT; |
| 185 | |
| 186 /** | |
| 187 * Whether we are generating a statement that does not need | |
| 188 * indentation (e.g. an 'if' in an 'else if'). | |
|
Lasse Reichstein Nielsen
2012/06/19 09:10:44
Thanks for the explanation.
Nitpick: "," after "e.
| |
| 189 */ | |
| 190 bool generatingInlineStatement = false; | |
| 191 | |
| 183 HBasicBlock currentBlock; | 192 HBasicBlock currentBlock; |
| 184 | 193 |
| 185 // Records a block-information that is being handled specially. | 194 // Records a block-information that is being handled specially. |
| 186 // Used to break bad recursion. | 195 // Used to break bad recursion. |
| 187 HBlockInformation currentBlockInformation; | 196 HBlockInformation currentBlockInformation; |
| 188 // The subgraph is used to delimit traversal for some constructions, e.g., | 197 // The subgraph is used to delimit traversal for some constructions, e.g., |
| 189 // if branches. | 198 // if branches. |
| 190 SubGraph subGraph; | 199 SubGraph subGraph; |
| 191 | 200 |
| 192 LibraryElement get currentLibrary() => work.element.getLibrary(); | 201 LibraryElement get currentLibrary() => work.element.getLibrary(); |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1321 // information in [visitTryInfo], or not at all, in the case of the bailout | 1330 // information in [visitTryInfo], or not at all, in the case of the bailout |
| 1322 // generator. | 1331 // generator. |
| 1323 compiler.internalError('visitTry should not be called', instruction: node); | 1332 compiler.internalError('visitTry should not be called', instruction: node); |
| 1324 } | 1333 } |
| 1325 | 1334 |
| 1326 /** | 1335 /** |
| 1327 * Analyzes the given [graph] to know whether it is empty, or | 1336 * Analyzes the given [graph] to know whether it is empty, or |
| 1328 * contains one statement, one expression, or multiple statements. | 1337 * contains one statement, one expression, or multiple statements. |
| 1329 */ | 1338 */ |
| 1330 int analyzeGraphForCodegen(HStatementInformation graph) { | 1339 int analyzeGraphForCodegen(HStatementInformation graph) { |
| 1331 HBasicBlock start = graph.start; | 1340 return analyzeBlocksForCodegen(graph.start, graph.end); |
| 1332 HBasicBlock end = graph.end; | 1341 } |
| 1333 // Only deal with single blocks for now. TODO(ngeoffray): analyze | |
| 1334 // all blocks. | |
| 1335 if (start !== end) return MULTIPLE_STATEMENTS; | |
| 1336 | 1342 |
| 1343 int analyzeBlocksForCodegen(HBasicBlock start, HBasicBlock end) { | |
| 1337 int kind = EMPTY; | 1344 int kind = EMPTY; |
| 1338 bool updateKind(int newKind) { | 1345 bool updateKind(int newKind) { |
| 1339 if (kind != EMPTY) return false; | 1346 if (kind != EMPTY) return false; |
| 1340 kind = newKind; | 1347 kind = newKind; |
| 1341 return true; | 1348 return true; |
| 1342 } | 1349 } |
| 1343 | 1350 |
| 1344 for (HInstruction instruction = start.first; | 1351 for (HInstruction instruction = start.first; |
| 1345 instruction != start.last; | 1352 instruction != start.last; |
| 1346 instruction = instruction.next) { | 1353 instruction = instruction.next) { |
| 1347 if (instruction.isStatement()) { | 1354 if (instruction.isStatement()) { |
| 1348 if (!updateKind(ONE_STATEMENT)) return MULTIPLE_STATEMENTS; | 1355 if (!updateKind(ONE_STATEMENT)) return MULTIPLE_STATEMENTS; |
| 1349 } else if (!isGenerateAtUseSite(instruction)) { | 1356 } else if (!isGenerateAtUseSite(instruction)) { |
| 1350 if (!updateKind(ONE_EXPRESSION)) return MULTIPLE_STATEMENTS; | 1357 if (!updateKind(ONE_EXPRESSION)) return MULTIPLE_STATEMENTS; |
| 1351 } | 1358 } |
| 1352 } | 1359 } |
| 1353 | 1360 |
| 1354 HInstruction last = start.last; | 1361 HInstruction last = start.last; |
| 1355 if (last is !HGoto) { | 1362 if (last is HGoto) { |
| 1356 if (!updateKind(last.isStatement() ? ONE_STATEMENT : ONE_EXPRESSION)) { | 1363 if (start !== end) { |
| 1364 int nextKind = analyzeBlocksForCodegen(start.successors[0], end); | |
| 1365 if (!updateKind(nextKind)) return MULTIPLE_STATEMENTS; | |
| 1366 } | |
| 1367 } else if (last is HIf) { | |
| 1368 HIf ifInstruction = last; | |
| 1369 if (ifInstruction.joinBlock !== null | |
| 1370 && analyzeBlocksForCodegen(ifInstruction.joinBlock, end) != EMPTY) { | |
| 1357 return MULTIPLE_STATEMENTS; | 1371 return MULTIPLE_STATEMENTS; |
| 1358 } | 1372 } |
| 1373 int ifKind = controlFlowOperators.contains(ifInstruction) | |
| 1374 ? ONE_EXPRESSION | |
| 1375 : IF_STATEMENT; | |
| 1376 if (!updateKind(ifKind)) return MULTIPLE_STATEMENTS; | |
| 1377 } else if (start !== end) { | |
| 1378 return MULTIPLE_STATEMENTS; | |
| 1379 } else if (!updateKind( | |
| 1380 last.isStatement() ? ONE_STATEMENT : ONE_EXPRESSION)) { | |
| 1381 return MULTIPLE_STATEMENTS; | |
| 1359 } | 1382 } |
| 1360 | 1383 |
| 1361 CopyHandler handler = variableNames.getCopyHandler(start); | 1384 CopyHandler handler = variableNames.getCopyHandler(start); |
| 1362 if (handler !== null && !handler.isEmpty()) { | 1385 if (handler !== null && !handler.isEmpty()) { |
| 1363 if (handler.assignments.length > 1) return MULTIPLE_STATEMENTS; | 1386 if (handler.assignments.length > 1) return MULTIPLE_STATEMENTS; |
| 1364 if (handler.assignments.length == 1) { | 1387 if (handler.assignments.length == 1) { |
| 1365 if (!updateKind(ONE_STATEMENT)) return MULTIPLE_STATEMENTS; | 1388 if (!updateKind(ONE_STATEMENT)) return MULTIPLE_STATEMENTS; |
| 1366 } | 1389 } |
| 1367 // If the block has a copy where the destination and source are | 1390 // If the block has a copy where the destination and source are |
| 1368 // different, we will emit that copy, and therefore the block is | 1391 // different, we will emit that copy, and therefore the block is |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1382 if (!controlFlowOperators.contains(node)) return false; | 1405 if (!controlFlowOperators.contains(node)) return false; |
| 1383 HPhi phi = node.joinBlock.phis.first; | 1406 HPhi phi = node.joinBlock.phis.first; |
| 1384 bool atUseSite = isGenerateAtUseSite(phi); | 1407 bool atUseSite = isGenerateAtUseSite(phi); |
| 1385 // Don't generate a conditional operator in this situation: | 1408 // Don't generate a conditional operator in this situation: |
| 1386 // i = condition ? bar() : i; | 1409 // i = condition ? bar() : i; |
| 1387 // But generate this instead: | 1410 // But generate this instead: |
| 1388 // if (condition) i = bar(); | 1411 // if (condition) i = bar(); |
| 1389 // Usually, the variable name is longer than 'if' and it takes up | 1412 // Usually, the variable name is longer than 'if' and it takes up |
| 1390 // more space to duplicate the name. | 1413 // more space to duplicate the name. |
| 1391 if (!atUseSite | 1414 if (!atUseSite |
| 1415 && !generatingInlineStatement | |
| 1392 && variableNames.getName(phi) == variableNames.getName(phi.inputs[1])) { | 1416 && variableNames.getName(phi) == variableNames.getName(phi.inputs[1])) { |
| 1393 return false; | 1417 return false; |
| 1394 } | 1418 } |
| 1395 if (!atUseSite) define(phi); | 1419 if (!atUseSite) define(phi); |
| 1396 visitBasicBlock(node.joinBlock); | 1420 visitBasicBlock(node.joinBlock); |
| 1397 return true; | 1421 return true; |
| 1398 } | 1422 } |
| 1399 | 1423 |
| 1400 void generateIf(HIf node, HIfBlockInformation info) { | 1424 void generateIf(HIf node, HIfBlockInformation info) { |
| 1401 HStatementInformation thenGraph = info.thenGraph; | 1425 HStatementInformation thenGraph = info.thenGraph; |
| 1402 HStatementInformation elseGraph = info.elseGraph; | 1426 HStatementInformation elseGraph = info.elseGraph; |
| 1403 int thenKind = analyzeGraphForCodegen(thenGraph); | 1427 int thenKind = analyzeGraphForCodegen(thenGraph); |
| 1404 int elseKind = analyzeGraphForCodegen(elseGraph); | 1428 int elseKind = analyzeGraphForCodegen(elseGraph); |
| 1405 | 1429 |
| 1406 void visitWithoutIndent(HStatementInformation toVisit) { | 1430 void visitWithoutIndent(HStatementInformation toVisit) { |
| 1407 int oldIndent = indent; | 1431 generatingInlineStatement = true; |
| 1408 indent = 0; | 1432 visitSubGraph(new SubGraph(toVisit.start, toVisit.end)); |
| 1409 generateStatements(toVisit); | |
| 1410 indent = oldIndent; | |
| 1411 } | 1433 } |
| 1412 | 1434 |
| 1413 void visitWithIndent(HStatementInformation toVisit) { | 1435 void visitWithIndent(HStatementInformation toVisit) { |
| 1414 buffer.add('{\n'); | 1436 buffer.add('{\n'); |
| 1415 indent++; | 1437 indent++; |
| 1416 generateStatements(toVisit); | 1438 visitSubGraph(new SubGraph(toVisit.start, toVisit.end)); |
| 1417 indent--; | 1439 indent--; |
| 1418 addIndented('}'); | 1440 addIndented('}'); |
| 1419 } | 1441 } |
| 1420 | 1442 |
| 1421 void emitIf() { | 1443 void emitIf() { |
| 1422 addIndented('if ('); | 1444 addIndented('if ('); |
| 1423 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); | 1445 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); |
| 1424 buffer.add(') '); | 1446 buffer.add(') '); |
| 1425 } | 1447 } |
| 1426 | 1448 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1450 use(node.inputs[0], JSPrecedence.STATEMENT_PRECEDENCE); | 1472 use(node.inputs[0], JSPrecedence.STATEMENT_PRECEDENCE); |
| 1451 buffer.add(';\n'); | 1473 buffer.add(';\n'); |
| 1452 } | 1474 } |
| 1453 break; | 1475 break; |
| 1454 | 1476 |
| 1455 case ONE_EXPRESSION: | 1477 case ONE_EXPRESSION: |
| 1456 generateAnd(elseGraph, () { generateNot(node.inputs[0]); }); | 1478 generateAnd(elseGraph, () { generateNot(node.inputs[0]); }); |
| 1457 break; | 1479 break; |
| 1458 | 1480 |
| 1459 case ONE_STATEMENT: | 1481 case ONE_STATEMENT: |
| 1482 case IF_STATEMENT: | |
| 1460 addIndented('if ('); | 1483 addIndented('if ('); |
| 1461 generateNot(node.inputs[0]); | 1484 generateNot(node.inputs[0]); |
| 1462 buffer.add(') '); | 1485 buffer.add(') '); |
| 1463 visitWithoutIndent(elseGraph); | 1486 visitWithoutIndent(elseGraph); |
| 1464 break; | 1487 break; |
| 1465 | 1488 |
| 1466 case MULTIPLE_STATEMENTS: | 1489 case MULTIPLE_STATEMENTS: |
| 1467 addIndented('if ('); | 1490 addIndented('if ('); |
| 1468 generateNot(node.inputs[0]); | 1491 generateNot(node.inputs[0]); |
| 1469 buffer.add(') '); | 1492 buffer.add(') '); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1482 int precedence = operatorPrecedence.left; | 1505 int precedence = operatorPrecedence.left; |
| 1483 generateAnd(thenGraph, () { use(node.inputs[0], precedence); }); | 1506 generateAnd(thenGraph, () { use(node.inputs[0], precedence); }); |
| 1484 } else { | 1507 } else { |
| 1485 emitIf(); | 1508 emitIf(); |
| 1486 visitWithoutIndent(thenGraph); | 1509 visitWithoutIndent(thenGraph); |
| 1487 } | 1510 } |
| 1488 break; | 1511 break; |
| 1489 | 1512 |
| 1490 case ONE_EXPRESSION: | 1513 case ONE_EXPRESSION: |
| 1491 case ONE_STATEMENT: | 1514 case ONE_STATEMENT: |
| 1515 case IF_STATEMENT: | |
| 1492 // TODO(ngeoffray): Generate a conditional. | 1516 // TODO(ngeoffray): Generate a conditional. |
| 1493 emitIf(); | 1517 emitIf(); |
| 1494 visitWithoutIndent(thenGraph); | 1518 visitWithoutIndent(thenGraph); |
| 1495 if (thenGraphHasSuccessor) { | 1519 if (thenGraphHasSuccessor) { |
| 1496 addIndented('else '); | 1520 addIndented('else '); |
| 1497 visitWithoutIndent(elseGraph); | 1521 visitWithoutIndent(elseGraph); |
| 1498 } else { | 1522 } else { |
| 1499 generateStatements(elseGraph); | 1523 generateStatements(elseGraph); |
| 1500 } | 1524 } |
| 1501 break; | 1525 break; |
| 1502 | 1526 |
| 1503 case MULTIPLE_STATEMENTS: | 1527 case MULTIPLE_STATEMENTS: |
| 1504 emitIf(); | 1528 emitIf(); |
| 1505 visitWithoutIndent(thenGraph); | 1529 visitWithoutIndent(thenGraph); |
| 1506 if (thenGraphHasSuccessor) { | 1530 if (thenGraphHasSuccessor) { |
| 1507 addIndented('else '); | 1531 addIndented('else '); |
| 1508 visitWithIndent(elseGraph); | 1532 visitWithIndent(elseGraph); |
| 1509 buffer.add('\n'); | 1533 buffer.add('\n'); |
| 1510 } else { | 1534 } else { |
| 1511 generateStatements(elseGraph); | 1535 generateStatements(elseGraph); |
| 1512 } | 1536 } |
| 1513 break; | 1537 break; |
| 1514 } | 1538 } |
| 1515 break; | 1539 break; |
| 1516 | 1540 |
| 1517 case MULTIPLE_STATEMENTS: | 1541 case MULTIPLE_STATEMENTS: |
| 1542 case IF_STATEMENT: | |
| 1518 emitIf(); | 1543 emitIf(); |
| 1519 visitWithIndent(thenGraph); | 1544 visitWithIndent(thenGraph); |
| 1520 | 1545 |
| 1521 switch (elseKind) { | 1546 switch (elseKind) { |
| 1522 case EMPTY: | 1547 case EMPTY: |
| 1523 buffer.add('\n'); | 1548 buffer.add('\n'); |
| 1524 break; | 1549 break; |
| 1525 | 1550 |
| 1526 case ONE_EXPRESSION: | 1551 case ONE_EXPRESSION: |
| 1527 case ONE_STATEMENT: | 1552 case ONE_STATEMENT: |
| 1553 case IF_STATEMENT: | |
| 1528 if (thenGraphHasSuccessor) { | 1554 if (thenGraphHasSuccessor) { |
| 1529 buffer.add(' else '); | 1555 buffer.add(' else '); |
| 1530 visitWithoutIndent(elseGraph); | 1556 visitWithoutIndent(elseGraph); |
| 1531 } else { | 1557 } else { |
| 1532 buffer.add('\n'); | 1558 buffer.add('\n'); |
| 1533 generateStatements(elseGraph); | 1559 generateStatements(elseGraph); |
| 1534 } | 1560 } |
| 1535 break; | 1561 break; |
| 1536 | 1562 |
| 1537 case MULTIPLE_STATEMENTS: | 1563 case MULTIPLE_STATEMENTS: |
| 1538 if (thenGraphHasSuccessor) { | 1564 if (thenGraphHasSuccessor) { |
| 1539 buffer.add(' else '); | 1565 buffer.add(' else '); |
| 1540 visitWithIndent(elseGraph); | 1566 visitWithIndent(elseGraph); |
| 1541 buffer.add('\n'); | 1567 buffer.add('\n'); |
| 1542 } else { | 1568 } else { |
| 1543 buffer.add('\n'); | 1569 buffer.add('\n'); |
| 1544 generateStatements(elseGraph); | 1570 generateStatements(elseGraph); |
| 1545 } | 1571 } |
| 1546 break; | 1572 break; |
| 1547 } | 1573 } |
| 1548 break; | 1574 break; |
| 1549 } | 1575 } |
| 1550 } | 1576 } |
| 1551 | 1577 |
| 1552 | |
| 1553 visitIf(HIf node) { | 1578 visitIf(HIf node) { |
| 1554 if (tryControlFlowOperation(node)) return; | 1579 if (tryControlFlowOperation(node)) return; |
| 1555 | 1580 |
| 1556 if (subGraph !== null && node.block === subGraph.end) { | 1581 if (subGraph !== null && node.block === subGraph.end) { |
| 1557 if (isGeneratingExpression()) { | 1582 if (isGeneratingExpression()) { |
| 1558 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); | 1583 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); |
| 1559 } | 1584 } |
| 1560 return; | 1585 return; |
| 1561 } | 1586 } |
| 1562 | 1587 |
| 1563 HInstruction condition = node.inputs[0]; | 1588 HInstruction condition = node.inputs[0]; |
| 1564 HIfBlockInformation info = node.blockInformation.body; | 1589 HIfBlockInformation info = node.blockInformation.body; |
| 1565 | 1590 |
| 1566 if (condition.isConstant()) { | 1591 if (condition.isConstant()) { |
| 1567 HConstant constant = condition; | 1592 HConstant constant = condition; |
| 1568 if (constant.constant.isTrue()) { | 1593 if (constant.constant.isTrue()) { |
| 1569 generateStatements(info.thenGraph); | 1594 generateStatements(info.thenGraph); |
| 1595 int thenKind = analyzeGraphForCodegen(info.thenGraph); | |
| 1596 if (thenKind == EMPTY && generatingInlineStatement) { | |
| 1597 // If we are generating an inline statement, but that | |
| 1598 // statement is actually empty, still emit a ';' (one | |
| 1599 // statement) to emit valid syntax (e.g. 'else;'). | |
| 1600 generatingInlineStatement = false; | |
| 1601 buffer.add(';\n'); | |
| 1602 } | |
| 1570 } else { | 1603 } else { |
| 1571 generateStatements(info.elseGraph); | 1604 generateStatements(info.elseGraph); |
| 1605 int elseKind = analyzeGraphForCodegen(info.elseGraph); | |
| 1606 if (elseKind == EMPTY && generatingInlineStatement) { | |
| 1607 generatingInlineStatement = false; | |
| 1608 buffer.add(';\n'); | |
| 1609 } | |
| 1572 } | 1610 } |
| 1573 } else { | 1611 } else { |
| 1574 generateIf(node, info); | 1612 generateIf(node, info); |
| 1575 } | 1613 } |
| 1576 | 1614 |
| 1577 HBasicBlock joinBlock = node.joinBlock; | 1615 HBasicBlock joinBlock = node.joinBlock; |
| 1578 if (joinBlock !== null && joinBlock.dominator !== node.block) { | 1616 if (joinBlock !== null && joinBlock.dominator !== node.block) { |
| 1579 // The join block is dominated by a block in one of the branches. | 1617 // The join block is dominated by a block in one of the branches. |
| 1580 // The subgraph traversal never reached it, so we visit it here | 1618 // The subgraph traversal never reached it, so we visit it here |
| 1581 // instead. | 1619 // instead. |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2022 buffer.add('throw '); | 2060 buffer.add('throw '); |
| 2023 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE); | 2061 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE); |
| 2024 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 2062 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 2025 buffer.add(compiler.namer.isolateAccess(helper)); | 2063 buffer.add(compiler.namer.isolateAccess(helper)); |
| 2026 visitArguments([null, argument]); | 2064 visitArguments([null, argument]); |
| 2027 endExpression(JSPrecedence.CALL_PRECEDENCE); | 2065 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 2028 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE); | 2066 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE); |
| 2029 } | 2067 } |
| 2030 | 2068 |
| 2031 void addIndentation() { | 2069 void addIndentation() { |
| 2032 for (int i = 0; i < indent; i++) { | 2070 if (generatingInlineStatement) { |
|
Lasse Reichstein Nielsen
2012/06/19 09:10:44
I understand the variable now.
Maybe it could be c
| |
| 2033 buffer.add(' '); | 2071 generatingInlineStatement = false; |
| 2072 } else { | |
| 2073 for (int i = 0; i < indent; i++) { | |
| 2074 buffer.add(' '); | |
| 2075 } | |
| 2034 } | 2076 } |
| 2035 } | 2077 } |
| 2036 | 2078 |
| 2037 void addIndented(String text) { | 2079 void addIndented(String text) { |
| 2038 addIndentation(); | 2080 addIndentation(); |
| 2039 buffer.add(text); | 2081 buffer.add(text); |
| 2040 } | 2082 } |
| 2041 | 2083 |
| 2042 void visitSwitch(HSwitch node) { | 2084 void visitSwitch(HSwitch node) { |
| 2043 // Switches are handled using [visitSwitchInfo]. | 2085 // Switches are handled using [visitSwitchInfo]. |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2908 startBailoutSwitch(); | 2950 startBailoutSwitch(); |
| 2909 } | 2951 } |
| 2910 } | 2952 } |
| 2911 | 2953 |
| 2912 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2954 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2913 if (labeledBlockInfo.body.start.hasGuards()) { | 2955 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2914 endBailoutSwitch(); | 2956 endBailoutSwitch(); |
| 2915 } | 2957 } |
| 2916 } | 2958 } |
| 2917 } | 2959 } |
| OLD | NEW |