gpt4 book ai didi

java - ASM 字节码库中用于确定操作码性质的实用方法?

转载 作者:行者123 更新时间:2023-12-01 14:53:06 28 4
gpt4 key购买 nike

ASM 中是否有任何 utils 类允许我从操作码推断指令是否是某种存储、加载或其他类型?

例如,考虑以下代码(来自 ASM)

/**
* Visits a zero operand instruction.
*
* @param opcode the opcode of the instruction to be visited. This opcode is
* either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2,
* ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0,
* FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD, LALOAD, FALOAD,
* DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, IASTORE, LASTORE, FASTORE,
* DASTORE, AASTORE, BASTORE, CASTORE, SASTORE, POP, POP2, DUP,
* DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, IADD, LADD, FADD,
* DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV, LDIV,
* FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL,
* LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR,
* I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B,
* I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN,
* FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW,
* MONITORENTER, or MONITOREXIT.
*/
public void visitInsn(int opcode) {
if (mv != null) {
mv.visitInsn(opcode);
}
}

使用 Utils.isConst(opcode) 或 Utils.isLoad(opcode) 或 Utils.isStore(opcode) 等方法会很方便。

ASM中有类似的东西吗?

最佳答案

看看InstructionAdapter 。它将操作码转换为更粗粒度的方法调用。

关于java - ASM 字节码库中用于确定操作码性质的实用方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14634081/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com