Java Reference
In-Depth Information
values are automatically popped from the caller's stack and deposited into the
low-numbered registers.
The JVM's registers are untyped , so they can hold any kind of value. For
values that require two registers (long and double types), an even-odd pair of
registers must be used.
iload
The iload instruction pushes the contents of a JVM
register on TOS. The instruction must contain an im-
mediate operand designating the register whose con-
tents should be loaded. The register is una
23
ff
ected by
the instruction.
If register 2 contains the value 23, then the example
shows the results of executing iload 2.
Before
After
To facilitate compression, the JVM has some single-byte instructions that load
low-numbered registers. The iload 2 instruction takes two bytes: one for
the instruction and one for the operand. The operation can be abbreviated as
iload 2, which takes only a single byte, as the opcode implies that register 2
is loaded.
istore
131
Instructions are also available for moving data from the
stack to a register. The istore instruction pops a value
from the stack and stores it in the register specified as
an immediate operand of the instruction.
In the example, an istore 10 would pop the value 131
from the stack and store it in register 10. There is no
abbreviated formof this instruction because register 10
is beyond the registers provisioned for the single-byte
istore instructions.
Before
After
There are variations of iload and istore for each type of data that can be
loaded or stored. For example, fload n reads a float value from register n
and pushes it on TOS. There are no register instructions specific to the boolean
type. The JVM uses an int representation for boolean, with 0 representing
false and 1 representing true.Typeschar, byte,andshort are similarly
treated as int at the register level, because 32 bits can accommodate their
values as well.
All reference types are loaded and stored using aload and astore instruc-
tions, respectively. An object reference takes the same space as an int:32bits.
The value of 0 is reserved to represent null.
 
Search WWH ::




Custom Search