Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Bytecode basics

A first look at the bytecodes of the Java virtual machine

  • Print
  • Feedback

Page 7 of 10

Opcode Operand(s) Description
lload vindex pushes long from local variable positions vindex and (vindex + 1)
lload_0 (none) pushes long from local variable positions zero and one
lload_1 (none) pushes long from local variable positions one and two
lload_2 (none) pushes long from local variable positions two and three
lload_3 (none) pushes long from local variable positions three and four
dload vindex pushes double from local variable positions vindex and (vindex + 1)
dload_0 (none) pushes double from local variable positions zero and one
dload_1 (none) pushes double from local variable positions one and two
dload_2 (none) pushes double from local variable positions two and three
dload_3 (none) pushes double from local variable positions three and four

The final group of opcodes that push local variables move 32-bit object references from the local variables section of the stack frame to the operand section. These opcodes are shown in the following table:

Opcode Operand(s) Description
aload vindex pushes object reference from local variable position vindex
aload_0 (none) pushes object reference from local variable position zero
aload_1 (none) pushes object reference from local variable position one
aload_2 (none) pushes object reference from local variable position two
aload_3 (none) pushes object reference from local variable position three

Popping to local variables

For each opcode that pushes a local variable onto the stack there exists a corresponding opcode that pops the top of the stack back into the local variable. The names of these opcodes can be formed by replacing "load" in the names of the push opcodes with "store". The opcodes that pop ints and floats from the top of the operand stack to a local variable are listed in the following table. Each of these opcodes moves one 32-bit value from the top of the stack to a local variable.

Opcode Operand(s) Description
istore vindex pops int to local variable position vindex
istore_0 (none) pops int to local variable position zero
istore_1 (none) pops int to local variable position one
istore_2 (none) pops int to local variable position two
istore_3 (none) pops int to local variable position three
fstore vindex pops float to local variable position vindex
fstore_0 (none) pops float to local variable position zero
fstore_1 (none) pops float to local variable position one
fstore_2 (none) pops float to local variable position two
fstore_3 (none) pops float to local variable position three

The next table shows the instructions that pop values of type long and double into a local variable. These instructions move a 64-bit value from the top of the operand stack to a local variable.

  • Print
  • Feedback

Resources
  • Previous Under The Hood articles:
  • The lean, mean virtual machine -- Gives an introduction to the Java virtual machine. Look here to see how the garbage collected heap fits in with the other parts of the JVM.
  • The Java class file lifestyle -- Gives an overview to the Java class file, the file format into which all Java programs are compiled.
  • Java's garbage-collected heap -- Gives an overview of garbage collection in general and the garbage-collected heap of the JVM in particular.