Purity and side effect analysis for Java programs

A Sălcianu, M Rinard - … , Model Checking, and Abstract Interpretation: 6th …, 2005 - Springer
A Sălcianu, M Rinard
Verification, Model Checking, and Abstract Interpretation: 6th International …, 2005Springer
We present a new purity and side effect analysis for Java programs. A method is pure if it
does not mutate any location that exists in the program state right before the invocation of
the method. Our analysis is built on top of a combined pointer and escape analysis, and is
able to determine that methods are pure even when the methods mutate the heap, provided
they mutate only new objects. Our analysis provides useful information even for impure
methods. In particular, it can recognize read-only parameters (a parameter is read-only if the …
Abstract
We present a new purity and side effect analysis for Java programs. A method is pure if it does not mutate any location that exists in the program state right before the invocation of the method. Our analysis is built on top of a combined pointer and escape analysis, and is able to determine that methods are pure even when the methods mutate the heap, provided they mutate only new objects.
Our analysis provides useful information even for impure methods. In particular, it can recognize read-only parameters (a parameter is read-only if the method does not mutate any objects transitively reachable from the parameter) and safe parameters (a parameter is safe if it is read-only and the method does not create any new externally visible heap paths to objects transitively reachable from the parameter). The analysis can also generate regular expressions that characterize the externally visible heap locations that the method mutates.
We have implemented our analysis and used it to analyze several applications. Our results show that our analysis effectively recognizes a variety of pure methods, including pure methods that allocate and mutate complex auxiliary data structures.
Springer