dfa: don't multiply eq classes until really needed

This commit is contained in:
peter
2013-09-15 22:48:34 +04:00
parent c2f28d8e20
commit 0f1494e02a
2 changed files with 16 additions and 11 deletions
@@ -511,13 +511,12 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
@Override
public boolean isNull(DfaValue dfaValue) {
if (dfaValue instanceof DfaTypeValue && ((DfaTypeValue)dfaValue).isNotNull()) return false;
if (dfaValue instanceof DfaConstValue) return ((DfaConstValue)dfaValue).getConstant() == null;
if (dfaValue instanceof DfaVariableValue || dfaValue instanceof DfaConstValue) {
DfaConstValue dfaNull = myFactory.getConstFactory().getNull();
Integer c1Index = getOrCreateEqClassIndex(dfaValue);
Integer c2Index = getOrCreateEqClassIndex(dfaNull);
return c1Index != null && c1Index.equals(c2Index);
if (dfaValue instanceof DfaVariableValue) {
int c1Index = getEqClassIndex(dfaValue);
return c1Index >= 0 && c1Index == getEqClassIndex(myFactory.getConstFactory().getNull());
}
return false;
@@ -530,16 +529,16 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
}
DfaConstValue dfaNull = myFactory.getConstFactory().getNull();
Integer c1Index = getOrCreateEqClassIndex(dfaVar);
Integer c2Index = getOrCreateEqClassIndex(dfaNull);
if (c1Index == null || c2Index == null) {
int c1Index = getEqClassIndex(dfaVar);
int c2Index = getEqClassIndex(dfaNull);
if (c1Index < 0 || c2Index < 0) {
return false;
}
long[] pairs = myDistinctClasses.toArray();
for (long pair : pairs) {
if (c1Index.equals(low(pair)) && c2Index.equals(high(pair)) ||
c1Index.equals(high(pair)) && c2Index.equals(low(pair))) {
if (c1Index == low(pair) && c2Index == high(pair) ||
c1Index == high(pair) && c2Index == low(pair)) {
return true;
}
}
@@ -384,4 +384,10 @@
<description>Condition &lt;code&gt;i&lt;/code&gt; is always &lt;code&gt;true&lt;/code&gt; when reached</description>
</problem>
<problem>
<file>Test.java</file>
<line>62</line>
<module>testUnboxingNPE_7454908424878253728</module>
<description>Switch label&lt;code&gt;case 0:&lt;/code&gt; is unreachable</description>
</problem>
</problems>