Java directives and virtual machine loading mechanisms

Source: Internet
Author: User
Tags bitwise instance method throw exception
Java Directives

The instructions for a Java Virtual machine are composed of a byte-length number that represents a specific operational meaning (called an opcode, Opcode). Because the Java virtual machine uses an operand stack rather than a register architecture, most directives do not contain operands, only one opcode.

For most byte-code directives related to data types, their opcode mnemonics have special characters that indicate which type of data is specifically served: I represents the operation of data of type int, l on behalf of the LONG,S Representative Short,b Representative Byte,c representative Char,f representative float, D represents Double,a on behalf of reference.

loading and storing directives

The instructions for loading a local variable into the operation Stack include:
Iload, iload_<n>, Lload, lload_<n>, Fload, fload_<n>, Dload, dload_<n>, Aload, aload_<n>

The instructions for storing a number from the operand stack to a local variable table include
Istore, istore_<n>, Lstore, lstore_<n>, Fstore, fstore_<n>, Dstore, dstore_<n>, Astore, astore_ <n>

The instructions to load a constant onto the operand stack include
Bipush, Sipush, LDC, Ldc_w, Ldc2_w, Aconst_null, Iconst_m1, iconst_<i>, lconst_<l>, fconst_<f>, Dconst _<d>

An instruction to augment the access index of a local variable table: Wide operation instruction addition instruction: Iadd, Ladd, Fadd, dadd subtraction instruction: Isub, lsub, fsub, dsub multiplication instruction: Imul, Lmul, Fmul, Dmul Division instruction: Idiv, Ldiv, Fdiv, ddiv remainder instructions: irem, Lrem, Frem, Drem take counter instructions: Ineg, Lneg, Fneg, Dneg Displacement command: ISHL, ISHR, Iushr, LSHL, LSHR, LUSHR Bitwise OR directive: IOR, Lor bitwise AND instruction: Iand, land bitwise XOR or directive: Ixor, Lxor local variable self-increasing instruction: Iinc comparison directives: Dcmpg, Dcmpl, Fcmpg, Fcmpl, lcmp type conversion directives

Java virtual machines are directly supported for wide type conversions and do not require instruction execution, including: int types to long, float, or double type long to float, double type float to double type

The narrowing type conversion instruction consists of a
I2B, I2C, I2s, L2i, F2i, f2l, D2i, d2l and d2f.

Narrowing type conversions are likely to result in loss of precision.object creation and Operation directivesTo create an instruction for a class instance: New to create an array instruction: Newarray,anewarray,multianewarray Access class fields (static fields, or class variables) and instance fields (not static fields, Or become an instance variable: GetField, Putfield, getstatic, putstatic the instructions to load an array element onto the operand stack: baload, Caload, Saload, Iaload, Laload, Faload, Daload, aaload an instruction that stores the value of an operand stack into an array element: Bastore, Castore, Sastore, Iastore, Fastore, Dastore, Aastore, and the instructions for the length of the array: arraylength Check class instance type directives: instanceof, checkcast operand stack management directives (instructions for direct manipulation of operand stacks): POPs, Pop2, DUP, dup2, dup_x1, dup2_x1, dup_x2, dup2_x2, and swapControl transfer instruction:Conditional branches: ifeq, Iflt, Ifle, Ifne, IFGT, IFGE, Ifnull, Ifnonnull, If_icmpeq, If_icmpne, If_icmplt, IF_ICMPGT, If_icmple, if_ Icmpge, If_acmpeq, and If_acmpne compound conditions branch: tableswitch, lookupswitch Unconditional branch: Goto, Goto_w, JSR, Jsr_w, retmethod calls and return directivesThe invokevirtual directive is used to invoke an instance method of an object, which is assigned based on the actual type of the object (virtual method dispatch), which is also the most common way of assigning methods in the Java language. The invokeinterface instruction is used to invoke the interface method, which searches for an object that implements the interface method at run time and finds the appropriate method to invoke it. The invokespecial directive is used to invoke some instance methods that require special handling, including instance initialization methods, private methods, and parent class methods. The invokestatic directive is used to invoke the method that the class method (static method) invokedynamic instruction uses to invoke the calling point object (call site object) that binds the invokedynamic directive. The call point object is a special syntax structure that, when a invokedynamic instruction is first executed by a Java virtual machine, executes a boot method (bootstrap) and takes the result of the method as the calling point object. Therefore, each invokedynamic instruction has a unique link state, which is a difference between its invocation instructions with other methods.

The method return instruction is distinguished by the type of the return value, including Ireturn (used when the return value is Boolean, Byte, char, short, and int) lreturn (long), Freturn (float), Dreturn ( Double) and Areturn (reference) return instructions for class initialization methods that declare void, instance initialization methods, classes, and interfaces using throw exception directives

Athrow



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.