/** * Computes the maximum stack size and sets <code>max_stack</code> * to the computed size. * * @throws BadBytecode if this method fails in computing. * @return the newly computed value of <code>max_stack</code> */ public int computeMaxStack() throws BadBytecode { maxStack = new CodeAnalyzer(this).computeMaxStack(); return maxStack; }
|| opcode == IFNULL || opcode == IFNONNULL) { int target = index + ci.s16bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); case GOTO : target = index + ci.s16bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); return true; case GOTO_W : target = index + ci.s32bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); return true; case JSR : checkTarget(index, target, codeLength, stack, stackDepth); index2 = (index & ~3) + 4; target = index + ci.s32bitAt(index2); checkTarget(index, target, codeLength, stack, stackDepth); if (opcode == LOOKUPSWITCH) { int npairs = ci.s32bitAt(index2 + 4); for (int i = 0; i < npairs; ++i) { target = index + ci.s32bitAt(index2); checkTarget(index, target, codeLength, stack, stackDepth); index2 += 8; for (int i = 0; i < n; ++i) {
switch (op) { case GETFIELD : stack += getFieldSize(ci, index) - 1; break; case PUTFIELD : stack -= getFieldSize(ci, index) + 1; break; case GETSTATIC : stack += getFieldSize(ci, index); break; case PUTSTATIC : stack -= getFieldSize(ci, index); break; case INVOKEVIRTUAL :
private void visitBytecode(CodeIterator ci, int[] stack, int index) throws BadBytecode { int codeLength = stack.length; ci.move(index); int stackDepth = -stack[index]; int[] jsrDepth = new int[1]; jsrDepth[0] = -1; while (ci.hasNext()) { index = ci.next(); stack[index] = stackDepth; int op = ci.byteAt(index); stackDepth = visitInst(op, ci, index, stackDepth); if (stackDepth < 1) throw new BadBytecode("stack underflow at " + index); if (processBranch(op, ci, index, codeLength, stack, stackDepth, jsrDepth)) break; if (isEnd(op)) // return, ireturn, athrow, ... break; if (op == JSR || op == JSR_W) --stackDepth; } }
public int computeMaxStack() throws BadBytecode { /* d = stack[i] * d == 0: not visited * d > 0: the depth is d - 1 after executing the bytecode at i. * d < 0: not visited. the initial depth (before execution) is 1 - d. */ CodeIterator ci = codeAttr.iterator(); int length = ci.getCodeLength(); int[] stack = new int[length]; constPool = codeAttr.getConstPool(); initStack(stack, codeAttr); boolean repeat; do { repeat = false; for (int i = 0; i < length; ++i) if (stack[i] < 0) { repeat = true; visitBytecode(ci, stack, i); } } while (repeat); int maxStack = 1; for (int i = 0; i < length; ++i) if (stack[i] > maxStack) maxStack = stack[i]; return maxStack - 1; // the base is 1. }
private void visitBytecode(CodeIterator ci, int[] stack, int index) throws BadBytecode { int codeLength = stack.length; ci.move(index); int stackDepth = -stack[index]; int[] jsrDepth = new int[1]; jsrDepth[0] = -1; while (ci.hasNext()) { index = ci.next(); stack[index] = stackDepth; int op = ci.byteAt(index); stackDepth = visitInst(op, ci, index, stackDepth); if (stackDepth < 1) throw new BadBytecode("stack underflow at " + index); if (processBranch(op, ci, index, codeLength, stack, stackDepth, jsrDepth)) break; if (isEnd(op)) // return, ireturn, athrow, ... break; if (op == JSR || op == JSR_W) --stackDepth; } }
public int computeMaxStack() throws BadBytecode { /* d = stack[i] * d == 0: not visited * d > 0: the depth is d - 1 after executing the bytecode at i. * d < 0: not visited. the initial depth (before execution) is 1 - d. */ CodeIterator ci = codeAttr.iterator(); int length = ci.getCodeLength(); int[] stack = new int[length]; constPool = codeAttr.getConstPool(); initStack(stack, codeAttr); boolean repeat; do { repeat = false; for (int i = 0; i < length; ++i) if (stack[i] < 0) { repeat = true; visitBytecode(ci, stack, i); } } while (repeat); int maxStack = 1; for (int i = 0; i < length; ++i) if (stack[i] > maxStack) maxStack = stack[i]; return maxStack - 1; // the base is 1. }
private void visitBytecode(CodeIterator ci, int[] stack, int index) throws BadBytecode { int codeLength = stack.length; ci.move(index); int stackDepth = -stack[index]; while (ci.hasNext()) { index = ci.next(); stack[index] = stackDepth; int op = ci.byteAt(index); stackDepth = visitInst(op, ci, index, stackDepth); if (stackDepth < 1) throw new BadBytecode("stack underflow at " + index); if (processBranch(op, ci, index, codeLength, stack, stackDepth)) break; if (isEnd(op)) // return, ireturn, athrow, ... break; if (op == JSR || op == JSR_W) --stackDepth; } }
/** * Computes the maximum stack size and sets <code>max_stack</code> * to the computed size. * * @throws BadBytecode if this method fails in computing. * @return the newly computed value of <code>max_stack</code> */ public int computeMaxStack() throws BadBytecode { maxStack = new CodeAnalyzer(this).computeMaxStack(); return maxStack; }
public int computeMaxStack() throws BadBytecode { /* d = stack[i] * d == 0: not visited * d > 0: the depth is d - 1 after executing the bytecode at i. * d < 0: not visited. the initial depth (before execution) is 1 - d. */ CodeIterator ci = codeAttr.iterator(); int length = ci.getCodeLength(); int[] stack = new int[length]; constPool = codeAttr.getConstPool(); initStack(stack, codeAttr); boolean repeat; do { repeat = false; for (int i = 0; i < length; ++i) if (stack[i] < 0) { repeat = true; visitBytecode(ci, stack, i); } } while (repeat); int maxStack = 1; for (int i = 0; i < length; ++i) if (stack[i] > maxStack) maxStack = stack[i]; return maxStack - 1; // the base is 1. }
switch (op) { case GETFIELD : stack += getFieldSize(ci, index) - 1; break; case PUTFIELD : stack -= getFieldSize(ci, index) + 1; break; case GETSTATIC : stack += getFieldSize(ci, index); break; case PUTSTATIC : stack -= getFieldSize(ci, index); break; case INVOKEVIRTUAL :
|| opcode == IFNULL || opcode == IFNONNULL) { int target = index + ci.s16bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); case GOTO : target = index + ci.s16bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); return true; case GOTO_W : target = index + ci.s32bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); return true; case JSR : checkTarget(index, target, codeLength, stack, stackDepth); index2 = (index & ~3) + 4; target = index + ci.s32bitAt(index2); checkTarget(index, target, codeLength, stack, stackDepth); if (opcode == LOOKUPSWITCH) { int npairs = ci.s32bitAt(index2 + 4); for (int i = 0; i < npairs; ++i) { target = index + ci.s32bitAt(index2); checkTarget(index, target, codeLength, stack, stackDepth); index2 += 8; for (int i = 0; i < n; ++i) {
private void visitBytecode(CodeIterator ci, int[] stack, int index) throws BadBytecode { int codeLength = stack.length; ci.move(index); int stackDepth = -stack[index]; int[] jsrDepth = new int[1]; jsrDepth[0] = -1; while (ci.hasNext()) { index = ci.next(); stack[index] = stackDepth; int op = ci.byteAt(index); stackDepth = visitInst(op, ci, index, stackDepth); if (stackDepth < 1) throw new BadBytecode("stack underflow at " + index); if (processBranch(op, ci, index, codeLength, stack, stackDepth, jsrDepth)) break; if (isEnd(op)) // return, ireturn, athrow, ... break; if (op == JSR || op == JSR_W) --stackDepth; } }
/** * Computes the maximum stack size and sets <code>max_stack</code> * to the computed size. * * @throws BadBytecode if this method fails in computing. * @return the newly computed value of <code>max_stack</code> */ public int computeMaxStack() throws BadBytecode { maxStack = new CodeAnalyzer(this).computeMaxStack(); return maxStack; }
public int computeMaxStack() throws BadBytecode { /* d = stack[i] * d == 0: not visited * d > 0: the depth is d - 1 after executing the bytecode at i. * d < 0: not visited. the initial depth (before execution) is 1 - d. */ CodeIterator ci = codeAttr.iterator(); int length = ci.getCodeLength(); int[] stack = new int[length]; constPool = codeAttr.getConstPool(); initStack(stack, codeAttr); boolean repeat; do { repeat = false; for (int i = 0; i < length; ++i) if (stack[i] < 0) { repeat = true; visitBytecode(ci, stack, i); } } while (repeat); int maxStack = 1; for (int i = 0; i < length; ++i) if (stack[i] > maxStack) maxStack = stack[i]; return maxStack - 1; // the base is 1. }
switch (op) { case GETFIELD : stack += getFieldSize(ci, index) - 1; break; case PUTFIELD : stack -= getFieldSize(ci, index) + 1; break; case GETSTATIC : stack += getFieldSize(ci, index); break; case PUTSTATIC : stack -= getFieldSize(ci, index); break; case INVOKEVIRTUAL :
|| opcode == IFNULL || opcode == IFNONNULL) { int target = index + ci.s16bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); case GOTO : target = index + ci.s16bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); return true; case GOTO_W : target = index + ci.s32bitAt(index + 1); checkTarget(index, target, codeLength, stack, stackDepth); return true; case JSR : checkTarget(index, target, codeLength, stack, stackDepth); if (stackDepth == 2) // stackDepth is 1 if empty return false; index2 = (index & ~3) + 4; target = index + ci.s32bitAt(index2); checkTarget(index, target, codeLength, stack, stackDepth); if (opcode == LOOKUPSWITCH) { int npairs = ci.s32bitAt(index2 + 4); for (int i = 0; i < npairs; ++i) { target = index + ci.s32bitAt(index2); checkTarget(index, target, codeLength, stack, stackDepth); index2 += 8;
private void visitBytecode(CodeIterator ci, int[] stack, int index) throws BadBytecode { int codeLength = stack.length; ci.move(index); int stackDepth = -stack[index]; int[] jsrDepth = new int[1]; jsrDepth[0] = -1; while (ci.hasNext()) { index = ci.next(); stack[index] = stackDepth; int op = ci.byteAt(index); stackDepth = visitInst(op, ci, index, stackDepth); if (stackDepth < 1) throw new BadBytecode("stack underflow at " + index); if (processBranch(op, ci, index, codeLength, stack, stackDepth, jsrDepth)) break; if (isEnd(op)) // return, ireturn, athrow, ... break; if (op == JSR || op == JSR_W) --stackDepth; } }
/** * Computes the maximum stack size and sets <code>max_stack</code> * to the computed size. * * @throws BadBytecode if this method fails in computing. * @return the newly computed value of <code>max_stack</code> */ public int computeMaxStack() throws BadBytecode { maxStack = new CodeAnalyzer(this).computeMaxStack(); return maxStack; }
public int computeMaxStack() throws BadBytecode { /* d = stack[i] * d == 0: not visited * d > 0: the depth is d - 1 after executing the bytecode at i. * d < 0: not visited. the initial depth (before execution) is 1 - d. */ CodeIterator ci = codeAttr.iterator(); int length = ci.getCodeLength(); int[] stack = new int[length]; constPool = codeAttr.getConstPool(); initStack(stack, codeAttr); boolean repeat; do { repeat = false; for (int i = 0; i < length; ++i) if (stack[i] < 0) { repeat = true; visitBytecode(ci, stack, i); } } while (repeat); int maxStack = 1; for (int i = 0; i < length; ++i) if (stack[i] > maxStack) maxStack = stack[i]; return maxStack - 1; // the base is 1. }