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.

11<br />

also has the ability to contain several element types that divide a single<br />

slot into two halves, where each half represents the index of another entry<br />

in the constant pool. A relatively small number of instructions access<br />

the constant pool, but it is an absolutely critical component of the virtual<br />

machine. Examples of such instructions include the field access bytecodes,<br />

the invoke* bytecodes and the ldc, ldc w and ldc2 w bytecodes.<br />

2.3 The Java Instruction Set<br />

The Java Virtual Machine instruction set includes a total of 201 distinct bytecodes,<br />

each of which performs a specific task. These bytecodes are used to represent the<br />

functionality of a Java application within a class file. The java compiler, javac,<br />

generates the class files and the bytecodes that they contain.<br />

In many ways, Java bytecodes are similar to assembly language instructions. Each<br />

bytecode performs a relatively small amount of work, with a typical Java language<br />

statement being translated into several bytecodes. The bytecodes defined by the Java<br />

Virtual Machine Specification can be categorized into broad families. These families<br />

are discussed in the following sections.<br />

2.3.1 Loads and Stores<br />

Load and store bytecodes are used to move values between the operand stack and<br />

the local variable array. Load bytecodes copy a value from the local variable array,<br />

pushing it onto the stack. Store bytecodes pop the top value from the operand stack<br />

and store it into a slot in the local variable array. Of the 201 bytecodes defined by<br />

astore dstore fstore istore lstore<br />

astore 0 dstore 0 fstore 0 istore 0 lstore 0<br />

astore 1 dstore 1 fstore 1 istore 1 lstore 1<br />

astore 2 dstore 2 fstore 2 istore 2 lstore 2<br />

astore 3 dstore 3 fstore 3 istore 3 lstore 3<br />

aload dload fload iload lload<br />

aload 0 dload 0 fload 0 iload 0 lload 0<br />

aload 1 dload 1 fload 1 iload 1 lload 1<br />

aload 2 dload 2 fload 2 iload 2 lload 2<br />

aload 3 dload 3 fload 3 iload 3 lload 3<br />

Table 2.1: Load and Store Bytecodes

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

Saved successfully!

Ooh no, something went wrong!