Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java @ 11442:2868b55001d4
Truffle-DSL: fixed specializationg grouping failed with guards using base types.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 28 Aug 2013 01:45:13 +0200 |
parents | efe58aa92f86 |
children | b33783cbd8ce |
comparison
equal
deleted
inserted
replaced
11441:fc509b6fbfdf | 11442:2868b55001d4 |
---|---|
1543 private boolean isReachableGroup(SpecializationGroup group, int ifCount, boolean checkMinimumState) { | 1543 private boolean isReachableGroup(SpecializationGroup group, int ifCount, boolean checkMinimumState) { |
1544 if (ifCount != 0) { | 1544 if (ifCount != 0) { |
1545 return true; | 1545 return true; |
1546 } | 1546 } |
1547 SpecializationGroup previous = group.getPreviousGroup(); | 1547 SpecializationGroup previous = group.getPreviousGroup(); |
1548 if (previous == null || previous.getElseConnectableGuard() == null) { | 1548 if (previous == null || previous.getElseConnectableGuards().isEmpty()) { |
1549 return true; | 1549 return true; |
1550 } | 1550 } |
1551 | 1551 |
1552 /* | 1552 /* |
1553 * Hacky else case. In this case the specialization is not reachable due to previous | 1553 * Hacky else case. In this case the specialization is not reachable due to previous |
1569 CodeTreeBuilder guardsCastBuilder = builder.create(); | 1569 CodeTreeBuilder guardsCastBuilder = builder.create(); |
1570 | 1570 |
1571 String guardsAnd = ""; | 1571 String guardsAnd = ""; |
1572 String guardsCastAnd = ""; | 1572 String guardsCastAnd = ""; |
1573 | 1573 |
1574 GuardData elseGuard = group.getElseConnectableGuard(); | 1574 List<GuardData> elseGuards = group.getElseConnectableGuards(); |
1575 | 1575 |
1576 boolean minimumState = checkMinimumState; | 1576 boolean minimumState = checkMinimumState; |
1577 if (minimumState) { | 1577 if (minimumState) { |
1578 int groupMaxIndex = group.getMaxSpecializationIndex(); | 1578 int groupMaxIndex = group.getMaxSpecializationIndex(); |
1579 | 1579 |
1641 castBuilder.tree(cast); | 1641 castBuilder.tree(cast); |
1642 } | 1642 } |
1643 } | 1643 } |
1644 | 1644 |
1645 for (GuardData guard : group.getGuards()) { | 1645 for (GuardData guard : group.getGuards()) { |
1646 if (elseGuard == guard) { | 1646 if (elseGuards.contains(guard)) { |
1647 continue; | 1647 continue; |
1648 } | 1648 } |
1649 | 1649 |
1650 if (needsTypeGuard(source, group, guard)) { | 1650 if (needsTypeGuard(source, group, guard)) { |
1651 guardsCastBuilder.tree(createMethodGuard(builder, guardsCastAnd, source, guard)); | 1651 guardsCastBuilder.tree(createMethodGuard(builder, guardsCastAnd, source, guard)); |
1654 guardsBuilder.tree(createMethodGuard(builder, guardsAnd, source, guard)); | 1654 guardsBuilder.tree(createMethodGuard(builder, guardsAnd, source, guard)); |
1655 guardsAnd = " && "; | 1655 guardsAnd = " && "; |
1656 } | 1656 } |
1657 } | 1657 } |
1658 | 1658 |
1659 int ifCount = startGuardIf(builder, guardsBuilder, 0, elseGuard); | 1659 int ifCount = startGuardIf(builder, guardsBuilder, 0, elseGuards); |
1660 builder.tree(castBuilder.getRoot()); | 1660 builder.tree(castBuilder.getRoot()); |
1661 ifCount = startGuardIf(builder, guardsCastBuilder, ifCount, elseGuard); | 1661 ifCount = startGuardIf(builder, guardsCastBuilder, ifCount, elseGuards); |
1662 return ifCount; | 1662 return ifCount; |
1663 } | 1663 } |
1664 | 1664 |
1665 private int startGuardIf(CodeTreeBuilder builder, CodeTreeBuilder conditionBuilder, int ifCount, GuardData elseGuard) { | 1665 private int startGuardIf(CodeTreeBuilder builder, CodeTreeBuilder conditionBuilder, int ifCount, List<GuardData> elseGuard) { |
1666 int newIfCount = ifCount; | 1666 int newIfCount = ifCount; |
1667 | 1667 |
1668 if (!conditionBuilder.isEmpty()) { | 1668 if (!conditionBuilder.isEmpty()) { |
1669 if (ifCount == 0 && elseGuard != null) { | 1669 if (ifCount == 0 && !elseGuard.isEmpty()) { |
1670 builder.startElseIf(); | 1670 builder.startElseIf(); |
1671 } else { | 1671 } else { |
1672 builder.startIf(); | 1672 builder.startIf(); |
1673 } | 1673 } |
1674 builder.tree(conditionBuilder.getRoot()); | 1674 builder.tree(conditionBuilder.getRoot()); |
1675 builder.end().startBlock(); | 1675 builder.end().startBlock(); |
1676 newIfCount++; | 1676 newIfCount++; |
1677 } else if (ifCount == 0 && elseGuard != null) { | 1677 } else if (ifCount == 0 && !elseGuard.isEmpty()) { |
1678 builder.startElseBlock(); | 1678 builder.startElseBlock(); |
1679 newIfCount++; | 1679 newIfCount++; |
1680 } | 1680 } |
1681 return newIfCount; | 1681 return newIfCount; |
1682 } | 1682 } |