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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

22<br />

Figure 2.5: A Simple Interpreter Engine<br />

2.4.2 A Better Switch Based Interpreter<br />

When the algorithm presented in Figure 2.4 is executed, two unconditional branches<br />

are performed for each bytecode executed. This can be reduced to one unconditional<br />

branch for each bytecode executed by replacing the while loop with an infinite loop<br />

constructed using a goto statement. One branch is eliminated by replacing the break<br />

statement at the end of each codelet with a goto statement. This goto statement<br />

transfers control to the top of the loop directly, making it unnecessary to branch to<br />

the bottom of the loop. Furthermore, performing this transformation eliminates the<br />

conditional that is tested in order to determine if the while loop should continue to<br />

execute. While an optimizing compiler should be able to eliminate the test if the<br />

conditional is constructed using only constant values, performing this transformation<br />

guarantees that the check will be removed without relying on the optimizer.<br />

Figure 2.6 shows the execution engine once these transformations have been per-

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

Saved successfully!

Ooh no, something went wrong!