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.

151<br />

Both the Total Bytecodes Score and the Transfer Reduction Score fail to consider<br />

the optimization potential of the sequence or the impact its replacement has on cache<br />

performance. Another scoring technique which attempts to capture of complete impact<br />

of the multicode’s impact including transfers removed, optimization potential<br />

and caching is discussed in Section 7.8.<br />

7.4 Multicode Substitution<br />

Once a multicode is identified, the Java class files must be modified to make use<br />

of it. This process is referred to as multicode substitution. It involves examining<br />

the code stream within each class file in order to locate occurrences of the bytecode<br />

sequence to replace with the multicode. However, performing multicode substitution<br />

is not as simple as replacing all occurrences of the bytecode sequence with the new<br />

multicode. Branching, exceptions, and the difference in size between the multicode<br />

and the sequence of bytecodes that it represents all must be taken into consideration.<br />

Checks were performed during profiling in order to ensure that only those sequences<br />

that can be replaced contribute to the score of each multicode. However, those checks<br />

do not guarantee the absence of other occurrences of the sequence that are ineligible<br />

for substitution within the class files. As a result, care must be taken during the<br />

substitution process.<br />

Branching presents difficulties because it is not possible to branch to the middle<br />

of a multicode – either the entire multicode executes or the entire multicode does<br />

not execute. Consequently, it is not possible to perform a multicode substitution<br />

on any sequence of bytecodes, x 1 →x 2 →x 3 →... →x n →, where a bytecode in the<br />

sequence, other than x 1 , is a target of a branch, conditional or unconditional. The<br />

lookupswitch and tableswitch bytecodes are treated as a special type of conditional<br />

branch that has multiple branch targets. If such a substitution was performed, there<br />

would be no way to express the target of the branch bytecode. Branching to the start<br />

of the multicode would result in bytecodes being executed that were not executed<br />

before the substitution was performed, potentially placing values with inconsistent<br />

types on the operand stack or otherwise resulting in incorrect results being generated.<br />

The same situation can occur if the branch target was set to the bytecode immediately<br />

following the multicode.<br />

Exception handlers are represented within the Java Virtual Machine by specifying<br />

the program counter value for the first bytecode within the exception handler and<br />

the first bytecode that is not covered by the exception handler. As a result, a similar

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

Saved successfully!

Ooh no, something went wrong!