• No results found

Parametric Shape Parametric Shape Analysis via 3

N/A
N/A
Protected

Academic year: 2022

Share "Parametric Shape Parametric Shape Analysis via 3"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

Parametric Shape Parametric Shape Analysis via 3

Analysis via 3 - - Valued Valued Logic

Logic

Mooly

Mooly Sagiv Sagiv , Thomas Reps, , Thomas Reps, Reinhard

Reinhard Wilhelm Wilhelm

(2)

Motivation Motivation

„„

Many shape analysis algorithms developed Many shape analysis algorithms developed

„„ Different abstractionsDifferent abstractions

„„ Hard to compareHard to compare

„„

Parametric Framework Parametric Framework

„„ yaccyacc for shape analysis?for shape analysis?

(3)

Overview Overview

„„ Use logic structures to represent storesUse logic structures to represent stores

„„ By choosing different predicates, the framework is By choosing different predicates, the framework is instantiated into different shape analysis algorithms.

instantiated into different shape analysis algorithms.

„„ Previous approach:Previous approach:

„„ Define abstraction, give transfer function, prove, implementDefine abstraction, give transfer function, prove, implement

„„ With the framework:With the framework:

„„ Choose predicate, define update formula for instrumentation Choose predicate, define update formula for instrumentation predicates, prove correctness of the formulae

predicates, prove correctness of the formulae

„„ The rest is automatically done by the systemThe rest is automatically done by the system

(4)

Representation Representation

„„ Logical Structures:Logical Structures:

„„ S=<U, ιS=<U, ι>>

„

„ U: individualsU: individuals

„„ ιι: maps p(u: maps p(u11, , uukk) to 0, 1 or 1/2) to 0, 1 or 1/2

„„ Predicates: Predicates:

„„ Constituents of shape invariants that can be used to Constituents of shape invariants that can be used to characterize a data structure

characterize a data structure

„„ Core Predicates:Core Predicates:

„„ Tracking Pointer Variables and Pointer-Tracking Pointer Variables and Pointer-valued fieldsvalued fields

„„ Common to all the shape analysisCommon to all the shape analysis

„„ EgEg: x(v: x(v), n(v1, v2), ), n(v1, v2), sm(v)sm(v)

(5)

Representation Representation

„„

Predicates Predicates

„„ Instrumentation predicates:Instrumentation predicates:

„„ Properties derived from core semantics, not explicitly part Properties derived from core semantics, not explicitly part of the semantics of pointers in a language,

of the semantics of pointers in a language,

„„ Different algorithms use different sets of instrumentation Different algorithms use different sets of instrumentation

„„ EgEg: : is(v)is(v) (sharing), r(sharing), rxx(v(v)) (reachability(reachability))

„„ Defining formulae:Defining formulae:

(6)

Representation Representation

„„

Property Property - - Extraction Principle Extraction Principle

„„ Concrete Store: 2Concrete Store: 2--Valued LogicValued Logic

„„ Questions about properties of stores can be answered by Questions about properties of stores can be answered by evaluating formulae: 1=>hold, 0=>doesn

evaluating formulae: 1=>hold, 0=>doesnt holdt hold

„„ Abstract store: 3Abstract store: 3--Valued LogicValued Logic

„„ A formulae can evaluate to 1, 0, or A formulae can evaluate to 1, 0, or ½½..

„„ 1=>hold1=>hold

„„ 0=>doesn0=>doesnt holdt hold

„„ ½½ => don=> dont knowt know

(7)

Representation Representation

„„

Examples Examples

(8)

Bounded Structures Bounded Structures

„„

Bounded Structures: Bounded Structures:

„„ A logical structure where no two individuals A logical structure where no two individuals evaluates to the same value for all predicates evaluates to the same value for all predicates

„„

Upper bound on the size of bounded structures: Upper bound on the size of bounded structures:

„„

Canonical Abstraction: Canonical Abstraction:

(9)

Embedding Theorem Embedding Theorem

„„ Embedding:Embedding:

„„ A way to relate 2A way to relate 2--valued and 3-valued and 3-valued structuresvalued structures

„„ S can be embedded in S’S can be embedded in S::

„„ SurjectiveSurjective function f: Ufunction f: USS ÆÆ UUS’S

„„

„„ Embedding Theorem:Embedding Theorem:

„„ If S can be embedded in SIf S can be embedded in S, every piece of information , every piece of information extracted from S

extracted from S via a formula is a conservative via a formula is a conservative approximation of the information extracted from S.

approximation of the information extracted from S.

(10)

Predicate

Predicate - - update formula update formula

„„

Expressing semantics using logic Expressing semantics using logic

„„ PredicatePredicate--update update formulaeformulae ϕ ϕppstst : Define the new : Define the new value of p for every statement

value of p for every statement stst

„„ Transfer function:Transfer function:

(11)

Predicate

Predicate - - update formula update formula

„„ Core Predicates: the predicateCore Predicates: the predicate--update formulae is update formulae is exactly the same for 3

exactly the same for 3--valued logic and 2valued logic and 2--valued valued logic

logic

„„ Instrumentation Predicate:Instrumentation Predicate:

„„ Trivial update formula: usually unsatisfactoryTrivial update formula: usually unsatisfactory

„„ User supplied formula: need to prove it maintains correct User supplied formula: need to prove it maintains correct instrumentation.

instrumentation.

(12)

Predicate

Predicate - - update formula update formula

„„

Core Predicates: Core Predicates:

(13)

Predicate

Predicate - - update formula update formula

„„

Instrumentation predicate Instrumentation predicate

(14)

The Shape Analysis Algorithm The Shape Analysis Algorithm

„„

When analyzing a single procedure, allow an When analyzing a single procedure, allow an arbitrary set of 3

arbitrary set of 3 - - valued structures to hold at the valued structures to hold at the entry of the procedure

entry of the procedure

(15)

The Shape Analysis Algorithm The Shape Analysis Algorithm

„„

Example: Example:

(16)

A More Precise Abstract Semantics A More Precise Abstract Semantics

„„

Overview Overview

„„ FocusFocus

„„ Apply transfer functionApply transfer function

„„ coercecoerce

(17)

A More Precise Abstract Semantics A More Precise Abstract Semantics

„„

Focus: forces a given formula to a definite value Focus: forces a given formula to a definite value

(18)

A More Precise Abstract Semantics A More Precise Abstract Semantics

„„

Focus Example: Focus Example:

(19)

A More Precise Abstract Semantics A More Precise Abstract Semantics

„„

Coerce Coerce

„„ Sharpen a structure according to Compatibility Sharpen a structure according to Compatibility Constraints

Constraints

„„ Compatibility Constraints from Instrumentation Compatibility Constraints from Instrumentation Predicates

Predicates

„„ Compatibility Constraints from Compatibility Constraints from HygienceHygience ConditionsConditions

(20)

A More Precise Abstract Semantics A More Precise Abstract Semantics

„„

An algorithm to generate compatibility constraints An algorithm to generate compatibility constraints

„„ Definition Formula:Definition Formula:

„„ Extended Horn Clause:Extended Horn Clause:

„„ Compatibility constraints:Compatibility constraints:

(21)

A More Precise Abstract Semantics A More Precise Abstract Semantics

„„

Coerce Example: Coerce Example:

(22)

Related work Related work

„„

K K - - limiting limiting

„„ Use instrumentation predicates Use instrumentation predicates ““reachablereachable--fromfrom--xx-- viavia--accessaccess--pathpath--αα””, for |α, for |α|<=k|<=k

„„

Storage Shape Graphs [CWZ Storage Shape Graphs [CWZ ’ ’ 90] 90]

„„ Use core predicates that record the allocation sites of Use core predicates that record the allocation sites of heap cells

heap cells

„„

Doubly Doubly - - linked list linked list

„„ Use Instrument Predicate Use Instrument Predicate ccf.bf.b(v(v) and ) and ccb.fb.f(v(v) )

(23)

Related Work Related Work

„„

Biased versus unbiased static program analysis Biased versus unbiased static program analysis

„„ Conventional analysis has oneConventional analysis has one--sided bias:sided bias:

„„ May Analysis: May Analysis:

„„ false => false => falsefalse

„„ true => may be true/ may be falsetrue => may be true/ may be false

„„ Must Analysis:Must Analysis:

„„ true => true => truetrue

„„ false => may be true/ may be falsefalse => may be true/ may be false

„„ 33--Valued Logic:Valued Logic:

„„ unbiasedunbiased

(24)

Summary Summary

„„

A parametric framework A parametric framework

„„

Easy to experiment with new algorithms Easy to experiment with new algorithms

„„

For core predicates, abstract semantics falls out For core predicates, abstract semantics falls out from the concrete semantics

from the concrete semantics

„„

No need for a proof for a particular instantiation No need for a proof for a particular instantiation

(25)

Limitations Limitations

„„

Size potentially exponential Size potentially exponential

„„

Efficiency Efficiency

„„

Usually need to provide predicate Usually need to provide predicate - - update update

formulae for instrumentation predicates and to formulae for instrumentation predicates and to prove that these formulae maintains the correct prove that these formulae maintains the correct instrumentation. Is it more or less burdensome?

instrumentation. Is it more or less burdensome?

References

Related documents

l Asynchronous database update (via update task) l Application level locking.. Presentation.

Choose some initial estimates for P (wjQ; R = 1) Iteratively assume top k documents retrieved are relevant Update estimates.. Accuracy depends on initial

Let ∀ 2 ∃ 0 be the class of sentences in PNF having the said prefix, and vocabulary con- taining equality, one binary predicate and any number of unary predicates.. We also know

Row Share Lock SELECT FOR UPDATE Row Exclusive Lock INSERT, UPDATE, DELETE. Share Lock

• Specification : what the function is supposed to do Typical form: If the arguments satisfy certain properties, then a certain value will be returned, or a certain action will

• A pointer to a variable can be created in the main program and dereferenced during a function call. • This way a function can be allowed to modify variables in the main program,

Lecture 24– Circuit Verification with Predicate Calculus; Prolog start.. 23 rd

Dr.. Anubha and Kajal are partners of a firm sharing profits and losses in the ratio of 2:1. According to partnership deed, both partners are allowed salary, ₹ 700 per month to