escape analysis for java - people
TRANSCRIPT
![Page 1: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/1.jpg)
1December 12, 1999
Escape Analysis for Java
J.-D. Choi, M. Gupta, M. Serrano, V. Sreedhar,
S. Midkiff, IBM T.J. Watson Research
OOPSLA ‘99
![Page 2: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/2.jpg)
2December 12, 1999
Outline
• Motivation
• Contributions
• Analysis Framework
• Algorithm
• Exceptions and Finalization in Java
• Experimental Results
• Conclusions
![Page 3: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/3.jpg)
3December 12, 1999
Motivation
• Stack allocation vs. heap allocation– No garbage collection overhead
– No synchronization
– More optimization possibilities
• Lock elimination– Reduce synchronization overhead
– Allocation in thread’s local memory
– Possibly avoid memory flush
![Page 4: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/4.jpg)
4December 12, 1999
Contribution
• Interprocedural framework
• Escape analysis for lock elimination
• Exception handling
• Connection graph abstraction
• Extensive experimental data
![Page 5: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/5.jpg)
5December 12, 1999
Escape Analysis Framework
• Definitions– Thread escape - object instance O escapes
thread T if visible by other thread
– Method escape - object instance O escapesmethod M if the lifetime of O exceeds thelifetime of M
![Page 6: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/6.jpg)
6December 12, 1999
Framework, cont.
• Connection graph– 4 types of nodes -
Reference, Object, Field,and Global nodes
– 3 types of edges -Points to, Deferred,and Field
• ByPass function
![Page 7: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/7.jpg)
7December 12, 1999
Algorithm Outline• An iterative dataflow algorithm
• Dataflow elements:CG annotated with EscapeStates
• Dataflow equations:
Cos = f s(Ci
s), Cis = ^r∈Pred(s)(Co
r)
• Until dataflow solution convergesIterate over methods in reverse topological order
![Page 8: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/8.jpg)
8December 12, 1999
Intraprocedural Analysis
• Basic statements– p = new t()
• Create new object node O
• Apply ByPass(p) (for FS analysis)
• Add a points-to edge from p to O
– p = q
• Apply ByPass(p) (for flow-sensitive)
• Add a deferred edge from p to q
![Page 9: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/9.jpg)
9December 12, 1999
Intraprocedural Analysis– p.f = q
• Find U = PointsTo(p)• Find V = {v s.t. u -> v, u ∈ U, and fid(v) = f}
• Add deferred edge from each v to q
– p = q.f
• Find U = PointsTo(q)• Find V = {v s.t. u -> v, u ∈ U, and fid(v) = f}
• Apply ByPass(p) (for FS analysis)
• Add deferred edge from q to each v
![Page 10: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/10.jpg)
10December 12, 1999
Intraprocedural Analysis, Example
![Page 11: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/11.jpg)
11December 12, 1999
Interprocedural Analysis
• Connection graph at method entry– Process fi = ai, for each formal fi;
ai is a phantom reference node
– EscapeState[fi] = NoEscape,
– EscapeState[ai] = ArgEscape
• Connection graph at method exit– return=ref, for each returned reference
– ByPass each reference node
– Do reachability analysis over CG of M
![Page 12: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/12.jpg)
12December 12, 1999
Reachability Analysis
• At method exit!
• A two phase transitive closure1. Find globally escaping nodes
2. Find argument escaping nodes
• Partition CG of M into three parts– Global - set reachable from a GlobalEscape node
– Arg - set reachable from an ArgEscape node
– Local - set which retains NoEscape
![Page 13: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/13.jpg)
13December 12, 1999
Interprocedural Analysis, cont.
• Connection graph before a call site– Process âi = ui,
âi is a dummy node, ui is an actual
– â1 and u1 reference the receiver object
• Connection graph after a call site– “Map” âi’s to ai’s
– Add nodes to caller
– Add edges to caller
![Page 14: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/14.jpg)
14December 12, 1999
MapsTo
• Propagates effects of the callee to caller
• Recursive rules– ai -> âi
– Op -> Oq Op∈PointsTo(p), Oq∈PointsTo(q),p and q are ai, and âi,or p and q are corresponding fields intwo mapping objects Op and Oq
![Page 15: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/15.jpg)
15December 12, 1999
Example
![Page 16: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/16.jpg)
16December 12, 1999
Java Special Features
• Bottom methods– Most conservative CG, using type information
• Exceptions– Kill edges from “try-local” nodes only
• Finalization– If object class overrides finalize - mark
GlobalEscape
![Page 17: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/17.jpg)
17December 12, 1999
Experiments• IBM HP (static) Java Compiler
• 333MHz Power PC, AIX 4.1.5, 1 Mb L2,512 Mb RAM
• 10 medium to large sized Java programs
• Two optimizations
• Four variants of the algorithm– Flow Sensitive– Bounded Field FS - k mod m, m=3– Flow Insensitive– Bounded Field FI
![Page 18: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/18.jpg)
18December 12, 1999
Benchmarks
![Page 19: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/19.jpg)
19December 12, 1999
Experimental Results• Stack Allocation of NoEscape objects
HPCJ native alloca routine
![Page 20: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/20.jpg)
20December 12, 1999
Experimental Results• Lock Elimination
At object use site bypass compare &swap
![Page 21: Escape Analysis for Java - People](https://reader031.vdocument.in/reader031/viewer/2022021006/62038d0bda24ad121e4aba37/html5/thumbnails/21.jpg)
21December 12, 1999
Conclusions
• 2 - 23% speedup, 8% avg
• Lots of stack-allocable objects
• 11 - 92% of locks eliminated
• FS as bad as FI?
• Very similar to point-to Graphs
• Need benchmarks with larger footprint
• Need algorithm time and space