Escape Analysis for Java Will von Rosenberg Noah Wallace.

Slides:



Advertisements
Similar presentations
Interprocedural Analysis. Currently, we only perform data-flow analysis on procedures one at a time. Such analyses are called intraprocedural analyses.
Advertisements

Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Coalescing Register Allocation CS153: Compilers Greg Morrisett.
COMPILERS Register Allocation hussein suleman uct csc305w 2004.
SSA.
Analysis of programs with pointers. Simple example What are the dependences in this program? Problem: just looking at variable names will not give you.
Prof. Necula CS 164 Lecture 141 Run-time Environments Lecture 8.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Contd... Objectives Explain the design, use, and operation of a linear list Implement a linear.
Parameterized Object Sensitivity for Points-to Analysis for Java Presented By: - Anand Bahety Dan Bucatanschi.
Semi-Sparse Flow-Sensitive Pointer Analysis Ben Hardekopf Calvin Lin The University of Texas at Austin POPL ’09 Simplified by Eric Villasenor.
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
Interprocedural analyses and optimizations. Costs of procedure calls Up until now, we treated calls conservatively: –make the flow function for call nodes.
Approach #1 to context-sensitivity Keep information for different call sites separate In this case: context is the call site from which the procedure is.
Runtime Environments Source language issues Storage organization
Code Generation Professor Yihjia Tsai Tamkang University.
Previous finals up on the web page use them as practice problems look at them early.
Compositional Pointer and Escape Analysis for Java Programs Martin Rinard Laboratory for Computer Science MIT John Whaley IBM Tokyo Research Laboratory.
Scaling CFL-Reachability-Based Points- To Analysis Using Context-Sensitive Must-Not-Alias Analysis Guoqing Xu, Atanas Rountev, Manu Sridharan Ohio State.
1 Pertemuan 20 Run-Time Environment Matakuliah: T0174 / Teknik Kompilasi Tahun: 2005 Versi: 1/6.
Range Analysis. Intraprocedural Points-to Analysis Want to compute may-points-to information Lattice:
Run time vs. Compile time
Intraprocedural Points-to Analysis Flow functions:
A simple approach Given call graph and CFGs of procedures, create a single CFG (control flow super-graph) by: –connecting call sites to entry nodes of.
Run-time Environment and Program Organization
From last time: Inlining pros and cons Pros –eliminate overhead of call/return sequence –eliminate overhead of passing args & returning results –can optimize.
Comparison Caller precisionCallee precisionCode bloat Inlining context-insensitive interproc Context sensitive interproc Specialization.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Reps Horwitz and Sagiv 95 (RHS) Another approach to context-sensitive interprocedural analysis Express the problem as a graph reachability query Works.
Schedule Midterm out tomorrow, due by next Monday Final during finals week Project updates next week.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
Chapter 7: Runtime Environment –Run time memory organization. We need to use memory to store: –code –static data (global variables) –dynamic data objects.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
P ARALLEL P ROCESSING I NSTITUTE · F UDAN U NIVERSITY 1.
Analyses and Optimizations for Multithreaded Programs Martin Rinard, Alex Salcianu, Brian Demsky MIT Laboratory for Computer Science John Whaley IBM Tokyo.
Chapter 19: Binary Trees. Objectives In this chapter, you will: – Learn about binary trees – Explore various binary tree traversal algorithms – Organize.
Software Testing and Maintenance Lecture 4 Graph Coverage for Design Element Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
Compiler Construction
CSc 453 Runtime Environments Saumya Debray The University of Arizona Tucson.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Runtime Environments. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
BİL 744 Derleyici Gerçekleştirimi (Compiler Design)1 Run-Time Environments How do we allocate the space for the generated target code and the data object.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Using Types to Analyze and Optimize Object-Oriented Programs By: Amer Diwan Presented By: Jess Martin, Noah Wallace, and Will von Rosenberg.
Pointer Analysis for Multithreaded Programs Radu Rugina and Martin Rinard M I T Laboratory for Computer Science.
7. Runtime Environments Zhang Zhizheng
Pointer and Escape Analysis for (Multithreaded) Programs Martin Rinard MIT Laboratory for Computer Science.
Pointer and Escape Analysis for Multithreaded Programs Alexandru Salcianu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
Pointer Analysis – Part I CS Pointer Analysis Answers which pointers can point to which memory locations at run-time Central to many program optimization.
 Activity diagram is basically a flow chart to represent the flow from one activity to another activity.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Runtime Environments Chapter 7. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
Code Optimization More Optimization Techniques. More Optimization Techniques  Loop optimization  Code motion  Strength reduction for induction variables.
Abstract Interpretation and Future Program Analysis Problems Martin Rinard Alexandru Salcianu Laboratory for Computer Science Massachusetts Institute of.
Run-Time Environments Presented By: Seema Gupta 09MCA102.
Code Generation Instruction Selection Higher level instruction -> Low level instruction Register Allocation Which register to assign to hold which items?
Compositional Pointer and Escape Analysis for Java programs
Run-Time Environments Chapter 7
Software Testing and Maintenance 1
Compositional Pointer and Escape Analysis for Java Programs
Paul Ammann & Jeff Offutt
Demand-Driven Context-Sensitive Alias Analysis for Java
Dr. Mustafa Cem Kasapbaşı
Pointer analysis.
UNIT V Run Time Environments.
Linked List Functions.
Presentation transcript:

