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.

13<br />

...<br />

i − 1<br />

iload 0x04 dstore 0x07<br />

i i + 1 i + 2 i + 3<br />

...<br />

i + 5<br />

Figure 2.2: A Code Stream Containing a Load Bytecode and a Store Bytecode<br />

the bytecodes occur at an arbitrary location within the code stream. This notation<br />

will be used to represent code streams graphically throughout the remainder of this<br />

document.<br />

Four additional load and four additional store bytecodes are also provided for each<br />

data type. Each of these bytecodes is only able to access one specific element within<br />

the local variable array. Consequently, these bytecodes do not require an operand<br />

because the slot which is accessed is fully determined by the opcode alone. The<br />

names of these opcodes specify the position that is accessed as the last character<br />

in the opcode name. These bytecodes follow the naming pattern load or<br />

store where is one of the characters listed in Table 2.2 and is<br />

an integer between 0 and 3. For example, the bytecode that would load local variable<br />

0 onto the stack as an object reference is aload 0 while the bytecode istore 3 is<br />

used to pop an integer from the operand stack and store it into local variable 3.<br />

2.3.2 Constant Loading<br />

Constant loading bytecodes are used to place literal values onto the top of the operand<br />

stack. The Java Virtual Machine Specification devotes 20 bytecodes to this purpose.<br />

They are listed in Table 2.3. Like the load and store bytecodes, different bytecodes<br />

are used in order to work with values of different types.<br />

The Java Virtual Machine Specification provides bytecodes that use three different<br />

techniques in order to place a constant value onto the operand stack. The simplest<br />

aconst null dconst 0 iconst m1 iconst 3<br />

fconst 0 dconst 1 iconst 0 iconst 4<br />

fconst 1 lconst 0 iconst 1 iconst 5<br />

fconst 2 lconst 1 iconst 2 bipush<br />

sipush ldc ldc w ldc2 w<br />

Table 2.3: Constant Loading Bytecodes

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

Saved successfully!

Ooh no, something went wrong!