首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

ASM4.0源码走读之二 授命的类型

2013-03-12 
ASM4.0源码走读之二指令的类型? ? ? ? 在深入分析ClassReader.readCode()方法之前,我们需要大概了解下ASM

ASM4.0源码走读之二 指令的类型

? ? ? ? 在深入分析ClassReader.readCode()方法之前,我们需要大概了解下ASM把jvm的指令分的类型,这在readCode会用到。先看ClassReader的代码:

    static {        int i;        byte[] b = new byte[220];        String s = "AAAAAAAAAAAAAAAABCLMMDDDDDEEEEEEEEEEEEEEEEEEEEAAAAAAAADD"                + "DDDEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"                + "AAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAJJJJJJJJJJJJJJJJDOPAA"                + "AAAAGGGGGGGHIFBFAAFFAARQJJKKJJJJJJJJJJJJJJJJJJ";        for (i = 0; i < b.length; ++i) {            b[i] = (byte) (s.charAt(i) - 'A');        }        TYPE = b;    }

? ? ? ? ?这其中的TYPE是一个字节数组,索引是jvm指令的byte值,值从0开始,分了16类,简化后是:

0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 1, 2,11,12, 12,3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3,14,15,0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 7, 8, 5, 1, 5, 0, 0, 5, 5, 0, 0, 17,16,9, 9,10,10, 9, 9, 9, 9, 9,9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9

? ? ? 补全下,指令跟指令类型的对照表:

