我'm trying to make an inline optimization and I'm使用本文作为参考http://modularity.info/conference/2007/program/industry/I5-UsingASMFramework.pdf(3.2.6) . 我正在使用ASM 7并且一些代码已经弃用了,所以如果你能指出我的新文章,我会感激不尽 .

无论版本如何,我仍然无法确切了解其工作原理

public static class InliningAdapter extends RemappingMethodAdapter
{ 
    private final LocalVariablesSorter lvs; 
    private final Label end; 
    public InliningAdapter(LocalVariablesSorter mv, Label end, int acc, String desc, Remapper remapper) { 
        super(acc, desc, mv, remapper); 
        this.lvs = mv; 
        this.end = end; 
        // guess it's offset as it is written that way below
        int off = (acc & Opcodes.ACC_STATIC)!=0 ? 0 : 1; 
        Type[] args = Type.getArgumentTypes(desc); 
        for (int i = args.length-1; i >= 0; i--) { 
            super.visitVarInsn(args[i].getOpcode(Opcodes.ISTORE), i + offset); 
        } 
        if(offset>0) { 
            super.visitVarInsn(Opcodes.ASTORE, 0); 
        } 
    } 
    public void visitInsn(int opcode) { 
        if(opcode==Opcodes.RETURN) { 
            super.visitJumpInsn(Opcodes.GOTO, end); 
        } else { 
            super.visitInsn(opcode); 
        } 
    } 
    public void visitMaxs(int stack, int locals) {   } 

    protected int newLocalMapping(Type type) { 
        return lvs.newLocal(type); 
    } 
}

我得到了,因为我们内联,堆栈中加载并准备好由方法调用使用的参数现在必须存储回本地重映射变量 . 但是,在存储这些参数的for循环中,使用的索引(i offset)很可能是0 e.t.c,因此通过LocalVariableSorter的重映射方法,可能不会重新映射此值,因为它们可能被视为方法参数 .

this线程中,它声明cosntructor "super(acc, desc, mv, remapper);"中的super命令必须更改为super(acc | Opcodes.ACC_STATIC,"()V",mv,remapper);为了重新映射每个变量,包括那些索引小于参数数量的变量 . 这篇论文的作者是错的吗?这种变化是必要的吗?