Reputation: 121
How iload #index differs from other 3 byte codes. Is there any performance difference between them.
Upvotes: 5
Views: 2051
Reputation: 318
When a new thread is launched,JVM create a new stack for the thread and when a thread invokes a Java method, the virtual machine creates and pushes a new frame onto the thread’s Java stack. The stack frame consist three parts: local variable, operand stack, frame data.
Local variable is organized as a zero-based array of words.
These iload_1, iload_2, iload_3 are entry level of local variable array.So, iload_1 means refering to first index of local variable array. Similarly, iload_2 and iload_3 means refering second and third index of the local variable array respectively.
So, there is no specific difference in these iload_1, iload_2, and iload_3, instead refering to respective index at local variable array.
Upvotes: 1
Reputation: 533720
How iload #index differs from other 3 byte codes.
The iload_1 _2 _3 use one byte of byte code. The other form uses 2.
Is there any performance difference between them.
Only indirectly. Most of the time it makes no difference, however there are some performance tuning metrics which are based byte code byte count. e.g. whether to inline a method or not. A slightly longer method can mean that certain optimisations are not performed.
e.g. the metric for inlining a method even if not called often is 35 bytes. If the code used the iload # instead of iload_1 it could means it is slightly more than 35 bytes long instead of slightly less and not get inlined.
Upvotes: 6