Abstract
Traditional points-to analysis in Java provides binary "may-point-to" information, which often leads to overly conservative compiler optimizations. This paper presents JPPA (Java Probabilistic Points-to Analysis), a framework that quantifies the likelihood of a reference pointing to specific memory locations. By integrating flow-sensitive analysis with static branch prediction, JPPA enables speculative optimizations with high accuracy and a modest 1.2x performance overhead compared to traditional methods.
Introduction
Points-to analysis is a fundamental task in compiler optimization, determining the set of objects a reference variable might target at runtime. However, standard "may-point-to" analysis is inherently conservative. If a variable has a 99% probability of pointing to Object A and only a 1% probability of pointing to Object B, a traditional compiler must treat both possibilities with equal weight, potentially missing significant optimization opportunities.
Probabilistic Points-to Analysis (PPA) addresses this by assigning probabilities to each target. While PPA has been explored for languages like C, Java’s object-oriented features—such as inheritance and virtual method dispatch—introduce unique complexities. This paper introduces JPPA, a framework designed to handle these challenges and provide a more nuanced view of program memory behavior.
The JPPA Framework
The JPPA framework, implemented in a tool called Lukewarm using the Soot analysis framework, employs a four-stage process to compute probabilities:
- Call Graph Construction: Utilizing Rapid Type Analysis (RTA) to identify reachable methods and prune unreachable code.
- Intraprocedural CFG Building: Constructing Control Flow Graphs (CFGs) for individual methods, with edges weighted by static branch prediction (e.g., predicting how often an
if-elsebranch is taken). - Interprocedural CFG (ICFG) Assembly: Linking method graphs into a global super-graph.
- Data-Flow Analysis: Iteratively computing Probabilistic Points-to Graphs (PPGs) across the ICFG.
Handling Virtual Dispatch
A primary challenge in Java is virtual method dispatch. When a method like p.set() is called, the actual code executed depends on the runtime type of p. JPPA handles this by distributing probabilities across all potential receiver objects based on the probability distribution of the pointer itself.
As shown in Figure 1, if the analysis determines that p has a 75% chance of being a Square and a 25% chance of being a Circle, these weights are propagated into the respective method implementations. This allows the analysis to maintain a precise distribution even across complex call boundaries.
Probabilistic Points-to Graphs (PPGs)
The core output of JPPA is the Probabilistic Points-to Graph. Unlike traditional graphs that merely show edges, a PPG represents points-to sets as discrete probability distributions. At join points, such as the end of an if-else block, probabilities from different paths are mathematically merged by summing their weighted values.
Figure 4 illustrates this evolution. As the analysis progresses through various assignments, the graph tracks not only which objects are referenced (O1, O2, etc.) but also the probability of those references. This includes tracking field-level pointers, such as this.area or this.radius, providing a granular view of the heap state at any given program point.
Evaluation and Results
The authors evaluated JPPA using several well-known Java benchmark suites, including DaCapo and Ashes. The analysis was compared to both traditional points-to analysis (TPA) and dynamic runtime profiles (the "ground truth").
- Accuracy: JPPA's predicted probabilities closely matched actual runtime behavior, with a distance metric often below 0.15. This is a significant improvement over TPA, which effectively assumes a uniform distribution among all possible targets.
- Efficiency: Despite the added complexity of calculating floating-point probabilities, JPPA only incurred a 1.2x performance overhead compared to TPA. Memory usage remained comparable, making it a viable candidate for integration into production compilers.
Conclusion and Future Work
JPPA demonstrates that probabilistic analysis is both feasible and accurate for Java. By moving beyond binary "maybe" answers, it provides the data necessary for aggressive speculative optimizations. Future work includes improving the handling of object arrays, which currently dilute precision, and extending the framework to be context-sensitive to further improve results. Additionally, the authors suggest that integrating machine learning for better initial branch prediction could further refine the accuracy of the resulting points-to probabilities.
Summary updated