public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo) { if (DEBUG) { System.out.println("Exception:"); } // The stack size when entering the exception handler is always 1. stackSize = 1; // Evaluate the instruction block starting at the entry point of the // exception handler. evaluateInstructionBlock(clazz, method, codeAttribute, exceptionInfo.u2handlerPC); }
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { // Compute the stack sizes. stackSizeComputer.visitCodeAttribute(clazz, method, codeAttribute); // Update the maximum stack size. codeAttribute.u2maxStack = stackSizeComputer.getMaxStackSize(); } }
/** * Marks the given method if the stack before the given instruction offset * has a size larger than the given size. */ private void markReturnWithNonEmptyStack(Method method, int offset, int stackSize) { if (!stackSizeComputer.isReachable(offset) || stackSizeComputer.getStackSizeBefore(offset) > stackSize) { setReturnsWithNonEmptyStack(method); } }
stackSizeComputer.isReachable(offset) && stackSizeComputer.getStackSizeAfter(offset) == 0;
stackSizeComputer.visitCodeAttribute(clazz, method, codeAttribute); if (stackSizeComputer.getStackSizeAfter(nextOffset) == 0)
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { // DEBUG = // clazz.getName().equals("abc/Def") && // method.getName(clazz).equals("abc"); // TODO: Remove this when the code has stabilized. // Catch any unexpected exceptions from the actual visiting method. try { // Process the code. visitCodeAttribute0(clazz, method, codeAttribute); } catch (RuntimeException ex) { System.err.println("Unexpected error while computing stack sizes:"); System.err.println(" Class = ["+clazz.getName()+"]"); System.err.println(" Method = ["+method.getName(clazz)+method.getDescriptor(clazz)+"]"); System.err.println(" Exception = ["+ex.getClass().getName()+"] ("+ex.getMessage()+")"); if (DEBUG) { method.accept(clazz, new ClassPrinter()); } throw ex; } }
inlinedAny = false; codeAttributeComposer.reset(); stackSizeComputer.visitCodeAttribute(clazz, method, codeAttribute);
stackSizeComputer.isReachable(offset) && stackSizeComputer.getStackSize(offset) == 0;
StackSizeComputer stackSizeComputer = new StackSizeComputer();
stackSizeComputer.isReachable(offset) && stackSizeComputer.getStackSizeAfter(offset) == 0;
stackSizeComputer.visitCodeAttribute(clazz, method, codeAttribute); if (stackSizeComputer.getStackSizeAfter(nextOffset) == 0)
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { // DEBUG = // clazz.getName().equals("abc/Def") && // method.getName(clazz).equals("abc"); // TODO: Remove this when the code has stabilized. // Catch any unexpected exceptions from the actual visiting method. try { // Process the code. visitCodeAttribute0(clazz, method, codeAttribute); } catch (RuntimeException ex) { System.err.println("Unexpected error while computing stack sizes:"); System.err.println(" Class = ["+clazz.getName()+"]"); System.err.println(" Method = ["+method.getName(clazz)+method.getDescriptor(clazz)+"]"); System.err.println(" Exception = ["+ex.getClass().getName()+"] ("+ex.getMessage()+")"); if (DEBUG) { method.accept(clazz, new ClassPrinter()); } throw ex; } }
inlinedAny = false; codeAttributeComposer.reset(); stackSizeComputer.visitCodeAttribute(clazz, method, codeAttribute);
StackSizeComputer stackSizeComputer = new StackSizeComputer();
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { // Compute the stack sizes. stackSizeComputer.visitCodeAttribute(clazz, method, codeAttribute); // Update the maximum stack size. codeAttribute.u2maxStack = stackSizeComputer.getMaxStackSize(); } }
public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo) { if (DEBUG) { System.out.println("Exception:"); } // The stack size when entering the exception handler is always 1. stackSize = 1; // Evaluate the instruction block starting at the entry point of the // exception handler. evaluateInstructionBlock(clazz, method, codeAttribute, exceptionInfo.u2handlerPC); }
/** * Marks the given method if the stack before the given instruction offset * has a size larger than the given size. */ private void markReturnWithNonEmptyStack(Method method, int offset, int stackSize) { if (!stackSizeComputer.isReachable(offset) || stackSizeComputer.getStackSizeBefore(offset) > stackSize) { setReturnsWithNonEmptyStack(method); } }
stackSizeComputer.isReachable(offset) && stackSizeComputer.getStackSizeAfter(offset) == 0;
stackSizeComputer.visitCodeAttribute(clazz, method, codeAttribute); if (stackSizeComputer.getStackSizeAfter(nextOffset) == 0)
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { // DEBUG = // clazz.getName().equals("abc/Def") && // method.getName(clazz).equals("abc"); // TODO: Remove this when the code has stabilized. // Catch any unexpected exceptions from the actual visiting method. try { // Process the code. visitCodeAttribute0(clazz, method, codeAttribute); } catch (RuntimeException ex) { System.err.println("Unexpected error while computing stack sizes:"); System.err.println(" Class = ["+clazz.getName()+"]"); System.err.println(" Method = ["+method.getName(clazz)+method.getDescriptor(clazz)+"]"); System.err.println(" Exception = ["+ex.getClass().getName()+"] ("+ex.getMessage()+")"); if (DEBUG) { method.accept(clazz, new ClassPrinter()); } throw ex; } }