1 / 46

Existential Quantification for Variant Ownership

This paper explores the concept of existential quantification for variant ownership, which statically partitions the heap and organizes objects into a hierarchical structure. This approach improves reasoning about programs, affects concurrency, memory management, and garbage collection. It discusses the many flavors of ownership, including parametric ownership, encapsulation properties, ownership hierarchy, and more. The paper also delves into the use of existential types and their bounds, as well as the motivation and goals of the proposed approach.

brendah
Download Presentation

Existential Quantification for Variant Ownership

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. Nicholas Cameron Sophia Drossopoulou Imperial College London (Victoria University of Wellington)‏ ncameron@ecs.vuw.ac.nz Existential Quantification forVariant Ownership

  2. Ownership

  3. Ownership • Statically partitions the heap • Organises objects into an hierarchical structure • Improves reasoning about programs • Effects • Concurrency • Memory Management • Garbage Collection • Many flavours • Encapsulation properties

  4. Ownership

  5. Ownership

  6. Ownership • Parametric ownership • Each object is owned by a context • context  object  owner • Classes and types are parameterised by contexts

  7. Ownership • Classes are parameterised by formal contexts • class C<o1, o2> {...} • o1 is the owner of objects of class C • o2 is another context

  8. Ownership • Types are parameterised by actual contexts • class C<o1, o2> {...} • C<this, this> • this • C<world, o> • World, formal contexts • C<x, f> • Final variables, final fields

  9. Ownership • Ownership hierarchy • o1:C<o3, a> • o2:C<o4, a> • o1 is insideo3 • o2 is insideo4 • If o4 is insideo3then o2 is insideo3

  10. Existential Types

  11. Existential Types • Used to model abstraction • ƎX.(X→int)‏ • Or variance in generic object-oriented languages • ƎX.List<X> • List<?> (Java wildcards)‏

  12. Existential Types • Bounds • ƎX→[Merino Animal].List<X> • Merino <: X <: Animal

  13. Existential Types • Safe covariance: • ƎX→[ Sheep].List<X> <:ƎX→[ Animal].List<X> • List<? ◄ Sheep> <:List<? ◄ Animal>

  14. Existential Types • Packing • pack(List<A>) = ƎX.List<X> • A is hidden – it is the witness type • close expression

  15. Existential Types • Unpacking • unpack(ƎX.List<X>) =List<Z> • Z is a fresh type variable • open expression

  16. JoƎ - Motivation

  17. Motivation • Desire for variance • +, -, * in Variant Ownership Types • Lu, Potter, ECOOP '06 • ? in MOJO • Cameron, Drossopoulou, Noble, Smith, OOPSLA '07 • any/readonly in Universes • Müller, Dietl, et al., many papers • any in Effective Ownership • Lu, Potter, POPL '06 • ...

  18. Motivation • All tailor-made solutions • No connection to established type theory • Limited expressivity

  19. Motivation • E.g., ? in MOJO • Strict substitution • If ? In .... • Strict method and field lookup • Permeates entire calculus • Additional subtype rules

  20. Motivation

  21. JoƎ

  22. JoƎ • Goals: • Expressivity • Uniformity

  23. JoƎ • Existential quantification of contexts • Parametrisation by typesandcontexts • This combination gives improved expressivity

  24. JoƎ Class List<owner, X> { List<owner, X> next; X datum; X get() {...} void add(X x) {...} }context parameters type parameters

  25. JoƎ • Generics and quantification for expressivity: • List<this, Sheep<this>> • Ǝo.List<o, Sheep<this>> • Ǝo.List<this, Sheep<o>> • List<this, Ǝo.Sheep<o>> • Ǝo.List<o, Sheep<o>>

  26. JoƎ • Flexible ownership language • Parametric methods • Type and context parameters • Actual contexts • Explicit unpacking • Upper and lower bounds on formal contexts

  27. JoƎ • Upper and lower bounds on formal contexts • Ǝo→[o5 o2].Sheep<o> • o is insideo2 • o5 is insideo

  28. JoƎ • Uniform • Uses only the purest form of existential types • No special cases to support variance • No tailored annotations • Variance is dealt with locally • Direct relation to long history of research on existential types

  29. JoƎ • Describes the topology of the heap • This topology is fixed, not variant • Type sound • Static description of topology reflects heap at runtime • Ownership hierarchy can 'grow', but not 'mutate' • Useful • e.g. effects

  30. JoƎ • Can encode other systems • Generic Universes • Dietl, Drossoploulou, Müller, ECOOP '07 • Existential owners for downcasting • Wrigstad, Clarke, JOT, May '07 • Variant Ownership Types? • Lu, Potter, ECOOP '06 • Single owner case of MOJO • Cameron, Drossopoulou, Noble, Smith, OOPSLA '07

  31. How it Works

  32. JoƎ

  33. JoƎ • Three environments • Variable environment

  34. JoƎ • Owner environment • Quantified contexts are unpacked here • Does not affect this rule

  35. JoƎ • Type environment • Owner bounds

  36. JoƎ • Substitute receiver for this

  37. JoƎ • Receiver cannot be arbitrary expression • But no loss of expressivity • Thanks to open expression

  38. JoƎ • Receiver must have class type • Forces unpacking • Don't account for quantification here

  39. Summary • Parametric ownership+ Existential quantification of contexts+ Generics= JoƎ • Expressive and Uniform • Can encode existing systems

  40. ncameron@ecs.vuw.ac.nz Thank you!

  41. Ownership • Encapsulation • Owners-as-Dominators • Owners-as-Modifiers • Link Soundness • ... • Owners-as-Dominators • All paths through the heap to an object are dominated by that object's owner • Common for parametric ownership systems • Useful for garbage collection, memory management, ...

  42. Ownership • Owners-as-Dominators

  43. Ownership • Owners-as-Modifiers

  44. Encapsulation

  45. JoƎdeep • Owners-as-Dominators • Strong encapsulation property • Very small modifications • Well-formed heap • Well-formed classes • Class type checking

  46. JoƎdeep • Treat existentially quantified context variables as their lower bounds • Owners-as-dominators involves showing referenced objects are outside their owners • If the lower bound is outside, then the hidden context must be outside

More Related