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.

172<br />

Removing these unnecessary writes is accomplished by performing copy propagation<br />

to eliminate uses of memory locations above the top of the stack on the right<br />

hand side of assignments. Performing replacements where the value being propagated<br />

consists of only a single value results in the following codelet:<br />

// iload_1:<br />

stack[sp+1] = local_vars[1];<br />

// iconst_1:<br />

stack[sp+2] = 1;<br />

// iadd:<br />

stack[sp+1] = local_vars[1] + 1;<br />

// istore_2:<br />

local_vars[2] = stack[sp+1];<br />

Further uses of stack locations on the right side of assignment operations can be<br />

eliminated when complete expressions are propagated rather than only single values.<br />

Care needs to be used to ensure that performing such a propagation does not result<br />

in recomputing the same expression on several occasions. However, in this instance,<br />

propagating local vars[1] + 1 as the value of stack[sp+1] will still only require<br />

its value to be computed once when all of the optimizations have been performed.<br />

// iload_1:<br />

stack[sp+1] = local_vars[1];<br />

// iconst_1:<br />

stack[sp+2] = 1;<br />

// iadd:<br />

stack[sp+1] = local_vars[1] + 1;<br />

// istore_2:<br />

local_vars[2] = local_vars[1] + 1;<br />

Once these copy propagations have been performed, unnecessary assignments can<br />

be removed. In general, an assignment is unnecessary if the memory location on the<br />

left side of the assignment is known conclusively to be written to before it is read<br />

again. This is the case for the first 3 assignments in the preceding codelet because they<br />

each write to a memory location that is above the top of the stack when the codelet<br />

finishes executing. Consequently, the codelet required to implement the multicode<br />

iload 1 iconst 1 iadd istore 2 is reduced to a single assignment.

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

Saved successfully!

Ooh no, something went wrong!