parametric shape parametric shape analysis via 3 valued
play

Parametric Shape Parametric Shape Analysis via 3- -Valued Valued - PowerPoint PPT Presentation

Parametric Shape Parametric Shape Analysis via 3- -Valued Valued Analysis via 3 Logic Logic Mooly Sagiv Sagiv, Thomas Reps, , Thomas Reps, Mooly Reinhard Wilhelm Wilhelm Reinhard Motivation Motivation Many shape analysis


  1. Parametric Shape Parametric Shape Analysis via 3- -Valued Valued Analysis via 3 Logic Logic Mooly Sagiv Sagiv, Thomas Reps, , Thomas Reps, Mooly Reinhard Wilhelm Wilhelm Reinhard

  2. Motivation Motivation � Many shape analysis algorithms developed Many shape analysis algorithms developed � � Different abstractions Different abstractions � � Hard to compare Hard to compare � � Parametric Framework Parametric Framework � � yacc yacc for shape analysis? for shape analysis? �

  3. Overview Overview � Use logic structures to represent stores Use 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, implement Define 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 system The rest is automatically done by the system �

  4. Representation Representation � Logical Structures: Logical Structures: � ι > S=<U, ι � S=<U, > � � U: individuals U: individuals � � ι ι : maps p(u : maps p(u 1 1 , , … … u u k k ) 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 fields valued fields � � Common to all the shape analysis Common to all the shape analysis � � Eg Eg: : 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 � � Eg Eg: : is(v is(v) ) (sharing), (sharing), r r x (v) ) ( (reachability reachability) ) x (v � � Defining formulae: Defining formulae: �

  6. Representation Representation � Property Property- -Extraction Principle Extraction Principle � � Concrete Store: 2 Concrete Store: 2- -Valued Logic Valued 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 ’ t hold evaluating formulae: 1=>hold, 0=>doesn ’ t hold � Abstract store: 3 Abstract store: 3- -Valued Logic Valued Logic � � A formulae can evaluate to 1, 0, or A formulae can evaluate to 1, 0, or ½ . ½ . � � 1=>hold 1=>hold � � 0=>doesn 0=>doesn ’ t hold ’ t hold � ½ => don => don ’ t know ’ t 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 2 A way to relate 2- -valued and 3 valued and 3- -valued structures valued structures � � S can be embedded in S S can be embedded in S ’ : ’ : � S � � Surjective Surjective function f: U function f: U S � U U S S ’ ’ � � � � Embedding Theorem: Embedding Theorem: � � If S can be embedded in S If S can be embedded in S ’ , every piece of information ’ , every piece of information � extracted from S ’ ’ via a formula is a conservative via a formula is a conservative extracted from S approximation of the information extracted from S. approximation of the information extracted from S.

  10. Predicate- -update formula update formula Predicate � Expressing semantics using logic Expressing semantics using logic � st : Define the new ϕ p formulae ϕ � Predicate Predicate- -update update formulae : Define the new pst � value of p for every statement st st value of p for every statement � Transfer function: Transfer function: �

  11. Predicate- -update formula update formula Predicate � Core Predicates: the predicate Core Predicates: the predicate- -update formulae is update formulae is � exactly the same for 3- -valued logic and 2 valued logic and 2- -valued valued exactly the same for 3 logic logic � Instrumentation Predicate: Instrumentation Predicate: � � Trivial update formula: usually unsatisfactory Trivial 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- -update formula update formula Predicate � Core Predicates: Core Predicates: �

  13. Predicate- -update formula update formula Predicate � 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- -valued structures to hold at the valued structures to hold at the arbitrary set of 3 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 � � Focus Focus � � Apply transfer function Apply transfer function � � coerce coerce �

  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 Hygience Hygience Conditions Conditions �

  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 “ reachable- -from from- -x x- - “ reachable � α ” α |<=k - α , for | α via- -access access- -path path- |<=k via ” , for | � 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 c c f.b (v) and ) and c c b.f (v) ) f.b (v b.f (v �

  23. Related Work Related Work � Biased versus unbiased static program analysis Biased versus unbiased static program analysis � � Conventional analysis has one Conventional analysis has one- -sided bias: sided bias: � � May Analysis: May Analysis: � � false => false => false false � � true => may be true/ may be false true => may be true/ may be false � � Must Analysis: Must Analysis: � � true => true => true true � � false => may be true/ may be false false => may be true/ may be false � � 3 3- -Valued Logic: Valued Logic: � � unbiased unbiased �

  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 �

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend