1 / 46

A Semantics for Procedure Local Heaps and its Abstractions

This study explores semantics for procedure local heaps, focusing on shape analysis and abstractions for imperative programs with procedures. The research addresses challenges like destructive updates and recursive data structures, proposing concrete operational semantics and shape abstractions. It compares observations with "standard" semantics and provides a detailed outline and motivating examples. The approach aims to offer a localized effect of procedures in imperative programming.

preusser
Download Presentation

A Semantics for Procedure Local Heaps and its Abstractions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Semantics for Procedure Local Heapsand its Abstractions Noam Rinetzky Tel Aviv University Jörg Bauer Universität des Saarlandes Thomas Reps University of Wisconsin Mooly Sagiv Tel Aviv University Reinhard Wilhelm Universität des Saarlandes

  2. Motivation • Interprocedural shape analysis • Conservative static pointer analysis • Heap intensive programs • Imperative programs with procedures • Recursive data structures • Challenge • Destructive update • Localized effect of procedures

  3. x x x x y g t Main idea • Local heaps call p(x); y g t

  4. x x x x y g t Main idea • Local heaps • Cutpoints call p(x); y g t

  5. Main Results • Concrete operational semantics • Large step • Functional analysis • Storeless • Shape abstractions • Local heap • Observationally equivalent to “standard” semantics • Java and “clean” C • Abstractions • Shape analysis [Sagiv, Reps, Wilhelm, TOPLAS ‘02] • May-alias [Deutsch, PLDI ‘94] • …

  6. Outline • Motivating example • Local heaps • Cutpoints • Why semantics • Local heap storeless semantics • Shape abstraction

  7. n n t n n q q n n n n p x n n n t t r r n n n n n n Example static List reverse(List t) { } static void main() { } … p List x = reverse(p); List y = reverse(q); List z = reverse(x); return r;

  8. n n n n t t n n n n p p x x n n n n n q y t t r r n n n n n n n n n n Example static List reverse(List t) { } static void main() { } List x = reverse(p); q List y = reverse(q); List z = reverse(x); return r;

  9. n t t n n p n t n p p x x n n n n n n n n q x q y y z t t r r n n n n n n n n n n n n n n n n Example static List reverse(List t) { } static void main() { } List x = reverse(p); List y = reverse(q); List z = reverse(x); return r;

  10. Cutpoints • Separatingobjects • Not pointed-to by a parameter

  11. n n n n n Cutpoints • Separatingobjects • Not pointed-to by a parameter proc(x) n p x Stack sharing

  12. n n n n n n n Cutpoints • Separatingobjects • Not pointed-to by a parameter proc(x) proc(x) n n n n n x p x n n y Stack sharing Heap sharing

  13. n n n n n n n Cutpoints • Separatingobjects • Not pointed-to by a parameter • Capture external sharing patterns proc(x) proc(x) n n n n n x p x n n y Stack sharing Heap sharing

  14. t p n n n p x n n n n n n q z q x y y r r t t n n n n n n n n n n n n Example static List reverse(List t) { } static void main() { } List x = reverse(p); List y = reverse(q); n n n p x List z = reverse(x); return r;

  15. Outline • Motivating example • Why semantics • Local heap storeless semantics • Shape abstraction

  16. Operational semantics   Abstract transformer Abstract Interpretation[Cousot and Cousot, POPL ’77]

  17. Operational semantics Abstract transformer ’ ’ Introducing local heap semantics ~ Local heap Operational semantics

  18. Outline • Motivating example • Why semantics • Local heap storeless semantics • Shape abstraction

  19. Programming model • Single threaded • Procedures • Value parameters • Recursion • Heap • Recursive data structures • Destructive update • No explicit addressing (&) • No pointer arithmetic

  20. Simplifying assumptions • No primitive values (only references) • No globals • Formals not modified

  21. y.n.n x.n.n y x x.n y.n n n n n y x x n n y x.n.n y.n.n x y x.n y.n Storeless semantics • No addresses • Memory state: • Object: 2Access paths • Heap: 2Object • Alias analysis y=x x=null

  22. n n n t n n n t z z.n z.n.n x z.n.n.n x t.n.n.n t.n.n t.n t z n n n n n n n q q y.n.n q y.n.n q y.n y.n y y y y t n n n r r.n r.n.n t r.n.n.n t n n n r r.n r.n.n t r.n.n.n r r Example static void main() { } static List reverse(List t) { return r; } List x = reverse(p); List y = reverse(q); t.n.n.n t.n.n t.n t n n n x.n.n.n p x.n.n x.n x p x List z = reverse(x); p?

  23. n n n p L L t t n p z p.n z.n p.n.n z.n.n x p.n.n.n z.n.n.n n n x t.n.n.n L t.n.n t.n t z n n n n n n n q q y.n.n q y.n.n q y.n y.n y y y y p.n.n.n p p.n.n p.n L t n n n L r L.n r.n L.n.n r.n.n t L.n.n.n r.n.n.n L t n n n L r L.n r.n L.n.n r.n.n t L.n.n.n r.n.n.n r r Example static void main() { } static List reverse(List t) { return r; } List x = reverse(p); List y = reverse(q); t.n.n.n L t.n.n t.n t n n n x.n.n.n p x.n.n x.n x p x List z = reverse(x);

  24. Cutpoint labels • Relate pre-state with post-state • Additional roots • Mark cutpoints at and throughoutan invocation

  25. Cutpoint labels • Cutpoint label: the set of access paths that point to a cutpoint • when the invoked procedure starts t.n.n.n L t.n.n t.n t t L L  {t.n.n.n}

  26. L L t t n n n n n n t.n.n.n L t.n.n.n L t.n.n t.n.n t.n t.n t t Sharing patterns • Cutpoint labels encode sharing patterns n n w.n w w p Stack sharing Heap sharing L  {t.n.n.n}

  27. Observational equivalence • L  L (Local-heap Storeless Semantics) • G  G (Global-heap Store-based Semantics) L and Gobservationally equivalent when for every access paths AP1, AP2  AP1 = AP2 (L)  AP1 = AP2 (G)

  28. Main theorem: semantic equivalence • L  L (Local-heap Storeless Semantics) • G  G (Global-heap Store-based Semantics) • L and G observationally equivalent st,L  ’Lst,G  ’G LSL GSB ’L and ’G areobservationally equivalent

  29. Corollaries • Preservation of invariants • Assertions: AP1 = AP2 • Detection of memory leaks

  30. Applications • Develop new static analyses • Shape analysis • Justify soundness of existing analyses • May-alias analysis [TAU-TR-26/04]

  31. Outline • Motivating example • Why semantics • Local heap storeless • Shape abstraction

  32. Shape abstraction • Shape descriptorsrepresent unbounded memory states • Conservatively • In a bounded way • Two dimensions • Local heap (objects) • Sharing pattern (cutpoint labels)

  33. AShape abstraction L={t.n.n.n} r n n n r L r.n L.n r.n.n L.n.n t, r.n.n.n L.n.n.n t L

  34. AShape abstraction L=* r n n n r L r.n L.n r.n.n L.n.n t, r.n.n.n L.n.n.n t L

  35. L=* n r n n n r L r.n L.n t, r.n L.n t L AShape abstraction L=* r n n r L r.n L.n r.n L.n t, r.n L.n t L

  36. L=* n r n n r L r.n L.n t, r.n L.n t L AShape abstraction

  37. L=* n r n n r L r.n L.n t, r.n L.n t L AShape abstraction L={t.n.n.n} r n n n r L r.n L.n r.n.n L.n.n t, r.n.n.n L.n.n.n t L

  38. AShape abstraction L2={g.n.n.n} L1={t.n.n.n} n d n n d L2 d.n L2.n d.n.n L2.n.n g, d.n.n.n L2.n.n.n g L2 r n n n r L1 r.n L1.n r.n.n L1.n.n t, r.n.n.n L1.n.n.n t L1 L=* n d n n d L d.n L.n t, d.n L.n t n L n n r L r.n L.n t, r.n L.n t r

  39. Application (joint work with Eran Yahav) • A framework for shape analysis using local heaps • Parametric abstraction • Local heap (lists, trees, …) • Sharing patterns

  40. Application • Properties proved • Absence of null dereferences • Listness preservation • API conformance • Recursive  Iterative • Procedural abstraction

  41. Outline • Motivating example • Why semantics • Local heap storeless • Shape abstraction

  42. Related work • Storeless semantics • Jonkers, Algorithmic Languages ‘81 • Deutsch, ICCL ‘92

  43. Related work • Interprocedural shape analysis • Rinetzky and Sagiv, CC ’01 • Global heap • Jeannet et al., SAS ’04 • Local heap, relational • Chong and Rugina, SAS ’03 • Local heap • Hackett and Rugina, POPL ’05 • Next talk …

  44. Related work • Local reasoning • Ishtiaq and O’Hearn, POPL ‘01 • Reynolds, LICS ’02

  45. Summary • Operational semantics • Storeless • Local heap • Cutpoints • Equivalence theorem • Applications • Shape analysis • May-alias analysis

  46. End A Semantics for procedure local heaps and its abstraction Noam Rinetzky, Jörg Bauer, Thomas Reps, Mooly Sagiv, and Reinhard Wilhelm AVACS Technical Report 1 Interprocedural functional shape analysis using local heaps Noam Rinetzky, Mooly Sagiv, and Eran Yahav School of Computer Science, Tel Aviv University, Technical Report 26/04 www.cs.tau.ac.il/~maon

More Related