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

pushdown control flow analysis of higher order programs
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Pushdown Control-Flow Analysis of Higher Order Programs

Christopher Earl1 Matthew Might1 David Van Horn2

1University of Utah

{cwearl,might}@cs.utah.edu

2Northeastern University

dvanhorn@ccs.neu.edu

August 21, 2010

slide-2
SLIDE 2

Who uses function (calls)?

slide-3
SLIDE 3

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

slide-4
SLIDE 4

Simple example of merging return-points

(let* ((id (lambda (x) x)) (a (id 3)) (b (id 4))) a)

slide-5
SLIDE 5

The big picture

Classical control-flow analysis is not precise enough.

slide-6
SLIDE 6

The big picture

Classical control-flow analysis is not precise enough. Pushdown control-flow analysis has better precision.

slide-7
SLIDE 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.

slide-8
SLIDE 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

slide-9
SLIDE 9

Control-flow analysis < pushdown control-flow analysis

Expressiveness of k-CFA = NFA

slide-10
SLIDE 10

Control-flow analysis < pushdown control-flow analysis

Expressiveness of k-CFA = NFA Expressiveness of PDCFA = PDA

slide-11
SLIDE 11

Our approach

slide-12
SLIDE 12

Target language/stack behavior

(let ((x e1)) e2) = ⇒ Push frame (x, e2, . . . ) onto stack.

slide-13
SLIDE 13

Target language/stack behavior

(let ((x e1)) e2) = ⇒ Push frame (x, e2, . . . ) onto stack. a = ⇒ Pop top of stack.

slide-14
SLIDE 14

Target language/stack behavior

(let ((x e1)) e2) = ⇒ Push frame (x, e2, . . . ) onto stack. a = ⇒ Pop top of stack. (f a) = ⇒ Stack no-op.

slide-15
SLIDE 15

Concrete Semantics

A CESK machine.

slide-16
SLIDE 16

Concrete Semantics

A CESK machine. Configuration = State × Stack

slide-17
SLIDE 17

Concrete Semantics

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

slide-18
SLIDE 18

Abstract Semantics

Abstracted environment = ⇒

slide-19
SLIDE 19

Abstract Semantics

Abstracted environment = ⇒ environments = finite

slide-20
SLIDE 20

Abstract Semantics

Abstracted environment = ⇒ environments = finite Abstracted store = ⇒

slide-21
SLIDE 21

Abstract Semantics

Abstracted environment = ⇒ environments = finite Abstracted store = ⇒ stores = finite

slide-22
SLIDE 22

Abstract Semantics

Abstracted environment = ⇒ environments = finite Abstracted store = ⇒ stores = finite Abstracted state = ⇒

slide-23
SLIDE 23

Abstract Semantics

Abstracted environment = ⇒ environments = finite Abstracted store = ⇒ stores = finite Abstracted state = ⇒ states = finite

slide-24
SLIDE 24

Size of the abstract configuration-space

Using the stack = ⇒

slide-25
SLIDE 25

Size of the abstract configuration-space

Using the stack = ⇒ configuration-space = infinite

slide-26
SLIDE 26

Size of the abstract configuration-space

Using the stack = ⇒ configuration-space = infinite The configuration-space cannot be explicitly searched.

slide-27
SLIDE 27

Size of the abstract state-space

State-space = finite Always.

slide-28
SLIDE 28

Finite model of pushdown control-flow analysis

· · ·

  • · · ·

ˆ ς1

ˆ φ+

  • ˆ

ς5

  • ˆ

ς2

ǫ

ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

slide-29
SLIDE 29

Finite model of pushdown control-flow analysis

· · ·

  • · · ·

ˆ ς1

ˆ φ+

  • ˆ

ς5

  • ˆ

ς2

ǫ

ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • This representation is a PDA.
slide-30
SLIDE 30

While finite, this naive PDA is inefficient:

· · ·

  • · · ·

ˆ ς1

ˆ φ+

  • ˆ

ς5

  • ˆ

ς2

ǫ

ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • ˆ

φ′

  • ˆ

φ′′

  • ˆ

ς6 ˆ ς7

slide-31
SLIDE 31

While finite, this naive PDA is inefficient:

· · ·

  • · · ·

ˆ ς1

ˆ φ+

  • ˆ

ς5

  • ˆ

ς2

ǫ

ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • ˆ

φ′

  • ˆ

φ′′

  • ˆ

ς6 ˆ ς7 (Provably) unreachable configurations/states are included.

slide-32
SLIDE 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 = ⇒

slide-33
SLIDE 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

