java bytecode

来源:互联网 发布:美工技巧 编辑:程序博客网 时间:2024/06/05 08:20

转自wiki:https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings
MnemonicOpcode
(in hexadecimal)Opcode (in binary)Other bytesStack
[before]→[after]Descriptionaaload320011 0010 arrayref, index → valueload onto the stack a reference from an arrayaastore530101 0011 arrayref, index, value →store into a reference in an arrayaconst_null010000 0001 → nullpush a null reference onto the stackaload190001 10011: index→ objectrefload a reference onto the stack from a local variable#indexaload_02a0010 1010 → objectrefload a reference onto the stack from local variable 0aload_12b0010 1011 → objectrefload a reference onto the stack from local variable 1aload_22c0010 1100 → objectrefload a reference onto the stack from local variable 2aload_32d0010 1101 → objectrefload a reference onto the stack from local variable 3anewarraybd1011 11012: indexbyte1, indexbyte2count → arrayrefcreate a new array of references of length count and component type identified by the class referenceindex (indexbyte1 << 8 + indexbyte2) in the constant poolareturnb01011 0000 objectref → [empty]return a reference from a methodarraylengthbe1011 1110 arrayref → lengthget the length of an arrayastore3a0011 10101: indexobjectref →store a reference into a local variable #indexastore_04b0100 1011 objectref →store a reference into local variable 0astore_14c0100 1100 objectref →store a reference into local variable 1astore_24d0100 1101 objectref →store a reference into local variable 2astore_34e0100 1110 objectref →store a reference into local variable 3athrowbf1011 1111 objectref → [empty], objectrefthrows an error or exception (notice that the rest of the stack is cleared, leaving only a reference to the Throwable)baload330011 0011 arrayref, index → valueload a byte or Boolean value from an arraybastore540101 0100 arrayref, index, value →store a byte or Boolean value into an arraybipush100001 00001: byte→ valuepush a byte onto the stack as an integer valuebreakpointca1100 1010  reserved for breakpoints in Java debuggers; should not appear in any class filecaload340011 0100 arrayref, index → valueload a char from an arraycastore550101 0101 arrayref, index, value →store a char into an arraycheckcastc01100 00002: indexbyte1, indexbyte2objectref → objectrefchecks whether an objectref is of a certain type, the class reference of which is in the constant pool atindex (indexbyte1 << 8 + indexbyte2)d2f901001 0000 value → resultconvert a double to a floatd2i8e1000 1110 value → resultconvert a double to an intd2l8f1000 1111 value → resultconvert a double to a longdadd630110 0011 value1, value2 → resultadd two doublesdaload310011 0001 arrayref, index → valueload a double from an arraydastore520101 0010 arrayref, index, value →store a double into an arraydcmpg981001 1000 value1, value2 → resultcompare two doublesdcmpl971001 0111 value1, value2 → resultcompare two doublesdconst_00e0000 1110 → 0.0push the constant 0.0 (a double) onto the stackdconst_10f0000 1111 → 1.0push the constant 1.0 (a double) onto the stackddiv6f0110 1111 value1, value2 → resultdivide two doublesdload180001 10001: index→ valueload a double value from a local variable #indexdload_0260010 0110 → valueload a double from local variable 0dload_1270010 0111 → valueload a double from local variable 1dload_2280010 1000 → valueload a double from local variable 2dload_3290010 1001 → valueload a double from local variable 3dmul6b0110 1011 value1, value2 → resultmultiply two doublesdneg770111 0111 value → resultnegate a doubledrem730111 0011 value1, value2 → resultget the remainder from a division between two doublesdreturnaf1010 1111 value → [empty]return a double from a methoddstore390011 10011: indexvalue →store a double value into a local variable #indexdstore_0470100 0111 value →store a double into local variable 0dstore_1480100 1000 value →store a double into local variable 1dstore_2490100 1001 value →store a double into local variable 2dstore_34a0100 1010 value →store a double into local variable 3dsub670110 0111 value1, value2 → resultsubtract a double from anotherdup590101 1001 value → value, valueduplicate the value on top of the stackdup_x15a0101 1010 value2, value1 → value1, value2, value1insert a copy of the top value into the stack two values from the top. value1 and value2 must not be of the type double or long.dup_x25b0101 1011 value3, value2, value1 → value1, value3, value2, value1insert a copy of the top value into the stack two (if value2 is double or long it takes up the entry of value3, too) or three values (if value2 is neither double nor long) from the topdup25c0101 1100 {value2, value1} → {value2, value1}, {value2, value1}duplicate top two stack words (two values, if value1 is not double nor long; a single value, if value1 is double or long)dup2_x15d0101 1101 value3, {value2, value1} → {value2, value1}, value3, {value2, value1}duplicate two words and insert beneath third word (see explanation above)dup2_x25e0101 1110 {value4, value3}, {value2, value1} → {value2, value1}, {value4, value3}, {value2, value1}duplicate two words and insert beneath fourth wordf2d8d1000 1101 value → resultconvert a float to a doublef2i8b1000 1011 value → resultconvert a float to an intf2l8c1000 1100 value → resultconvert a float to a longfadd620110 0010 value1, value2 → resultadd two floatsfaload300011 0000 arrayref, index → valueload a float from an arrayfastore510101 0001 arrayref, index, value →store a float in an arrayfcmpg961001 0110 value1, value2 → resultcompare two floatsfcmpl951001 0101 value1, value2 → resultcompare two floatsfconst_00b0000 1011 → 0.0fpush 0.0f on the stackfconst_10c0000 1100 → 1.0fpush 1.0f on the stackfconst_20d0000 1101 → 2.0fpush 2.0f on the stackfdiv6e0110 1110 value1, value2 → resultdivide two floatsfload170001 01111: index→ valueload a float value from a local variable #indexfload_0220010 0010 → valueload a float value from local variable 0fload_1230010 0011 → valueload a float value from local variable 1fload_2240010 0100 → valueload a float value from local variable 2fload_3250010 0101 → valueload a float value from local variable 3fmul6a0110 1010 value1, value2 → resultmultiply two floatsfneg760111 0110 value → resultnegate a floatfrem720111 0010 value1, value2 → resultget the remainder from a division between two floatsfreturnae1010 1110 value → [empty]return a floatfstore380011 10001: indexvalue →store a float value into a local variable #indexfstore_0430100 0011 value →store a float value into local variable 0fstore_1440100 0100 value →store a float value into local variable 1fstore_2450100 0101 value →store a float value into local variable 2fstore_3460100 0110 value →store a float value into local variable 3fsub660110 0110 value1, value2 → resultsubtract two floatsgetfieldb41011 01002: indexbyte1, indexbyte2objectref → valueget a field value of an object objectref, where the field is identified by field reference in the constant poolindex (indexbyte1 << 8 + indexbyte2)getstaticb21011 00102: indexbyte1, indexbyte2→ valueget a static field value of a class, where the field is identified by field reference in the constant pool index(indexbyte1 << 8 + indexbyte2)gotoa71010 01112: branchbyte1, branchbyte2[no change]goes to another instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)goto_wc81100 10004: branchbyte1, branchbyte2, branchbyte3, branchbyte4[no change]goes to another instruction at branchoffset (signed int constructed from unsigned bytes branchbyte1 << 24 + branchbyte2 << 16 + branchbyte3 << 8 + branchbyte4)i2b911001 0001 value → resultconvert an int into a bytei2c921001 0010 value → resultconvert an int into a characteri2d871000 0111 value → resultconvert an int into a doublei2f861000 0110 value → resultconvert an int into a floati2l851000 0101 value → resultconvert an int into a longi2s931001 0011 value → resultconvert an int into a shortiadd600110 0000 value1, value2 → resultadd two intsiaload2e0010 1110 arrayref, index → valueload an int from an arrayiand7e0111 1110 value1, value2 → resultperform a bitwise and on two integersiastore4f0100 1111 arrayref, index, value →store an int into an arrayiconst_m1020000 0010 → -1load the int value −1 onto the stackiconst_0030000 0011 → 0load the int value 0 onto the stackiconst_1040000 0100 → 1load the int value 1 onto the stackiconst_2050000 0101 → 2load the int value 2 onto the stackiconst_3060000 0110 → 3load the int value 3 onto the stackiconst_4070000 0111 → 4load the int value 4 onto the stackiconst_5080000 1000 → 5load the int value 5 onto the stackidiv6c0110 1100 value1, value2 → resultdivide two integersif_acmpeqa51010 01012: branchbyte1, branchbyte2value1, value2 →if references are equal, branch to instruction atbranchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)if_acmpnea61010 01102: branchbyte1, branchbyte2value1, value2 →if references are not equal, branch to instruction atbranchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)if_icmpeq9f1001 11112: branchbyte1, branchbyte2value1, value2 →if ints are equal, branch to instruction at branchoffset(signed short constructed from unsigned bytesbranchbyte1 << 8 + branchbyte2)if_icmpgea21010 00102: branchbyte1, branchbyte2value1, value2 →if value1 is greater than or equal to value2, branch to instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)if_icmpgta31010 00112: branchbyte1, branchbyte2value1, value2 →if value1 is greater than value2, branch to instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)if_icmplea41010 01002: branchbyte1, branchbyte2value1, value2 →if value1 is less than or equal to value2, branch to instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)if_icmplta11010 00012: branchbyte1, branchbyte2value1, value2 →if value1 is less than value2, branch to instruction atbranchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)if_icmpnea01010 00002: branchbyte1, branchbyte2value1, value2 →if ints are not equal, branch to instruction atbranchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)ifeq991001 10012: branchbyte1, branchbyte2value →if value is 0, branch to instruction at branchoffset(signed short constructed from unsigned bytesbranchbyte1 << 8 + branchbyte2)ifge9c1001 11002: branchbyte1, branchbyte2value →if value is greater than or equal to 0, branch to instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)ifgt9d1001 11012: branchbyte1, branchbyte2value →if value is greater than 0, branch to instruction atbranchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)ifle9e1001 11102: branchbyte1, branchbyte2value →if value is less than or equal to 0, branch to instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)iflt9b1001 10112: branchbyte1, branchbyte2value →if value is less than 0, branch to instruction atbranchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)ifne9a1001 10102: branchbyte1, branchbyte2value →if value is not 0, branch to instruction at branchoffset(signed short constructed from unsigned bytesbranchbyte1 << 8 + branchbyte2)ifnonnullc71100 01112: branchbyte1, branchbyte2value →if value is not null, branch to instruction atbranchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)ifnullc61100 01102: branchbyte1, branchbyte2value →if value is null, branch to instruction at branchoffset(signed short constructed from unsigned bytesbranchbyte1 << 8 + branchbyte2)iinc841000 01002: index, const[No change]increment local variable #index by signed byte constiload150001 01011: index→ valueload an int value from a local variable #indexiload_01a0001 1010 → valueload an int value from local variable 0iload_11b0001 1011 → valueload an int value from local variable 1iload_21c0001 1100 → valueload an int value from local variable 2iload_31d0001 1101 → valueload an int value from local variable 3impdep1fe1111 1110  reserved for implementation-dependent operations within debuggers; should not appear in any class fileimpdep2ff1111 1111  reserved for implementation-dependent operations within debuggers; should not appear in any class fileimul680110 1000 value1, value2 → resultmultiply two integersineg740111 0100 value → resultnegate intinstanceofc11100 00012: indexbyte1, indexbyte2objectref → resultdetermines if an object objectref is of a given type, identified by class reference index in constant pool (indexbyte1 << 8 + indexbyte2)invokedynamicba1011 10104: indexbyte1, indexbyte2, 0, 0[arg1, [arg2 ...]] → resultinvokes a dynamic method and puts the result on the stack (might be void); the method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)invokeinterfaceb91011 10014: indexbyte1, indexbyte2, count, 0objectref, [arg1, arg2, ...] → resultinvokes an interface method on object objectref and puts the result on the stack (might be void); the interface method is identified by method referenceindex in constant pool (indexbyte1 << 8 + indexbyte2)invokespecialb71011 01112: indexbyte1, indexbyte2objectref, [arg1, arg2, ...] → resultinvoke instance method on object objectref and puts the result on the stack (might be void); the method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)invokestaticb81011 10002: indexbyte1, indexbyte2[arg1, arg2, ...] → resultinvoke a static method and puts the result on the stack (might be void); the method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)invokevirtualb61011 01102: indexbyte1, indexbyte2objectref, [arg1, arg2, ...] → resultinvoke virtual method on object objectref and puts the result on the stack (might be void); the method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)ior801000 0000 value1, value2 → resultbitwise int orirem700111 0000 value1, value2 → resultlogical int remainderireturnac1010 1100 value → [empty]return an integer from a methodishl780111 1000 value1, value2 → resultint shift leftishr7a0111 1010 value1, value2 → resultint arithmetic shift rightistore360011 01101: indexvalue →store int value into variable #indexistore_03b0011 1011 value →store int value into variable 0istore_13c0011 1100 value →store int value into variable 1istore_23d0011 1101 value →store int value into variable 2istore_33e0011 1110 value →store int value into variable 3isub640110 0100 value1, value2 → resultint subtractiushr7c0111 1100 value1, value2 → resultint logical shift rightixor821000 0010 value1, value2 → resultint xorjsra81010 10002: branchbyte1, branchbyte2→ addressjump to subroutine at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2) and place the return address on the stackjsr_wc91100 10014: branchbyte1, branchbyte2, branchbyte3, branchbyte4→ addressjump to subroutine at branchoffset (signed int constructed from unsigned bytes branchbyte1 << 24 + branchbyte2 << 16 + branchbyte3 << 8 + branchbyte4) and place the return address on the stackl2d8a1000 1010 value → resultconvert a long to a doublel2f891000 1001 value → resultconvert a long to a floatl2i881000 1000 value → resultconvert a long to a intladd610110 0001 value1, value2 → resultadd two longslaload2f0010 1111 arrayref, index → valueload a long from an arrayland7f0111 1111 value1, value2 → resultbitwise and of two longslastore500101 0000 arrayref, index, value →store a long to an arraylcmp941001 0100 value1, value2 → resultpush 0 if the two longs are the same, 1 if value1 is greater than value2, -1 otherwiselconst_0090000 1001 → 0Lpush 0L (the number zero with type long) onto the stacklconst_10a0000 1010 → 1Lpush 1L (the number one with type long) onto the stackldc120001 00101: index→ valuepush a constant #index from a constant pool (String, int or float) onto the stackldc_w130001 00112: indexbyte1, indexbyte2→ valuepush a constant #index from a constant pool (String, int or float) onto the stack (wide index is constructed as indexbyte1 << 8 + indexbyte2)ldc2_w140001 01002: indexbyte1, indexbyte2→ valuepush a constant #index from a constant pool (double or long) onto the stack (wide index is constructed asindexbyte1 << 8 + indexbyte2)ldiv6d0110 1101 value1, value2 → resultdivide two longslload160001 01101: index→ valuel

