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.

95<br />

when a pure interpreter virtual machine was used to execute the benchmarks.<br />

Despecialization resulted in a greater average performance loss on<br />

this platform than any other. Consequently, while despecialization has a<br />

minimal impact once JIT compilation is performed, slower run times can<br />

be expected for the portion of the code executed before JIT compilation<br />

occurs. However, it is worth noting that the amount of time spent executing<br />

the application with the interpreter is typically far less than the<br />

amount of time spent executing code generated by the JIT compiler.<br />

The infrequency with which some specialized bytecodes were executed was initially<br />

a surprising result because it was assumed that the specialized bytecodes that<br />

are defined by the Java Virtual Machine Specification were selected for some sound<br />

reason. However, looking to the architecture of the Java Virtual Machine revealed<br />

that design decisions made about the architecture of the Java Virtual Machine cause<br />

some specialized bytecodes to execute infrequently.<br />

Four Java bytecodes are defined which have the ability to change the flow of control<br />

within the application to a new method. These bytecodes include invokevirtual,<br />

invokestatic, invokeinterface and invokespecial. In this document, they are<br />

referred to collectively as the invoke* bytecodes. In each case, the arguments passed<br />

to the method being invoked must be present on the operand stack before the necessary<br />

invoke* bytecode is executed. When an invoke* bytecode is encountered, the<br />

arguments are copied from the operand stack in the calling scope and placed into<br />

local variables in the called scope. The first argument is placed in local variable slot<br />

0, the second argument is placed in local variable slot 1, and so on. When a value<br />

of type long or double is passed as a parameter, it occupies two slots in the local<br />

variable array.<br />

The bytecodes iload 0, fload 2 and dload 3 are specialized versions of the general<br />

purpose bytecodes iload, fload and dload respectively. The inclusion of these<br />

specialized forms in the Java Virtual Machine Specification implies that accesses to<br />

the first four local variable slots are more common than accesses to slots with greater<br />

indices. However, in many cases, parameter values (other than the receiver object)<br />

are read only once at the start of the method and then are never used again. This<br />

is because local variables defined within the method are used to hold temporary results<br />

generated during the computation rather than overwriting the parameter value.<br />

Unfortunately programmer declared local variables are often unable to make use of<br />

specialized bytecodes for loads and stores because the slots for which specialized load<br />

and store bytecodes exist have already been occupied by method parameters.

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

Saved successfully!

Ooh no, something went wrong!