13.10.2014 Views

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

111<br />

The aload 0 bytecode was the most frequently executed instruction used for loading<br />

a local variable, representing almost 9.2 percent of the total bytecodes executed.<br />

The large execution frequency for this bytecode is a direct result of the design of<br />

the Java Virtual Machine. When any virtual method is invoked, the Java Virtual<br />

Machine Specification requires that a pointer to the receiver object be passed to the<br />

invoked method. This object reference is always passed as the first parameter. The<br />

Java Virtual Machine Specification also dictates that the values passed as parameters<br />

to methods will reside in the first local variable slots in the called scope. These<br />

conditions guarantee that the receiver object will always reside in slot 0 of the local<br />

variable array.<br />

A reference to the receiver object must be placed on the operand stack before any<br />

field in the object can be accessed or another method can be invoked on it. Both of<br />

these operations are performed frequently in object oriented languages. As a result,<br />

the aload 0 bytecode is executed frequently in order to place the required object<br />

references on the stack.<br />

The next most frequently executed load bytecodes are iload 1 and aload 1 respectively.<br />

In instance methods that take one or more parameters in addition to<br />

the receiver object, these bytecodes reflect the process of loading a copy of the first<br />

parameter onto the operand stack when its type is integer or object reference. If<br />

the method being invoked is static, these bytecodes are used to access the second<br />

parameter when it exists and has the appropriate type.<br />

An additional analysis was performed in order to determine the distribution of<br />

method parameter counts. It is described in more detail in Section 6.2.4. This<br />

analysis includes the receiver object as the first parameter to the method when the<br />

invoked method is in an instance method. It found that approximately 38.4 percent<br />

of the methods invoked have either 0 or 1 parameters. As a consequence, it can be<br />

concluded that aload 1 and iload 1 refer to a programmer declared local variable<br />

rather than a method parameter in over one third of the methods invoked. In the<br />

remaining methods, these bytecodes are being used to load the value of a method<br />

parameter onto the stack.<br />

The remaining 3 specialized bytecodes that appear in the 10 most frequently<br />

executed load bytecodes are iload 3 at position 5, iload 2 at position 7 and aload 2<br />

at position 9. Initially it may appear that these bytecodes are being employed for the<br />

purpose of accessing method parameters. However,the analysis of method parameters<br />

indicates that only approximately 19 percent of the methods invoked have more than 2<br />

parameters. As a result, it is concluded that these bytecodes are generally being used

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!