oad a long value from a local variable #index

lload_01e0001 1110 → valueload a long value from a local variable 0lload_11f0001 1111 → valueload a long value from a local variable 1lload_2200010 0000 → valueload a long value from a local variable 2lload_3210010 0001 → valueload a long value from a local variable 3lmul690110 1001 value1, value2 → resultmultiply two longslneg750111 0101 value → resultnegate a longlookupswitchab1010 10114+: <0–3 bytes padding>, defaultbyte1, defaultbyte2, defaultbyte3, defaultbyte4, npairs1, npairs2, npairs3, npairs4, match-offset pairs...key →a target address is looked up from a table using a key and execution continues from the instruction at that addresslor811000 0001 value1, value2 → resultbitwise or of two longslrem710111 0001 value1, value2 → resultremainder of division of two longslreturnad1010 1101 value → [empty]return a long valuelshl790111 1001 value1, value2 → resultbitwise shift left of a long value1 by int value2positionslshr7b0111 1011 value1, value2 → resultbitwise shift right of a long value1 by int value2positionslstore370011 01111: indexvalue →store a long value in a local variable #indexlstore_03f0011 1111 value →store a long value in a local variable 0lstore_1400100 0000 value →store a long value in a local variable 1lstore_2410100 0001 value →store a long value in a local variable 2lstore_3420100 0010 value →store a long value in a local variable 3lsub650110 0101 value1, value2 → resultsubtract two longslushr7d0111 1101 value1, value2 → resultbitwise shift right of a long value1 by int value2positions, unsignedlxor831000 0011 value1, value2 → resultbitwise exclusive or of two longsmonitorenterc21100 0010 objectref →enter monitor for object ("grab the lock" – start of synchronized() section)monitorexitc31100 0011 objectref →exit monitor for object ("release the lock" – end of synchronized() section)multianewarrayc51100 01013: indexbyte1, indexbyte2, dimensionscount1, [count2,...] → arrayrefcreate a new array of dimensions dimensions with elements of type identified by class reference in constant pool index (indexbyte1 << 8 + indexbyte2); the sizes of each dimension is identified by count1, [count2, etc.]newbb1011 10112: indexbyte1, indexbyte2→ objectrefcreate new object of type identified by class reference in constant pool index (indexbyte1 << 8 + indexbyte2)newarraybc1011 11001: atypecount → arrayrefcreate new array with count elements of primitive type identified by atypenop000000 0000 [No change]perform no operationpop570101 0111 value →discard the top value on the stackpop2580101 1000 {value2, value1} →discard the top two values on the stack (or one value, if it is a double or long)putfieldb51011 01012: indexbyte1, indexbyte2objectref, value →set field to value in an object objectref, where the field is identified by a field reference index in constant pool (indexbyte1 << 8 + indexbyte2)putstaticb31011 00112: indexbyte1, indexbyte2value →set static field to value in a class, where the field is identified by a field reference index in constant pool (indexbyte1 << 8 + indexbyte2)reta91010 10011: index[No change]continue execution from address taken from a local variable #index (the asymmetry with jsr is intentional)returnb11011 0001 → [empty]return void from methodsaload350011 0101 arrayref, index → valueload short from arraysastore560101 0110 arrayref, index, value →store short to arraysipush110001 00012: byte1, byte2→ valuepush a short onto the stackswap5f0101 1111 value2, value1 → value1, value2swaps two top words on the stack (note that value1 and value2 must not be double or long)tableswitchaa1010 10104+: [0–3 bytes padding], defaultbyte1, defaultbyte2, defaultbyte3, defaultbyte4, lowbyte1, lowbyte2, lowbyte3, lowbyte4, highbyte1, highbyte2, highbyte3, highbyte4, jump offsets...index →continue execution from an address in the table at offset indexwidec41100 01003/5: opcode, indexbyte1, indexbyte2
or
iinc, indexbyte1, indexbyte2, countbyte1, countbyte2[same as for corresponding instructions]execute opcode, where opcode is either iload, fload, aload, lload, dload, istore, fstore, astore, lstore, dstore, or ret, but assume the index is 16 bit; or execute iinc, where the index is 16 bits and the constant to increment by is a signed 16 bit short(no name)cb-fd   these values are currently unassigned for opcodes and are reserved for future use

0 0
原创粉丝点击