Purity analysis for JavaScript through abstract interpretation. Nicolay, J., Stiévenart, Q., De Meuter, W., & De Roover, C. Journal of Software: Evolution and Process, Wiley, 12, 2017.
doi  abstract   bibtex   
We present a static analysis for determining whether and to what extent functions in JavaScript programs are pure. To this end, the analysis classifies functions as pure functions, observers, or procedures. A function is pure if none of its executions generate or depend upon externally observable side effects. A function is an observer as soon as one of its executions depends on an external side effect, but none of its executions generate observable side effects. Otherwise, the function is classified as a procedure. Function executions and associated callers are found by traversing all reachable function execution contexts on the call stack at the point where an effect occurs. Our approach is based on a flow analysis that, in addition to computing traditional control and value flow, keeps track of read and write effects. To increase the precision of our purity analysis, we combine it with an intraprocedural analysis that determines freshness of variables and objects. We formalize the core aspects of our technique and discuss its implementation and results on common JavaScript benchmarks. Results show that our approach is capable of determining function purity in the presence of higher-order functions, dynamic property expressions, and prototypal inheritance. When compared with existing purity analyses, we find that our approach is as precise or more precise than the existing analyses.
@article{f1aef97f46674da08c491d1fec1b06c7,
  title     = "Purity analysis for JavaScript through abstract interpretation",
  abstract  = "We present a static analysis for determining whether and to what extent functions in JavaScript programs are pure. To this end, the analysis classifies functions as pure functions, observers, or procedures. A function is pure if none of its executions generate or depend upon externally observable side effects. A function is an observer as soon as one of its executions depends on an external side effect, but none of its executions generate observable side effects. Otherwise, the function is classified as a procedure. Function executions and associated callers are found by traversing all reachable function execution contexts on the call stack at the point where an effect occurs. Our approach is based on a flow analysis that, in addition to computing traditional control and value flow, keeps track of read and write effects. To increase the precision of our purity analysis, we combine it with an intraprocedural analysis that determines freshness of variables and objects. We formalize the core aspects of our technique and discuss its implementation and results on common JavaScript benchmarks. Results show that our approach is capable of determining function purity in the presence of higher-order functions, dynamic property expressions, and prototypal inheritance. When compared with existing purity analyses, we find that our approach is as precise or more precise than the existing analyses.",
  keywords  = "abstract interpretation, freshness analysis, JavaScript, purity analysis, side effect analysis",
  author    = "Jens Nicolay and Quentin Sti{\'e}venart and {De Meuter}, Wolfgang and {De Roover}, Coen",
  year      = "2017",
  month     = "12",
  doi       = "10.1002/smr.1889",
  language  = "English",
  volume    = "29",
  journal   = "Journal of Software: Evolution and Process",
  issn      = "2047-7473",
  publisher = "Wiley",
  number    = "12",
}

Downloads: 0