Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs Mayur Naik Intel Research CS294 Lecture March 19, 2009 (Slides courtesy of John Whaley)

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

4 Control Statements: Part 1.
Adders Used to perform addition, subtraction, multiplication, and division (sometimes) Half-adder adds rightmost (least significant) bit Full-adder.
1
Feichter_DPG-SYKL03_Bild-01. Feichter_DPG-SYKL03_Bild-02.
1 Vorlesung Informatik 2 Algorithmen und Datenstrukturen (Parallel Algorithms) Robin Pomplun.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
Objectives: Generate and describe sequences. Vocabulary:
Program Analysis Using Datalog
UNITED NATIONS Shipment Details Report – January 2006.
1 Hyades Command Routing Message flow and data translation.
We need a common denominator to add these fractions.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
Chapter 6 File Systems 6.1 Files 6.2 Directories
All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,
Robust Window-based Multi-node Technology- Independent Logic Minimization Jeff L.Cobb Kanupriya Gulati Sunil P. Khatri Texas Instruments, Inc. Dept. of.
Solve Multi-step Equations
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Break Time Remaining 10:00.
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Database Performance Tuning and Query Optimization
PP Test Review Sections 6-1 to 6-6
11 Data Structures Foundations of Computer Science ã Cengage Learning.
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Discrete Mathematical Structures: Theory and Applications
Digital Systems Introduction Binary Quantities and Variables
Chapter 10: Virtual Memory
Bellwork Do the following problem on a ½ sheet of paper and turn in.
Name Convolutional codes Tomashevich Victor. Name- 2 - Introduction Convolutional codes map information to code bits sequentially by convolving a sequence.
Chapter 6 File Systems 6.1 Files 6.2 Directories
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
© 2012 National Heart Foundation of Australia. Slide 2.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
Datorteknik TopologicalSort bild 1 To verify the structure Easy to hook together combinationals and flip-flops Harder to make it do what you want.
Analyzing Genes and Genomes
Systems Analysis and Design in a Changing World, Fifth Edition
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Essential Cell Biology
Clock will move after 1 minute
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Datorteknik TopologicalSort bild 1 To verify the structure Easy to hook together combinationals and flip-flops Harder to make it do what you want.
Mani Srivastava UCLA - EE Department Room: 6731-H Boelter Hall Tel: WWW: Copyright 2003.
Immunobiology: The Immune System in Health & Disease Sixth Edition
Energy Generation in Mitochondria and Chlorplasts
Select a time to count down from the clock above
Murach’s OS/390 and z/OS JCLChapter 16, Slide 1 © 2002, Mike Murach & Associates, Inc.
Instructor: Shengyu Zhang 1. Content Two problems  Minimum Spanning Tree  Huffman encoding One approach: greedy algorithms 2.
Techniques for proving programs with pointers A. Tikhomirov.
R O O T S Interprocedural Analysis Aleksandra Biresev
Scalable Points-to Analysis. Rupesh Nasre. Advisor: Prof. R. Govindarajan. Comprehensive Examination. Jun 22, 2009.
SAT Solver CS 680 Formal Methods Jeremy Johnson. 2 Disjunctive Normal Form  A Boolean expression is a Boolean function  Any Boolean function can be.
Swerve: Semester in Review. Topics  Symbolic pointer analysis  Model checking –C programs –Abstract counterexamples  Symbolic simulation and execution.
Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs John Whaley Monica Lam Stanford University June 10, 2004.
Pointer Analysis – Part II CS Unification vs. Inclusion Earlier scalable pointer analysis was context- insensitive unification-based [Steensgaard.
Presentation transcript:

Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs Mayur Naik Intel Research CS294 Lecture March 19, 2009 (Slides courtesy of John Whaley)

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 1 Unification vs. Inclusion Earlier scalable pointer analysis was context- insensitive unification-based [Steensgaard ’96] –Pointers are either unaliased or point to the same set of objects. –Near-linear, but VERY imprecise. Inclusion-based pointer analysis –Can point to overlapping sets of objects. –Closure calculation is O(n 3 ) –Various optimizations [Fahndrich,Su,Heintze,…] –BDD formulation, simple, scalable [Berndl,Zhu]

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 2 Context Sensitivity Context sensitivity is important for precision. –Unrealizable paths. Object id(Object x) { return x; } a = id(b);c = id(d);

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 3 Object id(Object x) { return x; } Context Sensitivity Context sensitivity is important for precision. –Unrealizable paths. –Conceptually give each caller its own copy. a = id(b);c = id(d);

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 4 Summary-Based Analysis Popular method for context sensitivity. Two phases: –Bottom-up: Summarize effects of methods. –Top-down: Propagate information down. Problems: –Difficult to summarize pointer analysis. –Summary-based analysis using BDD: not shown to scale [Zhu’02]

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 5 Cloning-Based Analysis Simple brute force technique. –Clone every path through the call graph. –Run context-insensitive algorithm on expanded call graph. The catch: exponential blowup

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 6 Cloning is exponential!

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 7 Recursion Actually, cloning is unbounded in the presence of recursive cycles. Technique: We treat all methods within a strongly-connected component as a single node.

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 8 Recursion A G BCD EF A G BCD EF EFEF GG

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 9 Top 20 Sourceforge Java Apps

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 10 Cloning is infeasible (?) Typical large program has ~10 14 paths –If you need 1 byte to represent a clone: Would require 256 terabytes of storage –Registered ECC 1GB DIMMs: $98.6 million »Power: 96.4 kilowatts = Power for 128 homes –300 GB hard disks: 939 x $250 = $234,750 »Time to read (sequential): 70.8 days Seems unreasonable!

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 11 BDD comes to the rescue There are many similarities across contexts. –Many copies of nearly-identical results. BDDs can represent large sets of redundant data efficiently. –Need a BDD encoding that exploits the similarities.

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 12 Contribution (1) Can represent context-sensitive call graph efficiently with BDDs and a clever context numbering scheme –Inclusion-based pointer analysis contexts, 19 minutes –Generates all answers

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 13 Contribution (2) BDD hacking is complicated  bddbddb (BDD-based deductive database) Pointer algorithm in 6 lines of Datalog Automatic translate into efficient BDD implementation 10x performance over hand-tuned solver (2164 lines of Java)

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 14 Contribution (3) bddbddb: General Datalog solver –Supports simple declarative queries –Easy use of context-sensitive pointer results Simple context-sensitive analyses: –Escape analysis –Type refinement –Side effect analysis –Many more presented in the paper

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 15 Context-sensitive call graphs in BDD

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 16 Call graph relation Call graph expressed as a relation. –Five edges: Calls(A,B) Calls(A,C) Calls(A,D) Calls(B,D) Calls(C,D) B D C A

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 17 Call graph relation Relation expressed as a binary function. –A=00, B=01, C=10, D=11 x1x1 x2x2 x3x3 x4x4 f B D C A

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 18 Binary Decision Diagrams Graphical encoding of a truth table. x2x2 x4x4 x3x3 x3x3 x4x4 x4x4 x4x x2x2 x4x4 x3x3 x3x3 x4x4 x4x4 x4x x1x1 0 edge 1 edge

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 19 Binary Decision Diagrams Collapse redundant nodes. x2x2 x4x4 x3x3 x3x3 x4x4 x4x4 x4x x2x2 x4x4 x3x3 x3x3 x4x4 x4x4 x4x x1x

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 20 Binary Decision Diagrams Collapse redundant nodes. x2x2 x4x4 x3x3 x3x3 x4x4 x4x4 x4x4 x2x2 x4x4 x3x3 x3x3 x4x4 x4x4 x4x4 0 x1x1 1

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 21 Binary Decision Diagrams Collapse redundant nodes. x2x2 x4x4 x3x3 x3x3 x2x2 x3x3 x3x3 x4x4 x4x4 0 x1x1 1

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 22 Binary Decision Diagrams Collapse redundant nodes. x2x2 x4x4 x3x3 x3x3 x2x2 x3x3 x4x4 x4x4 0 x1x1 1

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 23 Binary Decision Diagrams Eliminate unnecessary nodes. x2x2 x4x4 x3x3 x3x3 x2x2 x3x3 x4x4 x4x4 0 x1x1 1

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 24 Binary Decision Diagrams Eliminate unnecessary nodes. x2x2 x3x3 x2x2 x3x3 x4x4 0 x1x1 1

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 25 Binary Decision Diagrams Size is correlated to amount of redundancy, NOT size of relation. –As the set gets larger, the number of don’t-care bits increases, leading to fewer necessary nodes.

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 26 Expanded Call Graph A DBC E FG H 012 A DBC E FG H EE FFGG HHHHH

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 27 Numbering Clones A DBC E FG H A DBC E FG H EE FFGG HHHHH

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 28 Pointer Analysis

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 29 Pointer Analysis Example h 1 : v 1 = new Object(); h 2 : v 2 = new Object(); v 1.f = v 2 ; v 3 = v 1.f; Input Relations vPointsTo(v 1,h 1 ) vPointsTo(v 2,h 2 ) Store(v 1,f,v 2 ) Load(v 1,f,v 3 ) Output Relations hPointsTo(h 1,f,h 2 ) vPointsTo(v 3,h 2 ) v1v1 h1h1 v2v2 h2h2 f v3v3

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 30 hPointsTo(h 1, f, h 2 ):- Store(v 1, f, v 2 ), vPointsTo(v 1, h 1 ), vPointsTo(v 2, h 2 ). v1v1 h1h1 v2v2 h2h2 f Inference Rule in Datalog v 1.f = v 2 ; Stores:

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 31 Context-sensitive pointer analysis Compute call graph with context-insensitive pointer analysis. –Datalog rules for: assignments, loads, stores discover call targets, bind parameters type filtering –Apply rules until fix-point reached. Compute expanded call graph relation. Apply context-insensitive algorithm to expanded call graph.

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 32 bddbddb: BDD-Based Deductive DataBase

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 33 Datalog Declarative logic programming language designed for databases –Horn clauses –Operates on relations Datalog is expressive –Relational algebra: Explicitly specify relational join, project, rename. –Relational calculus: Specify relations between variables; operations are implicit. –Datalog: Allows recursively-defined relations.

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 34 Datalog  BDD Join, project, rename are directly mapped to built-in BDD operations Automatically optimizes: –Rule application order –Incrementalization –Variable ordering –BDD parameter tuning –Many more…

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 35 Experimental Results

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 36 Experimental Results Top 20 Java projects on SourceForge –Real programs with 100K+ users each Using automatic bddbddb solver –Each analysis only a few lines of code –Easy to try new algorithms, new queries Test system: –Pentium 4 2.2GHz, 1GB RAM –RedHat Fedora Core 1, JDK 1.4.2_04, javabdd library, Joeq compiler

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 37

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 38

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 39 Multi-type variables A variable is multi-type if it can point to objects of different types. –Measure of analysis precision –One line in Datalog Two ways of handling context sensitivity: –Projected: Merge all contexts together –Full: Keep each context separate

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 40

June 10, 2004Cloning-Based Context-Sensitive Pointer Alias Analysis using BDDs 41 Conclusion The first scalable context-sensitive inclusion- based pointer analysis. –Achieves context sensitivity by cloning. bddbddb: Datalog  efficient BDD Easy to query results, develop new analyses. Very efficient! –<19 minutes, <600mb on largest benchmark. Complete system is publicly available at: