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.

136<br />

from one bytecode to the next in a Java interpreter is denoted by the symbol →.<br />

Consequently, this symbol represents the loop, fetch and decode operations, and the<br />

task of advancing the program counter to refer to the next instruction, shown in the<br />

model of a Java interpreter in Figure 2.4. Using this notation, the code that must be<br />

executed for an arbitrary sequence of Java bytecodes can be expressed as:<br />

x 1 → x 2 → x 3 → ... → x n → (7.1)<br />

When a sequence of bytecodes is replaced by a multicode, the transfers of control<br />

between each bytecode are removed. The codelet for the multicode can be constructed<br />

by merging the codelets of its constituent bytecodes, as long as a small number<br />

of minor adjustments are performed during the concatenation. These adjustments<br />

ensure that the correct operands are read from the code stream when the multicode<br />

executes. The multicode that represents the sequence of bytecodes in Equation 7.1<br />

will be denoted as shown in Equation 7.2.<br />

x 1 /x 2 /x 3 /.../x n → (7.2)<br />

It has already been stated that the amount of time required to execute a multicode<br />

is smaller than the amount of time required to execute the equivalent sequence of Java<br />

bytecodes. This is apparent from Equation 7.1 and Equation 7.2 because the number<br />

of transfers of control in Equation 7.1 is n, while the number of transfers of control in<br />

Equation 7.2 is only 1, regardless of the length of the multicode. Equation 7.3 shows<br />

how the difference in performance will be represented. It uses the function Cost(code)<br />

to denote a measure of how much time is needed to execute ‘code’.<br />

∆ x1 /x 2 /x 3 .../x n→ = Cost(x 1 → x 2 → x 3 → ... → x n →) − Cost(x 1 /x 2 /x 3 .../x n →)<br />

(7.3)<br />

If it assumed that the codelet for the multicode is constructed as a concatenation<br />

of the codelets of the multicode’s constituent bytecodes, then Equation 7.3 reduces<br />

to:<br />

∆ x1 /x 2 /x 3 /...x n/→ = (n − 1) × Cost(→) (7.4)<br />

However, in general, the difference in performance is not that simple because<br />

it is possible to perform optimizations on the concatenated codelet representing the<br />

multicode. These optimizations could not be performed before multicode substitution

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

Saved successfully!

Ooh no, something went wrong!