-
iconst_n
- Integers n = 0..5.
-
- the n indicates the const itself, not the index, and the const would be put into the stack.
-
-
istore_n
- store integer in local variable n : n = 0..3
-
-
it says store integer. store what integer? actually it's the integer from the stack.
-
-
… ⇒
…, <i> -
Description Push the int constant <i> (−1, 0, 1, 2, 3, 4 or 5) onto the operand stack.
Notes Each of this family of instructions is equivalent to bipush <i> for the
respective value of <i>, except that the operand <i> is implicit. -
-
at Java Virtual Machine Specification 3rd P366, but when it coms to load the constant 6, what will it going to do? yes, it would then use
bipush 6
-
-
iconst and bipush's difference:
-
-
The Java virtual machine frequently takes advantage of the likelihood of certain
operands (int constants −1, 0, 1, 2, 3, 4 and 5 in the case of the iconst_<i>
instructions) by making those operands implicit in the opcode. Because the
iconst_0 instruction knows it is going to push an int 0, iconst_0 does not need to
store an operand to tell it what value to push, nor does it need to fetch or decode
an operand. Compiling the push of 0 as bipush 0 would have been correct, but
would have made the compiled code for spin one byte longer. A simple virtual
machine would have also spent additional time fetching and decoding the explicit
operand each time around the loop. Use of implicit operands makes compiled
code more compact and efficient.
-
-
-
-
iconst_<i> Operation Push int constant
Forms iconst_m1 = 2 (0x2)
iconst_0 = 3 (0x3) iconst_1 = 4 (0x4) iconst_2 = 5 (0x5) iconst_3 = 6 (0x6) iconst_4 = 7 (0x7) iconst_5 = 8 (0x8) Operand Stack