To compete with optimized C, object-oriented languages need classical optimizations as well as specific object-oriented optimizations. Therefore, a compiler infrastructure that enables object-oriented compiler research is of great interest for the research community. The SUIF compiler system with the OSUIF extension offers such a research environment. SUIF defines an intermediate representation for procedural languages and offers standard optimization passes. OSUIF extends SUIF with an intermediate representation tailored towards object-oriented languages, hence allowing specific object-oriented optimizations.
To enable Java-related compiler research in (O)SUIF, we have implemented j2s, a Java bytecode front end for the OSUIF/SUIF 2.0 compiler system. Our compiler uses off-line compilation, so that the whole program is known at compile time. Thus, static whole-program optimizations such as class hierarchy analysis and type inference can be implemented with (O)SUIF and applied during the compilation.
j2s supports the complete Java Virtual Machine specification, except for threads and exception handling, which are currently not supported by the runtime system and (O)SUIF. Because we implemented an off-line compiler, the dynamic loading of classes is also not supported.
The compiler is divided into the (O)SUIF front end and the runtime system. The main part of the thesis describes the compilation passes, which consist of Java class loading, resolution of symbolic references in class files, control flow graph generation, data flow analysis to recover lost type information in class files, and finally the actual (O)SUIF code generation. The compiler generates either plain SUIF 2.0 or OSUIF code.
Java, in contrast to C, requires a sophisticated runtime system. This thesis contains a detailed description of the interface between j2s and the runtime system; the runtime system itself has been written by Andrew Rutz as part of his Master's thesis.
The current version of j2s compiles Java applications that require neither threads nor exception handling during program execution. Despite these restrictions a large number of Java applications compiles and executes. For example, our compiler can handle the transitive closure of the JDK1.2beta2 javac compiler, which consists of 538 Java classes. The javac executable generated with our compiler runs about twice as fast as the JDK1.2beta2 Virtual Machine.
|