Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the JVM instructions

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what are the JVM instructions", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "what are the JVM instructions?"

1. Stack and local variable operations 1.1 instructions that push constants into the stack

Aconst_null pushes the null object reference onto the stack

Iconst_m1 pushes the int type constant-1 into the stack

Iconst_0 pushes the int type constant 0 onto the stack

Iconst_1 pushes the int type constant 1 onto the stack

Iconst_2 pushes the int type constant 2 onto the stack

Iconst_3 pushes the int type constant 3 onto the stack

Iconst_4 pushes the int type constant 4 onto the stack

Iconst_5 pushes the int type constant 5 onto the stack

Lconst_0 pushes the long type constant 0 onto the stack

Lconst_1 pushes the long type constant 1 onto the stack

Fconst_0 pushes the float type constant 0 onto the stack

Fconst_1 pushes the float type constant 1 onto the stack

Dconst_0 pushes the double type constant 0 onto the stack

Dconst_1 pushes the double type constant 1 onto the stack

Bipush pushes an 8-bit signed integer onto the stack

Sipush pushes 16-bit signed integers into the stack

Ldc pushes items from the constant pool into the stack

Ldc_w pushes items from the constant pool onto the stack (using a wide index)

Ldc2_w pushes items of type long or double in the constant pool onto the stack (using a wide index)

1.2 instructions to load values from local variables in the stack

Iload loads int type values from local variables

Lload loads long type values from local variables

Fload loads float type values from local variables

Dload loads double type values from local variables

Aload loads reference type values (refernce) from local variables

Iload_0 loads int type values from the local variable 0

Iload_1 loads the int type value from the local variable 1

Iload_2 loads int type values from local variable 2

Iload_3 loads int type values from local variable 3

Lload_0 loads long type values from the local variable 0

Lload_1 loads the long type value from the local variable 1

Lload_2 loads long type values from local variable 2

Lload_3 loads long type values from local variable 3

Fload_0 loads float type values from the local variable 0

Fload_1 loads the float type value from the local variable 1

Fload_2 loads float type values from local variable 2

Fload_3 loads float type values from local variable 3

Dload_0 loads double type values from the local variable 0

Dload_1 loads the double type value from the local variable 1

Dload_2 loads double type values from local variable 2

Dload_3 loads double type values from local variable 3

Aload_0 loads reference type values from the local variable 0

Aload_1 loads reference type values from local variable 1

Aload_2 loads reference type values from local variable 2

Aload_3 loads reference type values from local variable 3

Iaload loads int type values from an array

Laload loads long type values from an array

Faload loads float type values from an array

Daload loads double type values from an array

Aaload loads reference type values from an array

Baload loads byte or boolean type values from an array

Caload loads char type values from an array

Saload loads short type values from an array

1.3 instructions to store values in the stack into local variables

Istore stores values of type int in local variables

Lstore stores values of type long in local variables

Fstore stores values of type float in local variables

Dstore stores values of type double in local variables

Astore will store the reference type or returnAddress type value in a local variable

Istore_0 stores the int type value in the local variable 0

Istore_1 stores the int type value in the local variable 1

Istore_2 stores the int type value in the local variable 2

Istore_3 stores the int type value in the local variable 3

Lstore_0 stores the long type value in the local variable 0

Lstore_1 stores the long type value in the local variable 1

Lstore_2 stores the long type value in the local variable 2

Lstore_3 stores the long type value in the local variable 3

Fstore_0 stores the float type value in the local variable 0

Fstore_1 stores the float type value in the local variable 1

Fstore_2 stores the float type value in the local variable 2

Fstore_3 stores the float type value in the local variable 3

Dstore_0 stores the double type value in the local variable 0

Dstore_1 stores the double type value in the local variable 1

Dstore_2 stores the double type value in the local variable 2

Dstore_3 stores the double type value in the local variable 3

Astore_0 stores the reference type or returnAddress type value in the local variable 0

Astore_1 stores the reference type or returnAddress type value in the local variable 1

Astore_2 stores the reference type or returnAddress type value in the local variable 2

Astore_3 stores the reference type or returnAddress type value in the local variable 3

Iastore stores values of type int in an array

Lastore stores values of type long in an array

