Commit 7267ccf1 authored by Eric Bruneton's avatar Eric Bruneton

Restore (and complete) bug fix, make previously added test pass.

parent 895bff70
Pipeline #804 passed with stage
in 5 minutes and 55 seconds
......@@ -208,6 +208,7 @@ public class AnalyzerAdapter extends MethodVisitor {
}
visitFrameTypes(nLocal, local, this.locals);
visitFrameTypes(nStack, stack, this.stack);
maxLocals = Math.max(maxLocals, this.locals.size());
maxStack = Math.max(maxStack, this.stack.size());
}
......@@ -241,6 +242,12 @@ public class AnalyzerAdapter extends MethodVisitor {
@Override
public void visitVarInsn(final int opcode, final int var) {
super.visitVarInsn(opcode, var);
boolean isLongOrDouble =
opcode == Opcodes.LLOAD
|| opcode == Opcodes.DLOAD
|| opcode == Opcodes.LSTORE
|| opcode == Opcodes.DSTORE;
maxLocals = Math.max(maxLocals, var + (isLongOrDouble ? 2 : 1));
execute(opcode, var, null);
}
......@@ -400,6 +407,7 @@ public class AnalyzerAdapter extends MethodVisitor {
@Override
public void visitIincInsn(final int var, final int increment) {
super.visitIincInsn(var, increment);
maxLocals = Math.max(maxLocals, var + 1);
execute(Opcodes.IINC, var, null);
}
......@@ -426,6 +434,14 @@ public class AnalyzerAdapter extends MethodVisitor {
execute(Opcodes.MULTIANEWARRAY, dims, desc);
}
@Override
public void visitLocalVariable(
String name, String descriptor, String signature, Label start, Label end, int index) {
char firstDescChar = descriptor.charAt(0);
maxLocals = Math.max(maxLocals, index + (firstDescChar == 'J' || firstDescChar == 'D' ? 2 : 1));
super.visitLocalVariable(name, descriptor, signature, start, end, index);
}
@Override
public void visitMaxs(final int maxStack, final int maxLocals) {
if (mv != null) {
......@@ -438,12 +454,12 @@ public class AnalyzerAdapter extends MethodVisitor {
// ------------------------------------------------------------------------
private Object get(final int local) {
maxLocals = Math.max(maxLocals, local);
maxLocals = Math.max(maxLocals, local + 1);
return local < locals.size() ? locals.get(local) : Opcodes.TOP;
}
private void set(final int local, final Object type) {
maxLocals = Math.max(maxLocals, local);
maxLocals = Math.max(maxLocals, local + 1);
while (local >= locals.size()) {
locals.add(Opcodes.TOP);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment