List<String> exps = new ArrayList<String>(mn.exceptions);
if (!exps.contains(CheckInstrumentationVisitor.EXCEPTION_NAME)) {
exps.add(CheckInstrumentationVisitor.EXCEPTION_NAME);
}
String[] expss = MethodDatabase.toStringArray(exps);
MethodNode mv = new MethodNode(Opcodes.ACC_PUBLIC, buildInitHelpMethodName(mn.desc), "()V", null, expss);
Label invokedInitInsnStart = null;
Label invokedInitInsnEnd = null;
Label invokedInitInsnCatchAll = null;
boolean needWaveInvokedInitInsn = invokedInitInsn != null
&& db.checkMethodSuspendType(invokedInitInsn.owner, ClassEntry.key(invokedInitInsn.name, invokedInitInsn.desc), false) == MethodDatabase.SUSPEND_NORMAL;
if (needWaveInvokedInitInsn) {
invokedInitInsnStart = new Label();
invokedInitInsnEnd = new Label();
invokedInitInsnCatchAll = new Label();
mv.visitTryCatchBlock(invokedInitInsnStart, invokedInitInsnEnd, invokedInitInsnCatchAll, null);
}
for(TryCatchBlockNode tcb : mn.tryCatchBlocks) {
tcb.accept(mv);
}
mv.visitMethodInsn(Opcodes.INVOKESTATIC, CSTACK_NAME, "getStack", "()L"+CSTACK_NAME+";");
mv.visitVarInsn(Opcodes.ASTORE, lvarCStack);
if (needWaveInvokedInitInsn) {
mv.visitLabel(invokedInitInsnStart);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, invokedInitInsn.owner, "inch_" + getMD5(invokedInitInsn.desc), "()V");
mv.visitLabel(invokedInitInsnEnd);
}
for(int i=firstLocal ; i<f.getLocals() ; i++) {
BasicValue v = (BasicValue) f.getLocal(i);
if(!isNullType(v)) {
int slotIdx = fi.localSlotIndices[i];
assert slotIdx >= 0 && slotIdx < fi.numSlots;
emitRestoreValue(mv, v, lvarCStack, slotIdx);
mv.visitVarInsn(v.getType().getOpcode(Opcodes.ISTORE), i);
} else if(v != BasicValue.UNINITIALIZED_VALUE) {
mv.visitInsn(Opcodes.ACONST_NULL);
mv.visitVarInsn(Opcodes.ASTORE, i);
}
}
for(int i=0 ; i<f.getStackSize() ; i++) {
BasicValue v = (BasicValue) f.getStack(i);
if(!isOmitted(v)) {
if(!isNullType(v)) {
int slotIdx = fi.stackSlotIndices[i];
assert slotIdx >= 0 && slotIdx < fi.numSlots;
emitRestoreValue(mv, v, lvarCStack, slotIdx);
} else {
mv.visitInsn(Opcodes.ACONST_NULL);
}
}
}
mv.visitVarInsn(Opcodes.ALOAD,lvarCStack);
emitConst(mv, fi.numSlots);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CSTACK_NAME, "release", "(I)V");
int maxStack = mn.maxStack;
for (int i = splitPos; i < numIns; i++) {
AbstractInsnNode insn = mn.instructions.get(i);
if (insn instanceof MethodInsnNode) {
MethodInsnNode misn = (MethodInsnNode) insn;
String name = misn.name;
if (name.charAt(0) == '<' && name.charAt(1) == 'i' && db != null && db.checkMethodSuspendType(misn.owner, ClassEntry.key(name, misn.desc), false, false) == MethodDatabase.SUSPEND_NORMAL) {
mv.visitInsn(Opcodes.ACONST_NULL);
mv.visitMethodInsn(misn.getOpcode(), misn.owner, name, InstrumentConstructorMethod.buildShrinkedInitMethodDesc(misn.desc));
mv.visitInsn(Opcodes.DUP);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, misn.owner, InstrumentConstructorMethod.buildInitHelpMethodName(misn.desc), "()V");
maxStack = mn.maxStack + 1;
continue;
}
}
insn.accept(mv);
}
if (needWaveInvokedInitInsn) {
mv.visitLabel(invokedInitInsnCatchAll);
mv.visitVarInsn(Opcodes.ALOAD,lvarCStack);
emitConst(mv, fi.numSlots);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CSTACK_NAME, "release", "(I)V");
mv.visitInsn(Opcodes.ATHROW);
}
if(mn.localVariables != null && !mn.localVariables.isEmpty()) {
for (int i = 0; i < f.getLocals(); i++) {
mn.localVariables.get(i).accept(mv);
}
}
mv.visitMaxs(maxStack+3, mn.maxLocals+3);
mv.visitEnd();
InstrumentMethod im = new InstrumentMethod(db, className, mv);
if(im.collectCodeBlocks()) {
im.accept(cv.makeOutMV(mv));
}else {