Garbage collection is one of the most important features of Java, which is also called automatic memory management as Garbage Collector in Java Virtual Machine (JVM) automatically reclaims the unused memory for variables/objects. It frees programmers from the error-prone task of having to worry about details of memory allocation and reclamation.
Garbage collector is usually implemented as a single-thread or a set of threads; it requires extra memory and consumes CPU resources just like applications. In the traditional implementation of garbage collector, when garbage collecting threads work, JVM pauses all application threads until the collection is completed. This is known as a stop-the-world collection. If the collection time is too long, it will make a great impact on the executing efficiency of applications. In order to reduce the space and time cost of garbage collectors, other than further improving the garbage collection algorithms, a more effective approach is presented to provide runtime and compiler support for garbage collector. That is to say, Just-in-time (JIT) compiler analyses the applications to instrument the explicit "free" instructions and even the special object allocation instructions to assist garbage collector in improving the object allocation and reclamation.
This project explores techniques to improve Java memory management through JIT compiler assistance (not only on object reclamation, but also on object allocation). We implement them on the open source Java SE project - Apache Harmony.
[TOP]Garbage collection (GC) technology is prevailing in modern languages and their compilation runtime systems. The automatic memory management system of Java language based on GC brings convenience to Java programmers, but meantime it reduce executing efficiency of Java applications due to the GC's extra runtime cost. Although GC's performance has been improved dramatically in past decade, it is still one of the dominating factors for overall Java application's performance. For example, a typical enterprise-style workload like SPECjbb2005 usually spends ~10% of its total execution time in GC. The purpose of putting forward research on JIT-assisted GC is to hope using program analysis, compilation optimization and such techniques to assist GC in completing Java memory management, thus improving GC performance further. This is very important to improve the entire performance of compilation runtime system which based on GC.
[TOP]We research and develop JIT-assisted GC on an actual JVM (the DRLVM of Apache Harmony). Figure 1 shows the framework of JIT-assisted GC, it mostly refers to three modules which are JIT, GC and VMCore. Our work focuses on the shadow areas.
In Harmony, JIT uses pipeline compilation mechanism to compile and optimize Java byte code. The pipeline loads the byte code of the to-be-compiled method in turn, and the Java byte code translator first translates the byte code into the platform-independent high-level intermediate representation (HIR), then the code selector transforms HIR into the platform-dependent low-level intermediate representation (LIR), and at last the code emitter emits the native code. VMCore takes charge of driving all these actions. Moreover JIT executes a series of optimization passes on the HIR and LIR of the application program.
The research contents of JIT-assisted GC mainly include the following three parts: