Commit 50acd801 authored by Eric Bruneton's avatar Eric Bruneton

Merge branch '316555-non-regression-test' into 'master'

Add a non-regression test for issue #316555.

See merge request asm/asm!132
parents 8b4036a1 7267ccf1
Pipeline #844 canceled with stage
......@@ -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) {
......
......@@ -92,7 +92,14 @@ public class AnalyzerAdapterTest extends AsmTest {
super.visitMethod(access, name, desc, signature, exceptions);
AnalyzedFramesInserter inserter = new AnalyzedFramesInserter(methodVisitor);
AnalyzerAdapter analyzerAdapter =
new AnalyzerAdapter(api, owner, access, name, desc, inserter);
new AnalyzerAdapter(api, owner, access, name, desc, inserter) {
@Override
public void visitMaxs(int maxStack, int maxLocals) {
// AnalyzerAdapter should correctly recompute maxLocals from scratch.
super.visitMaxs(maxStack, 0);
}
};
inserter.analyzer = analyzerAdapter;
return analyzerAdapter;
}
......
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