slide-34
SLIDE 34

Shortcut edges: finding the top of the stack

· · ·

  • · · ·

ˆ ς1

ˆ φ+

  • ˆ

ς5

  • ˆ

ς2

ǫ

  • ǫ
  • ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • ˆ

φ′

  • ˆ

φ′′

  • ˆ

ς6 ˆ ς7

slide-35
SLIDE 35

Shortcut edges: finding the top of the stack

· · ·

  • · · ·

ˆ ς1

ˆ φ+

  • ǫ

ˆ

ς5

  • ˆ

ς2

ǫ

  • ǫ
  • ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • ˆ

φ′

  • ˆ

φ′′

  • ˆ

ς6 ˆ ς7

slide-36
SLIDE 36

Shortcut edges: finding the top of the stack

ˆ ς0

ˆ φ′

+

  • · · ·

ˆ ς1

ˆ φ+

  • ǫ

ˆ

ς5

  • ˆ

ς2

ǫ

  • ǫ
  • ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • ˆ

φ′

  • ˆ

φ′′

  • ˆ

ς6 ˆ ς7

slide-37
SLIDE 37

Shortcut edges: finding the top of the stack

ˆ ς0

ˆ φ′

+

  • ˆ

ς8 ˆ ς1

ˆ φ+

  • ǫ

ˆ

ς5

ˆ φ′

  • ˆ

ς2

ǫ

  • ǫ
  • ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • ˆ

φ′

  • ˆ

φ′′

  • ˆ

ς6 ˆ ς7

slide-38
SLIDE 38

Shortcut edges: finding the top of the stack

ˆ ς0

ˆ φ′

+

  • ǫ

ˆ

ς8 ˆ ς1

ˆ φ+

  • ǫ

ˆ

ς5

ˆ φ′

  • ˆ

ς2

ǫ

  • ǫ
  • ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • ˆ

φ′

  • ˆ

φ′′

  • ˆ

ς6 ˆ ς7

slide-39
SLIDE 39

Dyck state graphs: a lean PDA representation

ˆ ς0

ˆ φ′

+

  • ǫ

ˆ

ς8 ˆ ς1

ˆ φ+

  • ǫ

ˆ

ς5

ˆ φ′

  • ˆ

ς2

ǫ

  • ǫ
  • ˆ

ς3

ǫ

ˆ

ς4

ˆ φ−

  • Only reachable states and configurations are included.
slide-40
SLIDE 40

Our contributions

slide-41
SLIDE 41

Direct-style Polyvariant Polynomial

slide-42
SLIDE 42

Direct-style:

slide-43
SLIDE 43

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

slide-44
SLIDE 44

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

slide-45
SLIDE 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

slide-46
SLIDE 46

Polynomial: monovariance and store-widening

Standard (infinite) pushdown control-flow analysis: Configuration = Expression × Environment × Store × Stack Frame = Variable × Expression × Environment

slide-47
SLIDE 47

Polynomial: monovariance and store-widening

Dyck state graphs: State = Expression × Environment × Store Frame = Variable × Expression × Environment

slide-48
SLIDE 48

Polynomial: monovariance and store-widening

Monovariant Dyck state graphs: State = Expression × Store Frame = Variable × Expression

slide-49
SLIDE 49

Polynomial: monovariance and store-widening

Monovariant Dyck state graphs with store-widening: State = Expression (with a global store) Frame = Variable × Expression

slide-50
SLIDE 50

Recap

Pushdown control-flow analysis precisely models the stack.

slide-51
SLIDE 51

Recap

Pushdown control-flow analysis precisely models the stack. Our formulation only explores reachable configurations/states.

slide-52
SLIDE 52

Recap

Pushdown control-flow analysis precisely models the stack. Our formulation only explores reachable configurations/states. Our formulation works for direct-style programs.

slide-53
SLIDE 53

Recap

Pushdown control-flow analysis precisely models the stack. Our formulation only explores reachable configurations/states. Our formulation works for direct-style programs. Our formulation allows for either:

slide-54
SLIDE 54

Recap

Pushdown control-flow analysis precisely models the stack. Our formulation only explores reachable configurations/states. Our formulation works for direct-style programs. Our formulation allows for either: Polyvariance

slide-55
SLIDE 55

Recap

Pushdown control-flow analysis precisely models the stack. Our formulation only explores reachable configurations/states. Our formulation works for direct-style programs. Our formulation allows for either: Polyvariance Polynomial running-time

slide-56
SLIDE 56

Questions?

slide-57
SLIDE 57

O(n6)