Constraint based optimization of stationary fields

In many scenarios a field holds a value that is constant beyond a certain point in the execution of the program. However, Java only allows it to be marked as being final in relation to the control-flow of the program. We present a language extension whereby the programmer can express that a field will have an unchanging value once it satisfies a given constraint. That is the constraint is the guarantee of finality as opposed to the particular code region. A field holding an unchanging value is said to be stationary. The resulting change of the language has similar pitfalls to keywords that express immutability in a dynamic system. However, it provides a number of advantages: ability for improved partial evaluation and specialisation in dynamic compilation, simple inspection to show thread safety and richer information to the runtime environment. We present an implementation of our proposed language extension to Java in the Jikes Research Virtual Machine (RVM). We use class loading as a case study of where lazy initialisation occurs. In code that is frequently executed the probability of a referenced class being uninitialised is less than 1% for method accesses and for fields typically 0%. We create an optimization framework that uses this information to perform specialisation and partial evaluation. We demonstrate that on average 61.32% of accesses occur to fields in their stationary state. We demonstrate that stationary information allows optimizations achieving a best case 3.90% speedup of benchmark applications, and 1.67% speedup on average.

[1]  Gavin Brown,et al.  Intelligent selection of application-specific garbage collectors , 2007, ISMM '07.

[2]  Stephen J. Fink,et al.  The Jalapeño virtual machine , 2000, IBM Syst. J..

[3]  Frank Yellin,et al.  The Java Virtual Machine Specification , 1996 .

[4]  Vivek Sarkar,et al.  Immutability specification and its applications , 2002, JGI '02.

[5]  Panagiota Bilianou Runtime value specialization , 2008 .

[6]  Rafael Dueire Lins,et al.  Garbage collection: algorithms for automatic dynamic memory management , 1996 .

[7]  Niklas Röjemo Garbage Collection, and Memory Efficiency, in Lazy Functional Languages , 1995 .

[8]  Michael D. Ernst,et al.  Javari: adding reference immutability to Java , 2005, OOPSLA '05.

[9]  Matthew Arnold,et al.  Adaptive optimization in the Jalapeño JVM , 2000, OOPSLA '00.

[10]  David Holmes,et al.  Java Concurrency in Practice , 2006 .

[11]  Francis C. M. Lau,et al.  JESSICA: Java-Enabled Single-System-Image Computing Architecture , 2000, J. Parallel Distributed Comput..

[12]  Monica S. Lam,et al.  Automatic inference of stationary fields: a generalization of java's final fields , 2008, POPL '08.

[13]  Vivek Sarkar,et al.  Immutability specification and its applications: Research Articles , 2005 .

[14]  Steven S. Muchnick,et al.  Advanced Compiler Design and Implementation , 1997 .

[15]  Amer Diwan,et al.  The DaCapo benchmarks: java benchmarking development and analysis , 2006, OOPSLA '06.

[16]  David Hovemeyer,et al.  Status report on JSR-305: annotations for software defect detection , 2007, OOPSLA '07.

[17]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[18]  Vivek Sarkar,et al.  X10: an object-oriented approach to non-uniform cluster computing , 2005, OOPSLA '05.