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.

53<br />

...<br />

iload 3<br />

iflt<br />

...<br />

i − 1<br />

i i + 1<br />

i + 2<br />

(a) Before Despecialization<br />

...<br />

iload 3<br />

iconst 0 if icmplt<br />

...<br />

i − 1<br />

i i + 1 i + 2<br />

i + 3<br />

(b) After Despecializing if Bytecodes<br />

...<br />

iload 0x03 bipush 0x00 if icmplt<br />

...<br />

i − 1<br />

i i + 1 i + 2 i + 3 i + 4<br />

i + 5<br />

(c) After Despecializing Load, Integer Constant and if Bytecodes<br />

Figure 4.5: An Example of Branch Despecialization<br />

branch despecializations have been performed in 4.5b. Finally, Figure 4.5c shows the<br />

statement after both integer constant despecialization and branch despecialization<br />

have been performed.<br />

Performing this despecialization increases the size of the class file by one byte for<br />

each static despecialization performed, with further size increases occurring if integer<br />

constant despecialization is also performed. This despecialization also introduces an<br />

extra element onto the operand stack. As a result, all methods in a class file that<br />

had branch despecialization performed on them had their max stack value increased<br />

by one in order to ensure that there was sufficient space on the runtime stack for the<br />

additional zero value. Note that it is not necessary to increase the max stack value<br />

by one for each static occurrence of a branch bytecode despecialized in this manner<br />

because the extra zero value added to the stack by iconst 0 is consumed immediately<br />

by the if icmp bytecode, making it impossible for this transformation to<br />

increase the maximum stack height reached within the method by more than one.<br />

A second type of branch despecialization was also considered. It reduced the number<br />

of if icmp bytecodes from the six defined by the Java Virtual Machine<br />

Specification to four. The need for two conditions can be eliminated by swapping the

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

Saved successfully!

Ooh no, something went wrong!