tradition loop
1 | public void spin() { |
In vm there many frame at any point,
but only the operand stack in currrent frame is active.
javap -c Spin.class
1 | public void spin(); |
a | b |
---|---|
[0] | push int constant 0 |
[1] | store into local variable 1 (i=0) |
[2] | push local variable 1 (-> i) |
[3] | push int constant 10 |
[5] | break if great or equals (i>=10) |
[8] | increment local variable 1 by 1 (i++) |
[11] | loop |
[14] | return void when done |
Instructions
iconst_<i>
push an int constant to operand stackbipush
immediate push int constant to operand stackistore_<i>
pops an int from the operand stack and stores it in local variable iiload_<i>
pushes the value in local variable i on to the operand stack