JVM Tutorials - Herong's Tutorial Examples - v5.14, by Herong Yang
Local Variable Array Instructions
This section describes JVM instructions that transfer values between the local variable array and the operand stack: *load* and *store*.
What Are Local Variable Array Instructions? Local variable array instructions transfer values between the local variable array and the operand stack. Their mnemonics have a pattern of *load* or *store*.
The table below describes local variable array instructions. P. is the count of bytes following the opcode as operation parameters. I. is the count elements consumed from the operand stack as operation input. O. is the count elements added to the operand stack as operation output.
Mnemonic C. P. I. O. Description ------------- -- -- -- -- ---------------------------------------- iload 15 1 0 1 Load int from a given variable lload 16 1 0 2 Load long from a given variable fload 17 1 0 1 Load fload from a given variable dload 18 1 0 2 Load double from a given variable aload 19 1 0 1 Load address from a given variable iload_0 1A 0 0 1 Load int from variable 0 iload_1 1B 0 0 1 Load int from variable 1 iload_2 1C 0 0 1 Load int from variable 2 iload_3 1D 0 0 1 Load int from variable 3 lload_0 1E 0 0 2 Load long from variable 0 lload_1 1F 0 0 2 Load long from variable 1 lload_2 20 0 0 2 Load long from variable 2 lload_3 21 0 0 2 Load long from variable 3 fload_0 22 0 0 1 Load float from variable 0 fload_1 23 0 0 1 Load float from variable 1 fload_2 24 0 0 1 Load float from variable 2 fload_3 25 0 0 1 Load float from variable 3 dload_0 26 0 0 2 Load double from variable 0 dload_1 27 0 0 2 Load double from variable 1 dload_2 28 0 0 2 Load double from variable 2 dload_3 29 0 0 2 Load double from variable 3 aload_0 2A 0 0 1 Load address from variable 0 aload_1 2B 0 0 1 Load address from variable 1 aload_2 2C 0 0 1 Load address from variable 2 aload_3 2D 0 0 1 Load address from variable 3 istore 36 0 1 0 Store int to a given variable lstore 37 0 2 0 Store long to a given variable fstore 38 0 1 0 Store fload to a given variable dstore 39 0 2 0 Store double to a given variable astore 3A 0 1 0 Store address to a given variable istore_0 3B 0 1 0 Store int to variable 0 istore_1 3C 0 1 0 Store int to variable 1 istore_2 3D 0 1 0 Store int to variable 2 istore_3 3E 0 1 0 Store int to variable 3 lstore_0 3F 0 2 0 Store long to variable 0 lstore_1 40 0 2 0 Store long to variable 1 lstore_2 41 0 2 0 Store long to variable 2 lstore_3 42 0 2 0 Store long to variable 3 fstore_0 43 0 1 0 Store float to variable 0 fstore_1 44 0 1 0 Store float to variable 1 fstore_2 45 0 1 0 Store float to variable 2 fstore_3 46 0 1 0 Store float to variable 3 dstore_0 47 0 2 0 Store double to variable 0 dstore_1 48 0 2 0 Store double to variable 1 dstore_2 49 0 2 0 Store double to variable 2 dstore_3 4A 0 2 0 Store double to variable 3 astore_0 4B 0 1 0 Store address to variable 0 astore_1 4C 0 1 0 Store address to variable 1 astore_2 4D 0 1 0 Store address to variable 2 astore_3 4E 0 1 0 Store address to variable 3 iinc 84 2 0 0 Increment int in given variable by a int
Note that for a *load_* or *store_* instruction, the index of the targeted variable in the local variable array is hardcoded in the opcode. But they are limited to the first 4 variables, so we should take advantage of those hardcoded opcodes, by declaring most frequently used variables first to improve performance.
The iinc instruction takes the incrementing int from the second parameter after the local variable array index, not from the operand stack.
Table of Contents
JVM (Java Virtual Machine) Specification
Java HotSpot VM - JVM by Oracle/Sun
java.lang.Runtime Class - The JVM Instance
java.lang.System Class - The Operating System
ClassLoader Class - Class Loaders
Class Class - Class Reflections
JVM Stack, Frame and Stack Overflow
Thread Testing Program and Result
CPU Impact of Multi-Thread Applications
I/O Impact of Multi-Thread Applications
Micro Benchmark Runner and JVM Options
Micro Benchmark Tests on "int" Operations
Micro Benchmark Tests on "long" Operations
Micro Benchmark Tests in JIT Compilation Mode
Micro Benchmark Tests on "float" and "double" Operations
JRockit JVM 28.2.7 by Oracle Corporation
►JVM Bytecode and Instruction Set
Walkthrough of "javap -c -v" Command Output
►Local Variable Array Instructions
Arithmetic Operation Instructions
Bitwise Operation Instructions
Method Invocation Instructions