incrementalized pointer and escape analysis
play

Incrementalized Pointer and Escape Analysis Frdric Vivien Martin - PowerPoint PPT Presentation

Incrementalized Pointer and Escape Analysis Frdric Vivien Martin Rinard ICPS/LSIIT Laboratory for Computer Science Universit Louis Pasteur Massachusetts Institute of Technology Strasbourg, France Cambridge, MA, USA Start with a


  1. Incrementalized Pointer and Escape Analysis Frédéric Vivien Martin Rinard ICPS/LSIIT Laboratory for Computer Science Université Louis Pasteur Massachusetts Institute of Technology Strasbourg, France Cambridge, MA, USA

  2. Start with a program void main(i,j) ——————— ——————— ——————— void compute(d,e) void evaluate(i,j) ———— —————— ———— —————— ———— —————— void multiplyAdd(a,b,c) void abs(r) void scale(n,m) ————————— ———— —————— ————————— ———— —————— ————————— ———— void multiply(m) void add(u,v) ———— —————— ———— —————— ————

  3. Lots of allocation sites void main(i,j) ——————— ——————— ——————— void compute(d,e) void evaluate(i,j) ———— —————— ———— —————— ———— —————— void multiplyAdd(a,b,c) void abs(r) void scale(n,m) ————————— ———— —————— ————————— ———— —————— ————————— ———— void multiply(m) void add(u,v) ———— —————— ———— —————— ————

  4. Stack Allocation Optimization void main(i,j) ——————— ——————— ——————— void compute(d,e) void evaluate(i,j) ———— —————— ———— —————— ———— —————— void multiplyAdd(a,b,c) void abs(r) void scale(n,m) ————————— ———— —————— ————————— ———— —————— ————————— ———— void multiply(m) void add(u,v) ———— —————— ———— —————— ————

  5. Stack Allocation Optimization void main(i,j) Precise Whole-Program ——————— ——————— Pointer and Escape ——————— Analysis void compute(d,e) void evaluate(i,j) ———— —————— ———— —————— ———— —————— void multiplyAdd(a,b,c) void abs(r) void scale(n,m) ————————— ———— —————— ————————— ———— —————— ————————— ———— void multiply(m) void add(u,v) ———— —————— ———— —————— ————

  6. Drawbacks to Whole-Program Analysis • Resource Intensive • Large analysis times • Large memory consumption • Unsuitable for partial programs

  7. Key Observation Number One: void main(i,j) ——————— Most ——————— ——————— optimizations require only the analysis of a void compute(d,e) void evaluate(i,j) small part of ———— —————— program ———— —————— ———— —————— surrounding the object allocation void multiplyAdd(a,b,c) void abs(r) void scale(n,m) site ————————— ———— —————— ————————— ———— —————— ————————— ———— void multiply(m) void add(u,v) ———— —————— ———— —————— ————

  8. Key Observation Number Two: void main(i,j) ——————— Most of the ——————— ——————— optimization benefit comes from a small void compute(d,e) void evaluate(i,j) percentage of ———— —————— the allocation ———— —————— ———— —————— sites void multiplyAdd(a,b,c) void abs(r) void scale(n,m) ————————— ———— —————— ————————— ———— —————— ————————— ———— void multiply(m) void add(u,v) 99% of objects ———— —————— allocated at ———— —————— ———— these two sites

  9. Intuition for Better Analysis void main(i,j) ——————— • Locate important ——————— ——————— allocation sites • Use demand- driven approach void compute(d,e) void evaluate(i,j) to analyze region ———— —————— ———— —————— surrounding site ———— —————— • Somehow avoid sinking analysis void multiplyAdd(a,b,c) void abs(r) void scale(n,m) ————————— ———— —————— resources into ————————— ———— —————— ————————— ———— sites that can’t be optimized void multiply(m) void add(u,v) 99% of objects ———— —————— allocated at ———— —————— ———— these two sites

  10. What This Talk is About How we turned this intuition into an algorithm that usually 1) obtains almost all the benefit of the whole program analysis 2) analyzes a small fraction of program 3) consumes a small fraction of whole program analysis time

  11. Structure of Talk • Motivating Example • Base whole program analysis (Whaley and Rinard, OOPSLA 99) • Incrementalized analysis • Analysis policy • Experimental results • Conclusion

  12. Motivating Example

  13. Employee Database Example • Read in database of employee records • Extract statistics like max salary

  14. Employee Database Example • Read in database of employee records • Extract statistics like max salary Vector Name John Doe Ben Bit Jane Roe Salary $45,000 $30,000 $55,000

  15. Computing Max Salary • Traverse Records to Find Max Salary Vector Name John Doe Ben Bit Jane Roe Salary $45,000 $30,000 $55,000 max = $0

  16. Computing Max Salary • Traverse Records to Find Max Salary Vector Name John Doe Ben Bit Jane Roe Salary $45,000 $30,000 $55,000 max = $45,000 who = John Doe

  17. Computing Max Salary • Traverse Records to Find Max Salary Vector Name John Doe Ben Bit Jane Roe Salary $45,000 $30,000 $55,000 max = $45,000 who = John Doe

  18. Computing Max Salary • Traverse Records to Find Max Salary Vector Name John Doe Ben Bit Jane Roe Salary $45,000 $30,000 $55,000 max = $55,000 who = Jane Roe

  19. Computing Max Salary • Traverse Records to Find Max Salary Vector Name John Doe Ben Bit Jane Roe Salary $45,000 $30,000 $55,000 max salary = $55,000 highest paid = Jane Roe

  20. Coding Max Computation (in Java) class EmployeeDatabase { Vector database = new Vector(); Employee highestPaid; void computeMax() { int max = 0; Enumeration enum = database.elements(); while (enum.hasMoreElements()) { Employee e = enum.nextElement(); if (max < e.salary()) { max = e.salary(); highestPaid = e; } } } }

  21. Coding Max Computation (in Java) class EmployeeDatabase { Vector database = new Vector(); Employee highestPaid; void computeMax() { int max = 0; Enumeration enum = database.elements(); while (enum.hasMoreElements()) { Employee e = enum.nextElement(); if (max < e.salary()) { max = e.salary(); highestPaid = e; } } } }

  22. Issues In Implementation • Enumeration object allocated on heap • Increases heap memory usage • Increases garbage collection frequency • Heap allocation is unnecessary • Enumeration object allocated inside max • Not accessible outside max • Should be able to use stack allocation

  23. Basic Idea Use pointer and escape analysis to recognize captured objects Transform program to allocate captured objects on stack

  24. Base Analysis

  25. Base Analysis • Basic Abstraction: Points-to Escape Graph • Intraprocedural Analysis • Flow sensitive abstract interpretation • Produces points-to escape graph at each program point • Interprocedural Analysis • Bottom Up and Compositional • Analyzes each method once to obtain a single parameterized analysis result • Result is specialized for use at each call site

  26. Points-to Escape Graph in Example void computeMax() { int max = 0; Enumeration enum = database.elements(); while (enum.hasMoreElements()) { Employee e = enum.nextElement(); if (max < e.salary()) { max = e.salary(); highestPaid = e; } } [ ] vector elementData enum highestPaid database this e }

  27. Edge Types • Inside Edges: • created in currently analyzed part of program • Outside Edges: • created outside currently analyzed part of program [ ] vector elementData enum highestPaid database dashed = outside this e solid = inside

  28. Node Types • Inside Nodes: • Represent objects created in currently analyzed part of program • Outside Nodes: • Parameter nodes – represent parameters • Load nodes - represent objects accessed via pointers created outside analyzed part [ ] vector elementData enum highestPaid database dashed = outside this e solid = inside

  29. Escaped Nodes • Escaped nodes • parameter nodes • thread nodes • returned nodes • nodes reachable from other escaped nodes • Captured is the opposite of escaped [ ] vector elementData enum highestPaid database green = escaped this e white = captured

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend