42
Partially Disjunctive Heap Abstraction Roman Manevich Mooly Sagiv Tel Aviv University G. Ramalingam John Field IBM T.J. Watson

Partially Disjunctive Heap Abstraction

  • Upload
    arvin

  • View
    44

  • Download
    2

Embed Size (px)

DESCRIPTION

Partially Disjunctive Heap Abstraction. Roman Manevich Mooly Sagiv Tel Aviv University. G. Ramalingam John Field IBM T.J. Watson. Motivation. Analysis of Object Oriented programs is hard Recursive data structures Unbounded number of objects Destructive update of references - PowerPoint PPT Presentation

Citation preview

Page 1: Partially Disjunctive Heap Abstraction

Partially DisjunctiveHeap Abstraction

Roman ManevichMooly Sagiv

Tel Aviv University

G. RamalingamJohn Field

IBM T.J. Watson

Page 2: Partially Disjunctive Heap Abstraction

Motivation Analysis of Object Oriented programs is

hard Recursive data structures Unbounded number of objects Destructive update of references

Scalable heap analyses exist e.g., flow-insensitive Not precise enough for verification

Precise heap analyses exist e.g., SRW shape analysis Scaling is very challenging

Page 3: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

// @Ensures marked == REACH(root)void mark(Node root, NodeSet marked) { Node x; if (root != null) {

NodeSet pending = new NodeSet();pending.add(root);marked.clear();while (!pending.isEmpty()) { x = pending.selectAndRemove(); marked.add(x); if (x.left != null) if (!marked.contains(x.left))

pending.add(x.left); if (x.right != null) if (!marked.contains(x.right)

pending.add(x.right);}

}}

Page 4: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

// @Ensures marked == REACH(root)void mark(Node root, NodeSet marked) { Node x; if (root != null) {

NodeSet pending = new NodeSet();pending.add(root);marked.clear();while (!pending.isEmpty()) { x = pending.selectAndRemove(); marked.add(x); if (x.left != null) if (!marked.contains(x.left))

pending.add(x.left); if (x.right != null) if (!marked.contains(x.right)

pending.add(x.right);}

}}

Page 5: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

// @Ensures marked == REACH(root)void mark(Node root, NodeSet marked) { Node x; if (root != null) {

NodeSet pending = new NodeSet();pending.add(root);marked.clear();while (!pending.isEmpty()) { x = pending.selectAndRemove(); marked.add(x); if (x.left != null) if (!marked.contains(x.left))

pending.add(x.left); if (x.right != null) if (!marked.contains(x.right)

pending.add(x.right);}

}}

Page 6: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

pending = {root}marked = {}

u1

u2

u3

u4

rootx

left

rightleftleft

right

left

right

u5

u6

Page 7: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

pending = {u3,u2}marked = {u1}

u1

u2

u3

u4

root

left

rightleftleft

right

left

right

u5

u6x

Page 8: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

pending = {u4,u2}marked = {u1,u3}

u1

u2

u3

u4

root

left

rightleftleft

right

left

right

u5

u6

x

Page 9: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

pending = {u2}marked = {u1,u3,u4}

u1

u2

u3

u4

root

x

left

rightleftleft

right

left

right

u5

u6

Page 10: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

u1

u2

u3

u4

root

x left

rightleftleft

right

left

right

u5

u6

pending = {}marked = {u1,u3,u4,u2}

Page 11: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

u1

u2

u3

u4

root

x left

rightleftleft

right

left

right

u5

u6

DONE

pending = {}marked = {u1,u3,u4,u2}

Page 12: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

u1

u2

u3

u4

root

x left

rightleftleft

right

left

right

u5

u6

pending = {}marked = {u1,u3,u4,u2}

garbagegarbage

Page 13: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

u1

u2

u3

u4

root

x

left

right

left

right

pending = {}marked = {u1,u3,u4,u2}

Page 14: Partially Disjunctive Heap Abstraction

Motivating example:verifying mark phase of GC

Powerset heap abstraction 584 seconds, 189,772 abstract heaps Definitely too expensive Can we verify more efficiently?

Partially disjunctive heap abstraction 3 seconds, 1,133 abstract heaps

TVLA system

Page 15: Partially Disjunctive Heap Abstraction

Overview and main results

New (parametric) heap abstraction Uses a heap similarity criterion Merges “similar” heaps

Robust implementation Abstraction of choice among TVLA users Suitable for other shape analysis systems

Empirical results Significant speedups (2 orders of

magnitude) Precise in most cases

Page 16: Partially Disjunctive Heap Abstraction

Talk outline

Shape analysis background Representing heaps via logical structures Disjunctive (powerset) heap abstraction

Partially disjunctive heap abstraction Via universe congruence similarity

Empirical results Related work Future work Conclusions

Page 17: Partially Disjunctive Heap Abstraction

Shape analysis viaFirst-Order logic

SRW 2002 : Parametric shape analysis via 3-valued logic

Concrete heaps represented by 2-valued structures over predicate symbols P A set of individuals (nodes) U Interpretation of predicate symbols in P

p0() {0,1}p1(v) {0,1}p2(u,v) {0,1}

Page 18: Partially Disjunctive Heap Abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

left

rightleftleft

right

left

right

Concrete heap

unary predicatesxrootset[marked]set[pending]r[root]

left right

binary predicates

Page 19: Partially Disjunctive Heap Abstraction

3-valued structures

2-valued structures abstracted into3-valued structures by merging individuals

p0() {0,1,1/2}p1(v) {0,1,1/2}p2(u,v) {0,1,1/2}

Kleene’s partially ordered set of logical values:

0 1 = 1/2 0 1

1/2

Page 20: Partially Disjunctive Heap Abstraction

Canonical abstraction

Merge individuals with same values for all unary predicates (canonical name) Bounded structure with at most 2|A|

individuals A = set of unary predicates

Page 21: Partially Disjunctive Heap Abstraction

Canonical abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

left

rightleftleft

right

left

right

x(v)root(v)set[marked](v)set[pending](v)r[root](v)

A =

Page 22: Partially Disjunctive Heap Abstraction

Canonical abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

left

rightleftleft

right

left

right

x=0,root=0,r[root]=1,set[marked]=1,set[pending]=0

Page 23: Partially Disjunctive Heap Abstraction

Canonical abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

left

rightleftleft

right

left

right

x=0,root=0,r[root]=1,set[marked]=1,set[pending]=0

x=0,root=0,r[root]=1,set[marked]=1,set[pending]=0

Page 24: Partially Disjunctive Heap Abstraction

Canonical abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

left

rightleftleft

right

left

right

x=0,root=0,r[root]=1,set[marked]=1,set[pending]=0

x=0,root=0,r[root]=1,set[marked]=1,set[pending]=0

x=0,root=0,r[root]=0,set[marked]=0,set[pending]=0

Page 25: Partially Disjunctive Heap Abstraction

Canonical abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

left

rightleftleft

right

left

right

x=0,root=0,r[root]=1,set[marked]=1,set[pending]=0

x=0,root=0,r[root]=1,set[marked]=1,set[pending]=0

x=0,root=0,r[root]=0,set[marked]=0,set[pending]=0

x=0,root=0,r[root]=0,set[marked]=0,set[pending]=0

Page 26: Partially Disjunctive Heap Abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

left

rightleftleft

right

left

right

Canonical abstraction

Page 27: Partially Disjunctive Heap Abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

rightleftleft

right

right

left

left

Abstract heapBounded number of individuals

Page 28: Partially Disjunctive Heap Abstraction

Powerset heap abstraction

= canonical abstraction pow(X) = {(s) | s X} LUB (join) is set union Worst-case is doubly-exponential in |A| Can make unnecessary distinctions

Page 29: Partially Disjunctive Heap Abstraction

Partially disjunctiveheap abstraction

Use a heap-similarity criterion We defined similarity by universe

congruence Merge similar heaps Avoid merging dissimilar heaps

Page 30: Partially Disjunctive Heap Abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

right

leftleft

right

left

left

right

Universe congruent heaps

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

rightleftleft

right

right

left

left

Page 31: Partially Disjunctive Heap Abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

right

leftleft

right

left

left

right

Result of merge

left right

left

left

Page 32: Partially Disjunctive Heap Abstraction

r[root]set[marked]

r[root]set[marked]

r[root]set[pending]

root

x

right

leftleft

right

left

left

right

Non-congruent heaps – no merge

r[root]set[marked]

r[root]set[marked]

r[root]set[marked]

root

x

rightleftleft

right

right

left

left

Page 33: Partially Disjunctive Heap Abstraction

Definition of partially disjunctiveheap abstraction

Two heaps are similar iff they are universe congruent (same canonical names)

piC = merge universe congruent heaps pi(X) = {piC | C pow(X)}

Page 34: Partially Disjunctive Heap Abstraction

Characteristics of the partially disjunctive heap abstraction

1. 3-valued structures partially-ordered No LUB over singleton structure sets if S1 pi S2

pi({S1,S2}) = pi{S1,S2} else

pow({S1,S2}) = {S1,S2}

2. Retain definite values of unary predicates

3. Size of set can be reduced exponentially

Page 35: Partially Disjunctive Heap Abstraction

Running times

02,0004,0006,0008,00010,00012,00014,00016,00018,00020,000

DSW

Inpu

tStre

am5

Inpu

tStre

am5b

Inpu

tStre

am6

SQLExe

cuto

r

Kerne

lBen

ch.1

GC.mar

k

seconds

PowersetPartial

Page 36: Partially Disjunctive Heap Abstraction

Space consumption

0

20

40

60

80

100

120

DSW

Inpu

tStre

am5

Inpu

tStre

am5b

Inpu

tStre

am6

SQLExe

cuto

r

Kerne

lBen

ch.1

GC.mar

k

Mb

PowersetPartial

Page 37: Partially Disjunctive Heap Abstraction

Related work

Reducing cost of powerset-based analysis

Function space domain construction ESP [PLDI 02] Deutsch [PLDI 94]

Widening operators [Bagnara et el. VMCAI03]

Page 38: Partially Disjunctive Heap Abstraction

Future work

Experiment with other similarity criteria Structures with different universes

Deflating operators Widening operators

Page 39: Partially Disjunctive Heap Abstraction

Conclusions

A new (parametric) heap abstraction Partially disjunctive Merges similar abstract heap descriptors

Significantly more efficient than full powerset Essential for many TVLA analyses

Often no loss of precision in practice

Page 40: Partially Disjunctive Heap Abstraction

The End

Page 41: Partially Disjunctive Heap Abstraction

Parametric partial isomorphism

Structures S1=U1,I1 and S2=U2,I2 Isomorphic iff:

Exists bijection f : U1U2

Preserves all predicate values Partially-isomorphic relative to R iff:

Exists bijection f : U1U2

Preserves values of relational predicates A R P

Page 42: Partially Disjunctive Heap Abstraction

No LUB over singletonsp=1q=1

z=1/2

p=0q=1z=0

p=1q=0z=1

A

p=0q=1z=1

p=1q=0z=0

p=1q=1

z=1/2B

p=1q=0

z=1/2

p=1/2q=1

z=1/2

p=0q=1

z=1/2

p=1q=1/2z=1/2

C is an upper bound D is an upper bound

incomparable