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.

9<br />

performs garbage collection, a class file loader, and an execution engine. While all<br />

components of the interpreter are necessary in order to run a Java application, the<br />

execution engine is the component that is of most relevance to the studies conducted<br />

as part of this thesis.<br />

There are four core data structures that are maintained as part of the execution<br />

engine for the interpreter. Two additional variables are needed in order to maintain<br />

the current location within these data structures. Each of these is described in the<br />

following paragraphs. They are also presented graphically in Figure 2.1.<br />

Code: This array of bytes contains the opcodes and operands that represent<br />

the functionality of a method. An index into the array, denoted pc,<br />

is also maintained which represents the current location with the array.<br />

Several implementations are possible including representing the program<br />

counter as integer and dereferencing the array through the use of square<br />

brackets. Alternatively, the program counter can be represented as a byte<br />

pointer, allowing the current byte from the code stream to be acquired by<br />

dereferencing the pointer. The examples used in the remainder of this document<br />

will make use of an integer representation for the program counter<br />

in order to make the examples more clear.<br />

Stack: The operand stack is used to hold temporary values that will<br />

be used in a subsequent computation within the same method. It is commonly<br />

represented as an array of 4-byte slots. When category two values –<br />

values of type long or type double which occupy 8 bytes – are placed on the<br />

stack they occupy two adjacent slots. A stack pointer is also maintained<br />

which points to the element within the array which currently represents<br />

the top of the stack. Like the program counter, the stack pointer can be<br />

represented as an integer or as a pointer type. The examples presented<br />

in this chapter will make use of an integer representation of the stack<br />

pointer.<br />

Local Variables: Like the stack, the local variables are typically represented<br />

as an array of 4-byte slots where category two values are represented<br />

using two adjacent slots. No separate pointer is needed for the local variables<br />

since the local variable being accessed is always specified explicitly<br />

as an operand or known definitively from the opcode being executed.<br />

Constant Pool: The constant pool is also represented as an array of<br />

slots. In addition to containing some elements which occupy two slots, it

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

Saved successfully!

Ooh no, something went wrong!