Method from com.sun.tools.javac.jvm.Code$State Detail: |
void dump() {
dump(-1);
}
|
void dump(int pc) {
System.err.print("stackMap for " + meth.owner + "." + meth);
if (pc == -1)
System.out.println();
else
System.out.println(" at " + pc);
System.err.println(" stack (from bottom):");
for (int i=0; i< stacksize; i++)
System.err.println(" " + i + ": " + stack[i]);
int lastLocal = 0;
for (int i=max_locals-1; i >=0; i--) {
if (defined.isMember(i)) {
lastLocal = i;
break;
}
}
if (lastLocal >= 0)
System.err.println(" locals:");
for (int i=0; i< =lastLocal; i++) {
System.err.print(" " + i + ": ");
if (defined.isMember(i)) {
LocalVar var = lvar[i];
if (var == null) {
System.err.println("(none)");
} else if (var.sym == null)
System.err.println("UNKNOWN!");
else
System.err.println("" + var.sym + " of type " +
var.sym.erasure(types));
} else {
System.err.println("undefined");
}
}
if (nlocks != 0) {
System.err.print(" locks:");
for (int i=0; i< nlocks; i++) {
System.err.print(" " + locks[i]);
}
System.err.println();
}
}
|
State dup() {
try {
State state = (State)super.clone();
state.defined = defined.dup();
state.stack = stack.clone();
if (locks != null) state.locks = locks.clone();
if (debugCode) {
System.err.println("duping state " + this);
dump();
}
return state;
} catch (CloneNotSupportedException ex) {
throw new AssertionError(ex);
}
}
|
Type error() {
throw new AssertionError("inconsistent stack types at join point");
}
|
void forceStackTop(Type t) {
if (!alive) return;
switch (t.tag) {
case CLASS:
case ARRAY:
int width = width(t);
Type old = stack[stacksize-width];
Assert.check(types.isSubtype(types.erasure(old),
types.erasure(t)));
stack[stacksize-width] = t;
break;
default:
}
}
Force the top of the stack to be treated as this supertype
of its current type. |
State join(State other) {
defined = defined.andSet(other.defined);
Assert.check(stacksize == other.stacksize
&& nlocks == other.nlocks);
for (int i=0; i< stacksize; ) {
Type t = stack[i];
Type tother = other.stack[i];
Type result =
t==tother ? t :
types.isSubtype(t, tother) ? tother :
types.isSubtype(tother, t) ? t :
error();
int w = width(result);
stack[i] = result;
if (w == 2) Assert.checkNull(stack[i+1]);
i += w;
}
return this;
}
|
void lock(int register) {
if (locks == null) {
locks = new int[20];
} else if (locks.length == nlocks) {
int[] newLocks = new int[locks.length < < 1];
System.arraycopy(locks, 0, newLocks, 0, locks.length);
locks = newLocks;
}
locks[nlocks] = register;
nlocks++;
}
|
void markInitialized(UninitializedType old) {
Type newtype = old.initializedType();
for (int i=0; i< stacksize; i++)
if (stack[i] == old) stack[i] = newtype;
for (int i=0; i< lvar.length; i++) {
LocalVar lv = lvar[i];
if (lv != null && lv.sym.type == old) {
VarSymbol sym = lv.sym;
sym = sym.clone(sym.owner);
sym.type = newtype;
LocalVar newlv = lvar[i] = new LocalVar(sym);
// should the following be initialized to cp?
newlv.start_pc = lv.start_pc;
}
}
}
|
Type peek() {
return stack[stacksize-1];
}
|
void pop(int n) {
if (debugCode) System.err.println(" popping " + n);
while (n > 0) {
stack[--stacksize] = null;
n--;
}
}
|
void pop(Type t) {
pop(width(t));
}
|
Type pop1() {
if (debugCode) System.err.println(" popping " + 1);
stacksize--;
Type result = stack[stacksize];
stack[stacksize] = null;
Assert.check(result != null && width(result) == 1);
return result;
}
|
Type pop2() {
if (debugCode) System.err.println(" popping " + 2);
stacksize -= 2;
Type result = stack[stacksize];
stack[stacksize] = null;
Assert.check(stack[stacksize+1] == null
&& result != null && width(result) == 2);
return result;
}
|
void push(Type t) {
if (debugCode) System.err.println(" pushing " + t);
switch (t.tag) {
case TypeTags.VOID:
return;
case TypeTags.BYTE:
case TypeTags.CHAR:
case TypeTags.SHORT:
case TypeTags.BOOLEAN:
t = syms.intType;
break;
default:
break;
}
if (stacksize+2 >= stack.length) {
Type[] newstack = new Type[2*stack.length];
System.arraycopy(stack, 0, newstack, 0, stack.length);
stack = newstack;
}
stack[stacksize++] = t;
switch (width(t)) {
case 1:
break;
case 2:
stack[stacksize++] = null;
break;
default:
throw new AssertionError(t);
}
if (stacksize > max_stack)
max_stack = stacksize;
}
|
void unlock(int register) {
nlocks--;
Assert.check(locks[nlocks] == register);
locks[nlocks] = -1;
}
|