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.

50<br />

...<br />

i − 1<br />

iconst 0 istore 2 iconst 4 istore 3<br />

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

...<br />

i + 5<br />

(a) Before Integer Constant Despecialization<br />

...<br />

i − 1<br />

bipush 0x00 istore 2 bipush 0x04 istore 3<br />

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

(b) After Integer Constant Despecialization to bipush<br />

...<br />

i + 6<br />

...<br />

i − 1<br />

sipush 0x00 0x00 istore 2 sipush 0x00 0x04 istore 3<br />

i i + 1 i + 2 i + 3 i + 4 i + 5 i + 6 i + 7<br />

(c) After Integer Constant Despecialization to sipush<br />

...<br />

i + 8<br />

...<br />

i − 1<br />

ldc 0xff istore 2 ldc w 0x01 0x00 istore 3<br />

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

(d) After Integer Constant Despecialization to ldc / ldc w<br />

...<br />

i + 7<br />

Figure 4.3: An Example of Integer Constant Despecialization<br />

the operand stack. These operations are at least as expensive as the cost of copying<br />

the single operand byte that represents the constant directly from the code stream.<br />

Figure 4.3a shows a block of code that assigns two constant integer values to<br />

two local variables before integer constant despecialization is performed. The constant<br />

values are generated using the specialized iconst bytecodes. Figure 4.3b<br />

shows the code stream when the specialized iconst bytecodes are replaced with<br />

bipush. The alternative despecializations that could have been utilized are presented<br />

in Figure 4.3c and Figure 4.3d. These figures show the bytecode stream when the<br />

specialized integer constant loading bytecodes are replaced with sipush and ldc or<br />

ldc w respectively. Note that Figure 4.3d assumes that the integer constant value 0

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

Saved successfully!

Ooh no, something went wrong!