lstore :
store long integer in local variable : index : visitVarInsn()
- Description
- lstore pops a two-word long integer off the operand stack and
stores it in a local variable. It takes a single parameter, <varnum>, an
unsigned integer indicating which local variable to use.
Since long integers are 64-bits wide, and each local variable can only
hold up to 32 bits Java uses two consecutive local variables, <varnum>
and <varnum> + 1 to store a long. So lstore <varnum>
actually modifies the values of both <varnum> (which is set to
long-word1) and <varnum> + 1 (which is set to
long-word2).
Both <varnum> and <varnum> + 1 must be valid local variable
numbers in the current frame, and together they must be holding a long.
Remember that attempting to treat two-word values as two independent
single-word values will produce a verification error. So trying to retrieve
<varnum> or <varnum> + 1 independently (e.g. iload
<varnum>) will produce a verification error. Similarly, if you store
a value other than a long in <varnum>, then <varnum> + 1 becomes
invalidated until a new value is stored in it. - Example
ldc2_w 10 ; push the long integer 10 onto the stack
lstore 3 ; pop 10 off of the stack and store it in local variables 3 and 4
- See also
- istore fstore dstore astore wide
- Stack
Before
|
After |
long-word1 |
... |
long-word2 |
... |
... |
... |
- Bytecode
Type
|
Description |
u1
|
lstore
opcode = 0x37 (55)
|
u1
|
<varnum> |
There
is also a wide format for this instruction, which supports access to
all local variables from 0 to 65535:
Type
|
Description |
u1 |
wide
opcode = 0xC4 (196)
|
u1
|
lstore
opcode = 0x37 (55)
|
u2
|
<varnum> |