Escape Analysis for Java Will von Rosenberg Noah Wallace

Points-to vs. Escape Analysis  Points-to –Memory disambiguation –To determine if two pointers can be resolved to point at the same location –Points-to graph should lead to the same location for correctness, i.e. they may resolve to the same memory location  Escape Analysis –Identify objects that might escape a (dynamic) scope such as a method invocation or a thread object. –Connection graph may lead to different nodes, but could still be correct –Can safely ignore the calling context for escape analysis.

Reasons for Escape Analysis  If an object does not escape the method it was created in, then that object can be allocated onto the stack instead of the heap, since heap allocation is (supposedly) time expensive.  If an object does not escape the thread it was created in, then that object does not need to be synchronized. That means that lock() and unlock() do not need to be used on it. These synchronization methods are inherently time expensive.

Escape Analysis Definitions and Propositions  An object is said to escape a Method if the lifetime of the object is larger than the lifetime of the Method. That is to say that the scope of the object is greater than the scope of the Method it was created in.  An object is said to escape a Thread if another thread, not equal to the first, uses (locks) that object.  If an object does not escape the method, !Escapes(O, M), and that method was invoked in thread T, then it can be said that the object does not escape the thread, !Escapes(O, T).  (Proposition 2.3)

Escape Lattice  GlobalEscape –Escapes all Methods and Threads  ArgEscape –Escapes the Methods in which it was created, but not the thread invocation  NoEscape –Does not escape either the Method and the Thread

Connection Graph  Capture the connectivity relationship among objects

Connection Graph  Fid() –A unique number that identifies a field within a class, this field identifier or offset, is unique within the class, and can be compared to instances of the same class.  The notation refers to a reference node that contains an arbitrary number of deferred edges, that lead to a points-to edge.  The PointsTo() function refers to all nodes, such as the above, where m, through a sequence of deferred edges, points-to n. The function returns the set of all n’s that m points-to.

Intraprocedural Analysis  Flow-sensitive and Flow-insensitive  Simplify presentation by –splitting a multiple level reference expression into a two level reference. () –Bypass() function  Eliminates all edges to a node, either incoming, or outgoing.  Redirects them to a more precise location for the purpose of flow-sensitive analysis

Intra (cont’d)  P=new r() –FS (Flow Sensitive) new object node is created and ByPass(p). –FI new object node created with a points to edge from p to new node. ByPass(p) is not called.  P=q –FS apply ByPass(p) and add the deferred edge to q. –FI ignore ByPass(p) and add the deferred edge to q.  P.f=q –FS and FI are treated the same. We ignore ByPass(p) and add the deferred edges from V-> q. Where V are the field nodes. Phantom nodes may be created if pointsto(p) = 0 and field nodes may be created if V is empty.  P=q.f –FS apply ByPass(p) and add the deferred edge to V. –FI ignore ByPass(p) and add the deferred edge to V.

Interprocedural Analysis  Method Entry  Method Exit  Immediately before method invocation  Immediately after method invocation

Method Entry  Create Phantom reference nodes –F1  a  F1 is the phantom node and a is the formal parameters. –EscapeState[F1] = NoEscape  Because it is a phantom node and created and deleted in the Method. –EscapeState[a1] = ArgEscape  a1 is created outside the method so it can leave the method.

Method Exit  Partitions graph into three subgraphs –Those nodes reachable by GlobalEscape –Those nodes reachable by ArgEscape –Those nodes that are left are NoEscape  The union of GlobalEscape and ArgEscape graphs are deamed the NonLocalGraph  The NoEscape graph is deamed the LocalGraph

Immediately Before a Method  Each parameter (object node) of the caller will be mapped to an object node in the callee  Once inside, the Phantom reference nodes will be created referring back to the parameter object node.  These correlations will be kept track of for both the purpose of the return values of the nodes and the ability to reconstruct the connection graph in the event of another call of the same function.

Immediately After a Method  The mapping from the Before, a1, a2…aN, will then get the escape status of the phantom nodes in the callee.  The edges will be updated as well, showing the new relationships that were effected by the callee.

Updating Caller Nodes  This ensures that the node ai, in the caller function, will map to the correlated a^I, in the callee function.  Through recursion, we also ensure that the set PointsTo(ai) will be equal to the set PointsTo(a^I)

Results

Results (cont’d)

 Percentage of objects that may be allocated on the stack exceeds 70% of all dynamically created objects in three out of ten benchmarks.  11% to 92% of all lock operations are eliminated in the ten programs.  And execution time reduction ranges from 2% to 23%.

Results Final

We’re done! …………but wait…

 Congrats to Noah and Kaleem (Hopefully) on their last day of class for a while

 Does anybody have anything to do for tomorrow? –Who’s 21? (raise your hand!) –Who wants to go to Flats? For Margarita’s? –Who wants to go to Flats? For Margarita’s? –PhD’s allowed! –PhD’s allowed!