Advanced Processor Technologies Home
APT Advanced Processor Technologies Research Group

Constraint Based Optimization of Stationary Fields

Ian Rogers, Jisheng Zhao, Chris Kirkham and Ian Watson

Abstract

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.