private void scan(int pos, CodeIterator iter, Subroutine sub) throws BadBytecode { // Skip already processed blocks if (done.contains(new Integer(pos))) return; done.add(new Integer(pos)); int old = iter.lookAhead(); iter.move(pos); boolean next; do { pos = iter.next(); next = scanOp(pos, iter, sub) && iter.hasNext(); } while (next); iter.move(old); }
private void scan(int pos, CodeIterator iter, Subroutine sub) throws BadBytecode { // Skip already processed blocks if (done.contains(pos)) return; done.add(pos); int old = iter.lookAhead(); iter.move(pos); boolean next; do { pos = iter.next(); next = scanOp(pos, iter, sub) && iter.hasNext(); } while (next); iter.move(old); }
protected int match2(int pos, CodeIterator iterator) throws BadBytecode { iterator.move(pos); iterator.insert(saveCode); iterator.insert(loadCode); int p = iterator.insertGap(3); iterator.writeByte(INVOKESTATIC, p); iterator.write16bit(newIndex, p + 1); iterator.insert(loadCode); return iterator.next(); }
protected int match2(int pos, CodeIterator iterator) throws BadBytecode { iterator.move(pos); iterator.insert(saveCode); iterator.insert(loadCode); int p = iterator.insertGap(3); iterator.setMark(p); iterator.insert(loadCode); pos = iterator.next(); p = iterator.getMark(); iterator.writeByte(iterator.byteAt(pos), p); iterator.write16bit(iterator.u16bitAt(pos + 1), p + 1); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(newIndex, pos + 1); iterator.move(p); return iterator.next(); } }
protected int match2(int pos, CodeIterator iterator) throws BadBytecode { iterator.move(pos); iterator.insert(saveCode); iterator.insert(loadCode); int p = iterator.insertGap(3); iterator.writeByte(INVOKESTATIC, p); iterator.write16bit(newIndex, p + 1); iterator.insert(loadCode); return iterator.next(); }
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; } }
protected void runEditor(ExprEditor ed, CodeIterator oldIterator) throws CannotCompileException { CodeAttribute codeAttr = oldIterator.get(); int orgLocals = codeAttr.getMaxLocals(); int orgStack = codeAttr.getMaxStack(); int newLocals = locals(); codeAttr.setMaxStack(stack()); codeAttr.setMaxLocals(newLocals); ExprEditor.LoopContext context = new ExprEditor.LoopContext(newLocals); int size = oldIterator.getCodeLength(); int endPos = oldIterator.lookAhead(); oldIterator.move(currentPos); if (ed.doit(thisClass, thisMethod, context, oldIterator, endPos)) edited = true; oldIterator.move(endPos + oldIterator.getCodeLength() - size); codeAttr.setMaxLocals(orgLocals); codeAttr.setMaxStack(orgStack); maxLocals = context.maxLocals; maxStack += context.maxStack; } }
@Override protected int match2(int pos, CodeIterator iterator) throws BadBytecode { iterator.move(pos); iterator.insert(saveCode); iterator.insert(loadCode); int p = iterator.insertGap(3); iterator.setMark(p); iterator.insert(loadCode); pos = iterator.next(); p = iterator.getMark(); iterator.writeByte(iterator.byteAt(pos), p); iterator.write16bit(iterator.u16bitAt(pos + 1), p + 1); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(newIndex, pos + 1); iterator.move(p); return iterator.next(); } }
protected void runEditor(ExprEditor ed, CodeIterator oldIterator) throws CannotCompileException { CodeAttribute codeAttr = oldIterator.get(); int orgLocals = codeAttr.getMaxLocals(); int orgStack = codeAttr.getMaxStack(); int newLocals = locals(); codeAttr.setMaxStack(stack()); codeAttr.setMaxLocals(newLocals); ExprEditor.LoopContext context = new ExprEditor.LoopContext(newLocals); int size = oldIterator.getCodeLength(); int endPos = oldIterator.lookAhead(); oldIterator.move(currentPos); if (ed.doit(thisClass, thisMethod, context, oldIterator, endPos)) edited = true; oldIterator.move(endPos + oldIterator.getCodeLength() - size); codeAttr.setMaxLocals(orgLocals); codeAttr.setMaxStack(orgStack); maxLocals = context.maxLocals; maxStack += context.maxStack; } }
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 transform(CtClass tclazz, int pos, CodeIterator iterator, ConstPool cp) throws BadBytecode { int c = iterator.byteAt(pos); if (c == GETFIELD || c == GETSTATIC) { int index = iterator.u16bitAt(pos + 1); String typedesc = isField(tclazz.getClassPool(), cp, fieldClass, fieldname, isPrivate, index); if (typedesc != null) { if (c == GETSTATIC) { iterator.move(pos); pos = iterator.insertGap(1); // insertGap() may insert 4 bytes. iterator.writeByte(ACONST_NULL, pos); pos = iterator.next(); } String type = "(Ljava/lang/Object;)" + typedesc; int mi = cp.addClassInfo(methodClassname); int methodref = cp.addMethodrefInfo(mi, methodName, type); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(methodref, pos + 1); return pos; } } return pos; } }
@Override public int transform(CtClass tclazz, int pos, CodeIterator iterator, ConstPool cp) throws BadBytecode { int c = iterator.byteAt(pos); if (c == GETFIELD || c == GETSTATIC) { int index = iterator.u16bitAt(pos + 1); String typedesc = isField(tclazz.getClassPool(), cp, fieldClass, fieldname, isPrivate, index); if (typedesc != null) { if (c == GETSTATIC) { iterator.move(pos); pos = iterator.insertGap(1); // insertGap() may insert 4 bytes. iterator.writeByte(ACONST_NULL, pos); pos = iterator.next(); } String type = "(Ljava/lang/Object;)" + typedesc; int mi = cp.addClassInfo(methodClassname); int methodref = cp.addMethodrefInfo(mi, methodName, type); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(methodref, pos + 1); return pos; } } return pos; } }
if (c == PUTSTATIC) { CodeAttribute ca = iterator.get(); iterator.move(pos); char c0 = typedesc.charAt(0); if (c0 == 'J' || c0 == 'D') { // long or double
private void analyzeNextEntry(MethodInfo method, CodeIterator iter, IntQueue queue, Executor executor) throws BadBytecode { int pos = queue.take(); iter.move(pos); iter.next();
private void analyzeNextEntry(MethodInfo method, CodeIterator iter, IntQueue queue, Executor executor) throws BadBytecode { int pos = queue.take(); iter.move(pos); iter.next();
if (c == PUTSTATIC) { CodeAttribute ca = iterator.get(); iterator.move(pos); char c0 = typedesc.charAt(0); if (c0 == 'J' || c0 == 'D') { // long or double
ci.move(begin); HashMap marks = new HashMap(); while (ci.hasNext()) {
ci.move(begin); Map<Integer,Mark> marks = new HashMap<Integer,Mark>(); while (ci.hasNext()) {