指令操作码 16进制    指令类型                指令##类型为0的指令没有操作数0    =    0x0    =    0    ...............nop1    =    0x1    =    0    ...............aconst_null2    =    0x2    =    0    ...............iconst_m13    =    0x3    =    0    ...............iconst_04    =    0x4    =    0    ...............iconst_15    =    0x5    =    0    ...............iconst_26    =    0x6    =    0    ...............iconst_37    =    0x7    =    0    ...............iconst_48    =    0x8    =    0    ...............iconst_59    =    0x9    =    0    ...............lconst_010    =    0xa    =    0    ...............lconst_111    =    0xb    =    0    ...............fconst_012    =    0xc    =    0    ...............fconst_113    =    0xd    =    0    ...............fconst_214    =    0xe    =    0    ...............dconst_015    =    0xf    =    0    ...............dconst_1##类型为1的指令操作数长度为1个字节16    =    0x10    =    1    ...............bipush##类型为2的指令操作数长度为2个字节17    =    0x11    =    2    ...............sipush18    =    0x12    =    11    ...............ldc19    =    0x13    =    12    ...............ldc_w20    =    0x14    =    12    ...............ldc2_w##类型为3的指令操作数长度为1个字节21    =    0x15    =    3    ...............iload22    =    0x16    =    3    ...............lload23    =    0x17    =    3    ...............fload24    =    0x18    =    3    ...............dload25    =    0x19    =    3    ...............aload##类型为4的指令操作数长度为1个字节26    =    0x1a    =    4    ...............iload_027    =    0x1b    =    4    ...............iload_128    =    0x1c    =    4    ...............iload_229    =    0x1d    =    4    ...............iload_330    =    0x1e    =    4    ...............lload_031    =    0x1f    =    4    ...............lload_132    =    0x20    =    4    ...............lload_233    =    0x21    =    4    ...............lload_334    =    0x22    =    4    ...............fload_035    =    0x23    =    4    ...............fload_136    =    0x24    =    4    ...............fload_237    =    0x25    =    4    ...............fload_338    =    0x26    =    4    ...............dload_039    =    0x27    =    4    ...............dload_140    =    0x28    =    4    ...............dload_241    =    0x29    =    4    ...............dload_342    =    0x2a    =    4    ...............aload_043    =    0x2b    =    4    ...............aload_144    =    0x2c    =    4    ...............aload_245    =    0x2d    =    4    ...............aload_346    =    0x2e    =    0    ...............iaload47    =    0x2f    =    0    ...............laload48    =    0x30    =    0    ...............faload49    =    0x31    =    0    ...............daload50    =    0x32    =    0    ...............aaload51    =    0x33    =    0    ...............baload52    =    0x34    =    0    ...............caload53    =    0x35    =    0    ...............saload54    =    0x36    =    3    ...............istore55    =    0x37    =    3    ...............lstore56    =    0x38    =    3    ...............fstore57    =    0x39    =    3    ...............dstore58    =    0x3a    =    3    ...............astore59    =    0x3b    =    4    ...............istore_060    =    0x3c    =    4    ...............istore_161    =    0x3d    =    4    ...............istore_262    =    0x3e    =    4    ...............istore_363    =    0x3f    =    4    ...............lstore_064    =    0x40    =    4    ...............lstore_165    =    0x41    =    4    ...............lstore_266    =    0x42    =    4    ...............lstore_367    =    0x43    =    4    ...............fstore_068    =    0x44    =    4    ...............fstore_169    =    0x45    =    4    ...............fstore_270    =    0x46    =    4    ...............fstore_371    =    0x47    =    4    ...............dstore_072    =    0x48    =    4    ...............dstore_173    =    0x49    =    4    ...............dstore_274    =    0x4a    =    4    ...............dstore_375    =    0x4b    =    4    ...............astore_076    =    0x4c    =    4    ...............astore_177    =    0x4d    =    4    ...............astore_278    =    0x4e    =    4    ...............astore_379    =    0x4f    =    0    ...............iastore80    =    0x50    =    0    ...............lastore81    =    0x51    =    0    ...............fastore82    =    0x52    =    0    ...............dastore83    =    0x53    =    0    ...............aastore84    =    0x54    =    0    ...............bastore85    =    0x55    =    0    ...............castore86    =    0x56    =    0    ...............sastore87    =    0x57    =    0    ...............pop88    =    0x58    =    0    ...............pop289    =    0x59    =    0    ...............dup90    =    0x5a    =    0    ...............dup_x191    =    0x5b    =    0    ...............dup_x292    =    0x5c    =    0    ...............dup293    =    0x5d    =    0    ...............dup2_x194    =    0x5e    =    0    ...............dup2_x295    =    0x5f    =    0    ...............swap96    =    0x60    =    0    ...............iadd97    =    0x61    =    0    ...............ladd98    =    0x62    =    0    ...............fadd99    =    0x63    =    0    ...............dadd100    =    0x64    =    0    ...............isub101    =    0x65    =    0    ...............lsub102    =    0x66    =    0    ...............fsub103    =    0x67    =    0    ...............dsub104    =    0x68    =    0    ...............imul105    =    0x69    =    0    ...............lmul106    =    0x6a    =    0    ...............fmul107    =    0x6b    =    0    ...............dmul108    =    0x6c    =    0    ...............idiv109    =    0x6d    =    0    ...............ldiv110    =    0x6e    =    0    ...............fdiv111    =    0x6f    =    0    ...............ddiv112    =    0x70    =    0    ...............irem113    =    0x71    =    0    ...............lrem114    =    0x72    =    0    ...............frem115    =    0x73    =    0    ...............drem116    =    0x74    =    0    ...............ineg117    =    0x75    =    0    ...............lneg118    =    0x76    =    0    ...............fneg119    =    0x77    =    0    ...............dneg120    =    0x78    =    0    ...............ishl121    =    0x79    =    0    ...............lshl122    =    0x7a    =    0    ...............ishr123    =    0x7b    =    0    ...............lshr124    =    0x7c    =    0    ...............iushr125    =    0x7d    =    0    ...............lushr126    =    0x7e    =    0    ...............iand127    =    0x7f    =    0    ...............land128    =    0x80    =    0    ...............ior129    =    0x81    =    0    ...............lor130    =    0x82    =    0    ...............ixor131    =    0x83    =    0    ...............lxor132    =    0x84    =    13    ...............iinc133    =    0x85    =    0    ...............i2l134    =    0x86    =    0    ...............i2f135    =    0x87    =    0    ...............i2d136    =    0x88    =    0    ...............l2i137    =    0x89    =    0    ...............l2f138    =    0x8a    =    0    ...............l2d139    =    0x8b    =    0    ...............f2i140    =    0x8c    =    0    ...............f2l141    =    0x8d    =    0    ...............f2d142    =    0x8e    =    0    ...............d2i143    =    0x8f    =    0    ...............d2l144    =    0x90    =    0    ...............d2f145    =    0x91    =    0    ...............i2b146    =    0x92    =    0    ...............i2c147    =    0x93    =    0    ...............i2s148    =    0x94    =    0    ...............lcmp149    =    0x95    =    0    ...............fcmpl150    =    0x96    =    0    ...............fcmpg151    =    0x97    =    0    ...............dcmpl152    =    0x98    =    0    ...............dcmpg#类型为9的指令,主要是if、goto、jsr三大类指令153    =    0x99    =    9    ...............ifeq154    =    0x9a    =    9    ...............ifne155    =    0x9b    =    9    ...............iflt156    =    0x9c    =    9    ...............ifge157    =    0x9d    =    9    ...............ifgt158    =    0x9e    =    9    ...............ifle159    =    0x9f    =    9    ...............if_icmpeq160    =    0xa0    =    9    ...............if_icmpne161    =    0xa1    =    9    ...............if_icmplt162    =    0xa2    =    9    ...............if_icmpge163    =    0xa3    =    9    ...............if_icmpgt164    =    0xa4    =    9    ...............if_icmple165    =    0xa5    =    9    ...............if_acmpeq166    =    0xa6    =    9    ...............if_acmpne167    =    0xa7    =    9    ...............goto168    =    0xa8    =    9    ...............jsr169    =    0xa9    =    3    ...............ret#14    tableswitch    对齐变长,high(4)    /    low(4)    /    offsets[(high-low+1)*4]170    =    0xaa    =    14    ...............tableswitch#15    lookupswitch    对齐变长    default(4)    /    npairs(4)    /    match(4)    -    offset(4)    pairs171    =    0xab    =    15    ...............lookupswitch172    =    0xac    =    0    ...............ireturn173    =    0xad    =    0    ...............lreturn174    =    0xae    =    0    ...............freturn175    =    0xaf    =    0    ...............dreturn176    =    0xb0    =    0    ...............areturn177    =    0xb1    =    0    ...............return178    =    0xb2    =    6    ...............getstatic179    =    0xb3    =    6    ...............putstatic180    =    0xb4    =    6    ...............getfield181    =    0xb5    =    6    ...............putfield182    =    0xb6    =    6    ...............invokevirtual183    =    0xb7    =    6    ...............invokespecial184    =    0xb8    =    6    ...............invokestatic185    =    0xb9    =    7    ...............invokeinterface186    =    0xba    =    8    ...............invokedynamic187    =    0xbb    =    5    ...............new188    =    0xbc    =    1    ...............newarray189    =    0xbd    =    5    ...............anewarray190    =    0xbe    =    0    ...............arraylength191    =    0xbf    =    0    ...............athrow192    =    0xc0    =    5    ...............checkcast193    =    0xc1    =    5    ...............instanceof194    =    0xc2    =    0    ...............monitorenter195    =    0xc3    =    0    ...............monitorexit196    =    0xc4    =    17    ...............wide197    =    0xc5    =    16    ...............multianewarray198    =    0xc6    =    9    ...............ifnull199    =    0xc7    =    9    ...............ifnonnull#goto、jsr扩展指令200    =    0xc8    =    10    ...............goto_w201    =    0xc9    =    10    ...............jsr_w202    =    0xca    =    9    Reserved    opcodes:203    =    0xcb    =    9    ...............breakpoint204    =    0xcc    =    9    ...............impdep1205    =    0xcd    =    9    ...............impdep2206    =    0xce    =    9207    =    0xcf    =    9208    =    0xd0    =    9209    =    0xd1    =    9210    =    0xd2    =    9211    =    0xd3    =    9212    =    0xd4    =    9213    =    0xd5    =    9214    =    0xd6    =    9215    =    0xd7    =    9216    =    0xd8    =    9217    =    0xd9    =    9218    =    0xda    =    9219    =    0xdb    =    9

?

热点排行