int numLive = 0;
ArrayList<Value> set = new ArrayList<Value>(10);
for (int i = 0; i < f.getMaxLocals(); i++) {
if (u.isLiveIn(i)) {
numLive++;
Value v = f.getLocal(i);
if (!set.contains(v)) set.add(v);
}
}
nStack = f.getStackLen() - nStack;
for (int i = 0; i < nStack; i++) {
Value v = f.getStack(i);
if (!set.contains(v)) set.add(v);
}
char[] sig = new char[set.size()];
// create canonical sig. Convert types to one of 'O', 'I', 'F', 'L', 'D' and
// put in sorted order
// Also count non constants while we are iterating anyway.
for (int i = 0; i < set.size(); i++) {
Value v = set.get(i);
char c = v.getTypeDesc().charAt(0);
switch (c) {
case 'L': case '[': case 'N':
c = 'O'; break;
case 'I': case 'B': case 'S': case 'Z': case 'C':
c = 'I'; break;
case 'J':
c = 'J'; break;
case 'F':
c = 'F'; break;
case 'U':
default: {
c = 'U';
System.err.println("***************************************");
System.err.println("Undefined/unrecognized value " + v);
System.err.println("BasicBlock:\n" + bb);
break;
}
}
sig[i] = c;
if (v.getConstVal() == Value.NO_VAL) {
numNonConstants++;
}
}
Arrays.sort(sig);
numLive += nStack;