pushdown control flow analysis of higher order programs
play

Pushdown Control-Flow Analysis of Higher Order Programs Christopher - PowerPoint PPT Presentation

Pushdown Control-Flow Analysis of Higher Order Programs Christopher Earl 1 Matthew Might 1 David Van Horn 2 1 University of Utah { cwearl,might } @cs.utah.edu 2 Northeastern University dvanhorn@ccs.neu.edu August 21, 2010 Who uses function


  1. Pushdown Control-Flow Analysis of Higher Order Programs Christopher Earl 1 Matthew Might 1 David Van Horn 2 1 University of Utah { cwearl,might } @cs.utah.edu 2 Northeastern University dvanhorn@ccs.neu.edu August 21, 2010

  2. Who uses function (calls)?

  3. Who uses function (calls)? Pushdown control-flow analysis models function calls precisely.

  4. Simple example of merging return-points (let* ((id (lambda (x) x)) (a (id 3)) (b (id 4))) a)

  5. The big picture Classical control-flow analysis is not precise enough.

  6. The big picture Classical control-flow analysis is not precise enough. Pushdown control-flow analysis has better precision.

  7. The big picture Classical control-flow analysis is not precise enough. Pushdown control-flow analysis has better precision. We generalize k-CFA to a pushdown control-flow analysis.

  8. The big picture Classical control-flow analysis is not precise enough. Pushdown control-flow analysis has better precision. We generalize k-CFA to a pushdown control-flow analysis. Our approach has several advantages: Direct-style Polyvariant Polynomial

  9. Control-flow analysis < pushdown control-flow analysis Expressiveness of k-CFA = NFA

  10. Control-flow analysis < pushdown control-flow analysis Expressiveness of k-CFA = NFA Expressiveness of PDCFA = PDA

  11. Our approach

  12. Target language/stack behavior ( let (( x e 1 )) e 2 ) = Push frame ( x , e 2 , . . . ) onto stack. ⇒

  13. Target language/stack behavior ( let (( x e 1 )) e 2 ) = Push frame ( x , e 2 , . . . ) onto stack. ⇒ a = Pop top of stack. ⇒

  14. Target language/stack behavior ( let (( x e 1 )) e 2 ) = Push frame ( x , e 2 , . . . ) onto stack. ⇒ a = Pop top of stack. ⇒ ( f a ) = Stack no-op. ⇒

  15. Concrete Semantics A CESK machine.

  16. Concrete Semantics A CESK machine. Configuration = State × Stack

  17. Concrete Semantics A CESK machine. Configuration = State × Stack State = Expression × Environment × Store

  18. Abstract Semantics Abstracted environment = ⇒

  19. Abstract Semantics Abstracted environment = ⇒ environments = finite

  20. Abstract Semantics Abstracted environment = ⇒ environments = finite Abstracted store = ⇒

  21. Abstract Semantics Abstracted environment = ⇒ environments = finite Abstracted store = ⇒ stores = finite

  22. Abstract Semantics Abstracted environment = ⇒ environments = finite Abstracted store = ⇒ stores = finite Abstracted state = ⇒

  23. Abstract Semantics Abstracted environment = ⇒ environments = finite Abstracted store = ⇒ stores = finite Abstracted state = ⇒ states = finite

  24. Size of the abstract configuration-space Using the stack = ⇒

  25. Size of the abstract configuration-space Using the stack = ⇒ configuration-space = infinite

  26. Size of the abstract configuration-space Using the stack = ⇒ configuration-space = infinite The configuration-space cannot be explicitly searched.

  27. Size of the abstract state-space State-space = finite Always.

  28. � � � � Finite model of pushdown control-flow analysis · · · · · · � � � � � � � � � � � � � � � � ˆ ˆ ς 1 ς 5 � � ˆ � ˆ φ − φ + � � � � � � � � � � � ǫ � ˆ ǫ � ˆ ˆ ς 2 ς 3 ς 4

  29. � � � � Finite model of pushdown control-flow analysis · · · · · · � � � � � � � � � � � � � � � � ˆ ˆ ς 1 ς 5 � � ˆ � ˆ φ − φ + � � � � � � � � � � � ǫ � ˆ ǫ � ˆ ˆ ς 2 ς 3 ς 4 This representation is a PDA.

  30. � � � � � � While finite, this naive PDA is inefficient: · · · · · · � � � � � � � � � � � � � � � � ˆ ˆ ς 1 ς 5 � � ˆ � ˆ φ − φ + � � � � � � � � � � � ǫ � ˆ ǫ � ˆ ˆ ˆ � � � ς 2 ς 3 ς 4 ς 6 ˆ � φ ′ − � � ˆ φ ′′ � − ˆ ς 7

  31. � � � � � � While finite, this naive PDA is inefficient: · · · · · · � � � � � � � � � � � � � � � � ˆ ˆ ς 1 ς 5 � � ˆ � ˆ φ − φ + � � � � � � � � � � � ǫ � ˆ ǫ � ˆ ˆ ˆ � � � ς 2 ς 3 ς 4 ς 6 ˆ � φ ′ − � � ˆ φ ′′ � − ˆ ς 7 (Provably) unreachable configurations/states are included.

  32. � � � � � � While finite, this naive PDA is inefficient: · · · · · · � � � � � � � � � � � � � � � � ˆ ˆ ς 1 ς 5 � � ˆ � ˆ φ − φ + � � � � � � � � � � � ǫ � ˆ ǫ � ˆ ˆ ˆ � � � ς 2 ς 3 ς 4 ς 6 ˆ � φ ′ − � � ˆ φ ′′ � − ˆ ς 7 (Provably) unreachable configurations/states are included. Legal path from initial configuration/state = ⇒

  33. � � � � � � While finite, this naive PDA is inefficient: · · · · · · � � � � � � � � � � � � � � � � ˆ ˆ ς 1 ς 5 � � ˆ � ˆ φ − φ + � � � � � � � � � � � ǫ � ˆ ǫ � ˆ ˆ ˆ � � � ς 2 ς 3 ς 4 ς 6 ˆ � φ ′ − � � ˆ φ ′′ � − ˆ ς 7 (Provably) unreachable configurations/states are included. Legal path from initial configuration/state = ⇒ reachable

  34. � � � � � � � � Shortcut edges: finding the top of the stack · · · · · · � � � � � � � � � � � � � � � � ˆ ˆ ς 1 ς 5 � � ǫ ˆ ˆ � φ + φ − � � � � � � � � � � � ǫ ǫ � ˆ ˆ ˆ ˆ ς 3 � � � ς 6 ς 2 ς 4 � ˆ φ ′ − � � ˆ φ ′′ � − ˆ ς 7

  35. � � � � � � � � Shortcut edges: finding the top of the stack · · · · · · � � � � � � � � � � � � � � � � ǫ � ˆ ˆ ς 1 ς 5 � � ǫ ˆ ˆ � φ + φ − � � � � � � � � � � � ǫ ǫ � ˆ ˆ ˆ ˆ ς 3 � � � ς 6 ς 2 ς 4 � ˆ φ ′ − � � ˆ φ ′′ � − ˆ ς 7

  36. � � � � � � � � Shortcut edges: finding the top of the stack ˆ ς 0 · · · � � � ˆ φ ′ � � + � � � � � � � � � � ǫ � ˆ ˆ ς 1 ς 5 � � ˆ ǫ ˆ � φ + φ − � � � � � � � � � � � ǫ ǫ � ˆ ˆ ˆ ˆ � � � ς 2 ς 3 ς 4 ς 6 ˆ � φ ′ − � � ˆ φ ′′ � − ˆ ς 7

  37. � � � � � � � � Shortcut edges: finding the top of the stack ˆ ˆ ς 0 ς 8 � ˆ � ˆ φ ′ φ ′ � � � + − � � � � � � � � � ǫ � ˆ ˆ ς 1 ς 5 � � ˆ ǫ ˆ � φ + φ − � � � � � � � � � � � ǫ ǫ � ˆ ˆ ˆ ˆ � � � ς 2 ς 3 ς 4 ς 6 ˆ � φ ′ − � � ˆ φ ′′ � − ˆ ς 7

  38. � � � � � � � � Shortcut edges: finding the top of the stack ǫ � ˆ ˆ ς 0 ς 8 � ˆ � ˆ φ ′ φ ′ � � � + − � � � � � � � � � ǫ � ˆ ˆ ς 1 ς 5 � � ˆ ǫ ˆ � φ + φ − � � � � � � � � � � � ǫ ǫ � ˆ ˆ ˆ ˆ � � � ς 2 ς 3 ς 4 ς 6 ˆ � φ ′ − � � ˆ φ ′′ � − ˆ ς 7

  39. � � � � � � Dyck state graphs: a lean PDA representation ǫ � ˆ ˆ ς 0 ς 8 � ˆ ˆ � φ ′ φ ′ � � � + − � � � � � � � � � ǫ � ˆ ˆ ς 1 ς 5 � � ǫ ˆ � ˆ φ − φ + � � � � � � � � � � � ǫ ǫ � ˆ ˆ ˆ ς 2 ς 3 ς 4 Only reachable states and configurations are included.

  40. Our contributions

  41. Direct-style Polyvariant Polynomial

  42. Direct-style:

  43. Direct-style: by the language (A-Normal Form)

  44. Direct-style: by the language (A-Normal Form) Polyvariant:

  45. Direct-style: by the language (A-Normal Form) Polyvariant: the abstract semantics can use a parameter, k, identical to the k in k-CFA

  46. Polynomial: monovariance and store-widening Standard (infinite) pushdown control-flow analysis: Configuration = Expression × Environment × Store × Stack Frame = Variable × Expression × Environment

  47. Polynomial: monovariance and store-widening Dyck state graphs: State = Expression × Environment × Store Frame = Variable × Expression × Environment

  48. Polynomial: monovariance and store-widening Monovariant Dyck state graphs: State = Expression × Store Frame = Variable × Expression

  49. Polynomial: monovariance and store-widening Monovariant Dyck state graphs with store-widening: State = Expression (with a global store) Frame = Variable × Expression

  50. Recap Pushdown control-flow analysis precisely models the stack.

Recommend


More recommend