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.

152<br />

problem occurs for exceptions as was found for branching – there is no straight forward<br />

way to indicate what portion of a multicode is handled by one exception handler and<br />

what portion is handled by another exception handler. In addition to the difficulties<br />

with expressing the exception handler ranges, allowing a multicode to be split across<br />

multiple exception handlers would have serious implications for any optimizations that<br />

change the order of execution of the statements that implement the functionality of<br />

the multicode. As a consequence, substitutions are not performed on occurrences of<br />

the sequence if any entries in the exception handler list includes a start pc, end pc<br />

or handler pc value that specifies a bytecode other than x 1 .<br />

A class file mutator tool was developed that is capable of modifying Java class<br />

files. This tool is able to perform the despecializations described in previous chapters<br />

as well as multicode substitutions. Its input consists of a Java class file and a rule file<br />

which describes a set of manipulations to apply to the class file. Two rule types are<br />

supported: despecialization rules and multicode substitution rules. A despecialization<br />

rule includes a single opcode name and replaces all occurrences of that opcode with<br />

its equivalent general purpose form. A substitution rule consists of a list of bytecodes<br />

that make up the multicode and a (free) opcode that will be used to represent the<br />

multicode in the code streams. The substitution rule to replace all occurrences of the<br />

bytecode sequence aload 0 getfield is shown below:<br />

substitute aload 0 getfield -> o203<br />

Unfortunately, the bytes saved by replacing the bytecode sequence with a multicode<br />

complicate the substitution process slightly. Because of the change in size, extra<br />

work must be performed for some bytecode operands in order to ensure that they<br />

refer to the correct location in the code stream after the substitution is performed.<br />

Problematic bytecodes include all of the conditional branch bytecodes as well as the<br />

goto and goto w bytecodes. Updates must also be performed in order to ensure that<br />

exceptions cover the same bytecode ranges after despecialization is performed.<br />

Figure 7.6 illustrates the adjustment that must be performed to the operands<br />

of an ifeq bytecode. The top portion of the figure shows the original code stream<br />

before multicode substitution has been performed. The bytecode sequence aload 0<br />

→ getfield has been replaced with a multicode, denoted by mc in the lower portion<br />

of the diagram. Notice that performing this substitution has reduced the value of the<br />

second operand to ifeq by one because the distance spanned by the branch has been<br />

reduced by one byte. The technical implementation details describing how this size<br />

change was handled by the class file mutator tool are presented in Section 11.

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

Saved successfully!

Ooh no, something went wrong!