Mercurial > hg > truffle
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/SpecializationGroup.java @ 12401:85dcc7f59c34
Truffle-DSL: fixed incorrect else guard connections for executeAndSpecialize.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 14 Oct 2013 15:44:18 +0200 |
parents | d6a5ab791b0d |
children | 25ecb47a6d0e |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/SpecializationGroup.java Mon Oct 14 14:32:00 2013 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/SpecializationGroup.java Mon Oct 14 15:44:18 2013 +0200 @@ -90,7 +90,14 @@ return null; } - public List<GuardData> getElseConnectableGuards() { + public List<GuardData> findElseConnectableGuards(boolean minimumStateCheck) { + if (minimumStateCheck) { + /* + * TODO investigate further if we really cannot else connect guards if minimum state is + * required + */ + return Collections.emptyList(); + } if (!getTypeGuards().isEmpty() || !getAssumptions().isEmpty()) { return Collections.emptyList(); } @@ -101,7 +108,7 @@ List<GuardData> elseConnectableGuards = new ArrayList<>(); int guardIndex = 0; - while (guardIndex < getGuards().size() && findNegatedGuardInPrevious(getGuards().get(guardIndex)) != null) { + while (guardIndex < getGuards().size() && findNegatedGuardInPrevious(getGuards().get(guardIndex), minimumStateCheck) != null) { elseConnectableGuards.add(getGuards().get(guardIndex)); guardIndex++; } @@ -109,17 +116,18 @@ return elseConnectableGuards; } - private GuardData findNegatedGuardInPrevious(GuardData guard) { + private GuardData findNegatedGuardInPrevious(GuardData guard, boolean minimumStateCheck) { SpecializationGroup previous = this.getPreviousGroup(); if (previous == null) { return null; } - List<GuardData> elseConnectedGuards = previous.getElseConnectableGuards(); + List<GuardData> elseConnectedGuards = previous.findElseConnectableGuards(minimumStateCheck); if (previous == null || previous.getGuards().size() != elseConnectedGuards.size() + 1) { return null; } + /* Guard is else branch can be connected in previous specialization. */ if (elseConnectedGuards.contains(guard)) { return guard; } @@ -341,6 +349,28 @@ return parent.children.get(index - 1); } + public int getUncheckedSpecializationIndex() { + int groupMaxIndex = getMaxSpecializationIndex(); + + int genericIndex = node.getSpecializations().indexOf(node.getGenericSpecialization()); + if (groupMaxIndex >= genericIndex) { + // no minimum state check for an generic index + groupMaxIndex = -1; + } + + if (groupMaxIndex > -1) { + // no minimum state check if already checked by parent group + int parentMaxIndex = -1; + if (getParent() != null) { + parentMaxIndex = getParent().getMaxSpecializationIndex(); + } + if (groupMaxIndex == parentMaxIndex) { + groupMaxIndex = -1; + } + } + return groupMaxIndex; + } + public int getMaxSpecializationIndex() { if (specialization != null) { return specialization.getNode().getSpecializations().indexOf(specialization);