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.

259<br />

the level of entropy within the code stream. The implementation of these rules was<br />

considered so that future experiments might be conducted that considered the impact<br />

the order or distribution of the opcodes had on application performance.<br />

The bsub application was developed in C++. Object oriented design principles<br />

were used in order to represent the data that would be handled by the application.<br />

One class was developed which represented a Java class file. Additional class were<br />

created which represented the major structures within it. Examples of these structures<br />

include the constant pool, fields, methods, attributes, bytecodes and exceptions.<br />

A separate class was also developed to represent a rule.<br />

Addition helper functions were also developed. Some of these aided in the task of<br />

parsing the rules in the rule file. Others aided with reading and writing Java class files<br />

by providing an easy mechanism to read or write an element of a specific primitive<br />

data type. Using helper functions to read and write the multi-byte values within the<br />

Java class files made it easy to port bsub from a little endian architecture such as<br />

a Pentium III to a big endian architecture such as SPARC. The only changes made<br />

during the process were in these helper functions.<br />

The input to bsub consisted of the name of a class to process and the name of a<br />

rule file. Each of these values was provided as a command line argument for maximum<br />

flexibility. The first task performed by bsub was to parse the class file and rule file<br />

to verify that the input to the application was syntactically correct.<br />

If each of the input files was loaded successfully then the processing operations<br />

began. Each rule was applied to every method within the class in sequence, in the<br />

same order that they appeared in the rule file. As a result, later rules in the file could<br />

rely on earlier rules executing first. This also made it important that despecializations<br />

were performed in the correct order. For example, because despecializing ifeq<br />

introduces two bytecodes, an iconst 0 and a if icmpeq, it is important to ensure<br />

that iconst 0 is despecialized after ifeq. Otherwise, it is possible that occurrences<br />

of iconst 0 will reside in the output file after despecialization has been performed.<br />

Once every rule was applied to the code attribute for every method, a new version of<br />

the class file was written to disk, replacing the original file.<br />

It has already been observed that performing a despecialization or multicode substitution<br />

is not as simple as replacing all occurrences of a bytecode (for despecialization)<br />

or bytecode sequence (for a multicode substitution) with another bytecode.<br />

These transformations change the total size of the code stream and the distance that<br />

some branches span. Consequently, care was taken to ensure that branches and ex-

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

Saved successfully!

Ooh no, something went wrong!