Fastore stores values of type float in an array

Dastore stores values of type double in an array

Aastore stores reference type values in an array

Bastore stores values of type byte or type boolean in an array

Castore stores values of type char in an array

Sastore stores values of type short in an array

Wide instruction

Wide extends the local variable index with additional bytes

1.4 generic (untyped) stack operation

Nop doesn't do anything.

Pop pops up one word long content at the top of the stack

Pop2 pops up two words at the top of the stack

A word length at the top of the dup replication stack

Dup_x1 copies the one-word-long content at the top of the stack, and then pushes the copied content and the original two-word-long content into the stack

Dup_x2 copies the one-word-long content at the top of the stack, and then pushes the copied content and the original three-word-long content into the stack

Dup2 copies two words at the top of the stack

Dup2_x1 copies the two-word-long content at the top of the stack, and then pushes the copied content and the original three-word-long content into the stack

Dup2_x2 copies the two-word-long content at the top of the stack, and then pushes the copied content and the original pop-up four-word content into the stack

Two words at the top of the swap switch stack

two。 Type conversion

I2l converts data of type int to type long

I2f converts data of type int to type float

I2d converts data of type int to type double

L2i converts data of type long to type int.

L2F converts data of type long to type float.

L2d converts data of type long to type double

F2i converts data of type float to type int.

F2L converts data of type float to type long.

F2d converts data of type float to type double.

D2i converts data of type double to type int.

D2l converts data of type double to type long.

D2f converts data of type double to type float.

I2B converts data of type int to type byte

I2C converts data of type int to type char

I2s converts data of type int to type short.

3. Integer operation

Iadd performs the addition of int types

Ladd performs the addition of long types

Isub performs subtraction of int type

Lsub performs subtraction of long type

Imul performs multiplication of int types

Lmul performs multiplication of long types

Idiv performs division of int types

Ldiv performs division of long types

Irem calculates the remainder of int type division

Lrem calculates the remainder of long type division

Ineg reverses a value of type int

Lneg reverses a value of type long

Iinc adds a constant value to a local variable of type int

4. Logical operation 4.1 shift operation

Ishl performs a left shift operation of type int

Lshl performs a left shift operation of type long

Ishr performs a right shift operation of type int

Lshr performs a right shift operation of type long

Iushr performs a logical shift to the right of int type

Lushr performs a logical shift to the right of long type

4.2 Bitwise Boolean operation

Iand performs a "logical and" operation on int type values

Land performs a "logical and" operation on long type values

Ior performs a "logical OR" operation on an int type value

Lor performs a "logical OR" operation on a long type value

Ixor performs a "logical XOR" operation on int type values

Lxor performs a "logical XOR" operation on long type values

4.3 floating point operation

Fadd performs the addition of float types

Dadd performs the addition of double types

Fsub performs subtraction of float type

Dsub performs subtraction of double type

Fmul performs multiplication of float types

Dmul performs multiplication of double types

Fdiv performs division of float types

Ddiv performs division of double types

Frem calculates the remainder of float type division

Drem calculates the remainder of double type division

Fneg inverts a value of type float

Dneg inverts a value of type double

5. Object and array 5.1 object operation instructions

New creates a new object

Checkcast determines that the object is of the given type

Getfield gets a field from an object

Putfield sets the value of the field in the object

Getstatic gets static fields from the class

Putstatic sets the value of a static field in a class

Instanceof determines whether the object is of a given type

5.2 array operation instruction

Newarray allocates a new array whose data member type is the basic data type

Anewarray assigns a new array whose data member type is a reference type

Arraylength gets the length of the array

Multianewarray allocates new multidimensional arrays

6. Control flow 6.1 conditional branch instruction

If ifeq equals 0, jump

If ifne is not equal to 0, jump

If iflt is less than 0, jump

If ifge is greater than or equal to 0, jump

If ifgt is greater than 0, jump

If ifle is less than or equal to 0, jump

If_icmpcq jumps if two int values are equal

If_icmpne jumps if two int type values are not equal

If_icmplt jumps if one int type value is less than another int type value

If_icmpge jumps if one int type value is greater than or equal to another int type value

If_icmpgt jumps if one int type value is greater than another int type value

If_icmple jumps if one int type value is less than or equal to another int type value

