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.

170<br />

iload 1 → iconst 1 → iadd → istore 2 →<br />

This sequence implements a Java statement of the form a = b + 1, where variable<br />

a is stored in local variable position 2 and variable b is stored in local variable position<br />

1. The codelet which represents the equivalent multicode for this sequence is shown<br />

below without any optimizations having been performed.<br />

// iload_1:<br />

sp++;<br />

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

// iconst_1:<br />

sp++;<br />

stack[sp] = 1;<br />

// iadd:<br />

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

sp--;<br />

// istore_2:<br />

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

sp--;<br />

Initially, optimizing this code is complicated by an aliasing problem caused by<br />

the fact that stack[sp] refers to a different memory location at different points<br />

within the codelet. Consequently stack[sp] may have a different value on different<br />

lines. It is possible to collapse all stack pointer adjustments into a single statement,<br />

eliminating the aliasing problem. In addition, this has the advantage of reducing the<br />

total number of stack adjustments performed from n, the length of the multicode, to<br />

one for many multicodes. In this particular case, no stack adjustment is necessary<br />

after they are collapsed because the net adjustment to the stack for this sequence<br />

zero. The sequence that results from collapsing all of the stack adjustments is shown<br />

below.

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

Saved successfully!

Ooh no, something went wrong!