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.

49<br />

purpose bytecodes. The notation, , is used to represent an arbitrary small integer,<br />

allowing all four of the specialized bytecodes to be represented using a single<br />

symbol. While not used in Table 4.2, the symbol will be used to represent<br />

any of the primitive types supported by the Java Virtual Machine. As a result, the<br />

symbol store is used to represent an arbitrary specialized store bytecode.<br />

Similarly, the symbol load will be used to denote an arbitrary specialized<br />

load bytecode.<br />

4.1.3 Integer Constant Despecializations<br />

The Java Virtual Machine Specification includes 7 bytecodes used for placing small<br />

integer constants onto the operand stack. These cover the values -1, 0 and 1 through<br />

5. They are generated using the iconst series of bytecodes.<br />

Other facilities are available for placing integer constants onto the stack. These<br />

include the bipush bytecode which is capable of generating any integer constant in<br />

the range -128 to 127 and the sipush bytecode which can be used to generate any<br />

integer constant from -32768 to 32767. While bipush is not normally used to generate<br />

constants from -1 to 5, nothing in the Java Virtual Machine Specification precludes it<br />

from being used for this purpose. Similarly, sipush is not normally used to generate<br />

constants from -128 to 127. However, the Java Virtual Machine Specification does<br />

not specifically restrict it from being used for this purpose.<br />

An additional option is to make use of the appropriate ldc or ldc w bytecode<br />

to load the required value from the constant pool, rather than using bipush or<br />

sipush, which encodes the constant using only operands within the code stream<br />

for the method. Employing this solution results in an additional value being stored<br />

in the constant pool which is loaded through an offset specified as an operand to ldc<br />

or ldc w. While integer constants from -32768 to 32767 do not normally reside in the<br />

constant pool, the Java Virtual Machine Specification does not forbid this.<br />

In this work, integer constants are despecialized by replacing them with appropriate<br />

bipush bytecodes. This choice was made because it is guaranteed to have<br />

the least impact on overall class file size. Analyzing the behaviour of each of the<br />

options also suggests that this selection should have the least impact on application<br />

runtime. If sipush was used instead, it would be necessary to decode two operand<br />

bytes rather than one, resulting in both slower application runtime and larger class<br />

file sizes. Making use of ldc or ldc w would require one or two operand bytes to be<br />

decoded. Following that, a value would need to be copied from the constant pool to

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

Saved successfully!

Ooh no, something went wrong!