If ifnull is equal to null, jump

If ifnonnull is not equal to null, jump

If_acmpeq jumps if two object references are equal

If_acmpnc jumps if two object references are not equal

6.2 compare instructions

Lcmp compare long type values

Fcmpl compares float type values (returns-1 when NaN is encountered)

Fcmpg compares float type values (returns 1 when NaN is encountered)

Dcmpl compares double type values (returns-1 when NaN is encountered)

Dcmpg compares double type values (returns 1 when NaN is encountered)

6.3 unconditional transfer instruction

Goto unconditional jump

Goto_w unconditional jump (wide index)

6.4 Table jump instruction

Tableswitch accesses the jump table through the index and jumps

Lookupswitch accesses the jump table through key-value matching and performs the jump operation

6.5 abnormal

Athrow throws an exception or error

Finally clause

Jsr jumps to subroutine

Jsr_w jumps to subroutine (wide index)

Rct returns from the subroutine

7. Method call and return 7.1 method call instruction

The invokcvirtual runtime calls the instance method according to the class of the object

Invokespecial calls instance methods based on compile-time types

Invokestatic calls class (static) methods

Invokcinterface calls the interface method

7.2 method returns instruction

Ireturn returns data of type int from a method

Lreturn returns data of type long from a method

Freturn returns data of type float from a method

Dreturn returns data of type double from a method

Areturn returns data of the reference type from the method

Return returns from the method, and the return value is void

7.3 Thread synchronization

Montiorenter enters and gets the object monitor

Monitorexit releases and exits the object monitor

8. JVM instruction mnemonic

Variable to Operand stack: iload,iload_,lload,lload_,fload,fload_,dload,dload_,aload,aload_

Operand stack to variable: istore,istore_,lstore,lstore_,fstore,fstore_,dstore,dstor_,astore,astore_

Constant to Operand stack: bipush,sipush,ldc,ldc_w,ldc2_w,aconst_null,iconst_ml,iconst_,lconst_,fconst_,dconst_

Add: iadd,ladd,fadd,dadd

Minus: isub,lsub,fsub,dsub

Multiply: imul,lmul,fmul,dmul

Except for: idiv,ldiv,fdiv,ddiv

Remainder: irem,lrem,frem,drem

Negative: ineg,lneg,fneg,dneg

Shift: ishl,lshr,iushr,lshl,lshr,lushr

Bitwise or: ior,lor

Bitwise vs.: iand,land

Bitwise XOR: ixor,lxor

Type conversion: i2lmagentin i2frecoveryl2freparationl2frecoveryl2dcoveringf2d (relaxed numerical conversion)

I2brec, i2c, i2s, L2i, f2i, f2l, d2i, d2i, d2l, d2l, d2f (narrowed numeric conversion)

Creating a class is handy: new

Create a new array: newarray,anewarray,multianwarray

Access the domain of the class and the class instance domain: getfield,putfield,getstatic,putstatic

Load data into the Operand stack: baload,caload,saload,iaload,laload,faload,daload,aaload

Store from Operand stack to array: bastore,castore,sastore,iastore,lastore,fastore,dastore,aastore

Get array length: arraylength

Phase detector instance or array attribute: instanceof,checkcast

Operand stack management: pop,pop2,dup,dup2,dup_xl,dup2_xl,dup_x2,dup2_x2,swap conditional transfer: ifeq,iflt,ifle,ifne,ifgt,ifge,ifnull,ifnonnull,if_icmpeq,if_icmpene,if_icmplt,if_icmpgt,if_icmple,if_icmpge,if_acmpeq,if_acmpne,lcmp,fcmpl,fcmpg,dcmpl,dcmpg

Compound conditional transfer: tableswitch,lookupswitch

Unconditional transfer: goto,goto_w,jsr,jsr_w,ret

The practical method of scheduling object: invokevirtual

Call the method implemented by the interface: invokeinterface

Call the instance method that requires special handling: invokespecial

Call the static method in the named class: invokestatic

Method returns: ireturn,lreturn,freturn,dreturn,areturn,return

Exception: athrow

The implementation of finally keyword uses: jsr,jsr_w,ret

The above is all the contents of this article "what are the JVM instructions?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report