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.

72<br />

possible that performing despecialization may cause the number of elements in the<br />

constant pool to grow beyond the maximum number permitted. Should this occur it<br />

is necessary to go through the difficult process of splitting the class file into two or<br />

more new class files. In practice it was not necessary to perform this procedure for<br />

any of the class files in any of the libraries or the SPEC JVM98 Benchmark Suite.<br />

Before despecialization was performed the largest number of elements in any constant<br />

pool was 4302. This grew to 4546 elements after complete despecialization was<br />

performed. These values are far less than the 65535 elements permitted by the Java<br />

Virtual Machine Specification.<br />

Some limits are present within the Java Virtual Machine which are not explicitly<br />

stated. For example, the maximum displacement of a conditional branch is 32768<br />

bytes backward or 32767 bytes forward. This constraint is a consequence of the fact<br />

that the conditional branches express their target as a displacement stored in two<br />

bytes. Since despecialization generally increases class file size, it is possible that<br />

performing despecialization could result in a conditional branch that needs to span<br />

more than the maximum number of bytes permitted. However, such a branch could be<br />

transformed into a conditional branch to a goto or goto w bytecode that subsequently<br />

branches to the desired destination. This problem does not exist for unconditional<br />

branches because goto w uses 4 operand bytes to specify the displacement, allowing<br />

any location within the method to be reached from any other location. In practice it<br />

was found that this constraint did not cause a problem. This is evident from the fact<br />

that no class file had a code attribute in excess of 32767 bytes after despecialization.<br />

Further analysis revealed that the longest branch encountered before despecialization<br />

spanned 9896 bytes. After despecialization was performed the longest branch<br />

encountered spanned 12940 bytes.<br />

The Java Virtual Machine Specification states that the maximum number of elements<br />

that may reside on the operand stack at any time is restricted to 65535. Some<br />

branch despecializations increase the maximum number of elements that must reside<br />

on the stack at any given point in time. For example, some of the branch despecializations<br />

discussed in Section 4.1.5 potentially increase the maximum number of<br />

elements on the stack. This occurs because the zero value used during the comparison<br />

was not present on the stack before despecialization but is present on the stack<br />

after despecialization. Consequently the maximum number of elements that may be<br />

present on the stack has increased by one. There is not an easy way to work around<br />

this constraint should it ever be violated. However this is not a serious concern as

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

Saved successfully!

Ooh no, something went wrong!