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.

37<br />

method. However, the Java Virtual Machine Specification also permits a class file to<br />

contain custom attributes. Furthermore, attributes are structured in a manner that<br />

ensures that all virtual machines can parse custom attributes correctly, even if they<br />

do not recognize the information stored within them.<br />

Each attribute begins with an indication of its name. This is followed by a fourbyte<br />

value specifying the attribute’s total size. The data stored in the attribute is<br />

present immediately after its size. As a result, if a virtual machine encounters a nonstandard<br />

attribute that it does not recognize, the attribute can be ignored by simply<br />

skipping the attribute and continuing to parse the Java class file.<br />

Using additional attributes in this manner can aid in numerous types of optimizations<br />

including the removal of unnecessary array bounds checks and null pointer<br />

checks [91], and method inlining [109]. Other work has also been conducted which<br />

provided information to the JIT compiler to improve low level operations such as<br />

instruction scheduling and register allocation [16, 63]. Further studies have also considered<br />

communicating profile data to the optimization system through attributes<br />

[70]. The goal of this strategy is to provide information about what methods will execute<br />

with greatest frequency so that targeted optimizations can be performed before<br />

any profile data is collected for the current run of the application.<br />

Regardless of the type of optimization being performed, care must be taken to<br />

ensure that the attribute does not contain information derived from additional class<br />

files. If this constraint is not met, invalid information may be used at run time because<br />

different versions of the class file were utilized at compile time and run time. Since the<br />

data contained within non-standard attributes is not validated by the verifier, such<br />

errors will not be detected until an unexpected behaviour occurs unless the extensions<br />

to the virtual machine that read the attribute data validate it before use.<br />

3.2.3 Devirtualization of Method Calls<br />

Java is an object oriented language which provides polymorphism by allowing derived<br />

classes to override methods originally defined in the parent class. Consequently,<br />

many of the methods invoked in Java applications are virtual, requiring that the<br />

actual method invoked be determined at runtime based on the dynamic type of the<br />

receiver object. Performing virtual method dispatch is more expensive than nonvirtual<br />

dispatch. This cost occurs because the precise method to invoke must be<br />

determined at runtime.<br />

Numerous implementations of virtual method dispatch are possible [59]. However,

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

Saved successfully!

Ooh no, something went wrong!