Uniqueness and reference immutability for safe parallelism

A key challenge for concurrent programming is that side-effects (memory operations) in one thread can affect the behavior of another thread. In this paper, we present a type system to restrict the updates to memory to prevent these unintended side-effects. We provide a novel combination of immutable and unique (isolated) types that ensures safe parallelism (race freedom and deterministic execution). The type system includes support for polymorphism over type qualifiers, and can easily create cycles of immutable objects. Key to the system's flexibility is the ability to recover immutable or externally unique references after violating uniqueness without any explicit alias tracking. Our type system models a prototype extension to C# that is in active use by a Microsoft team. We describe their experiences building large systems with this extension. We prove the soundness of the type system by an embedding into a program logic.

[1]  Peter Müller,et al.  Ownership transfer in universe types , 2007, OOPSLA.

[2]  John C. Reynolds,et al.  Syntactic control of interference for separation logic , 2012, POPL '12.

[3]  Sophia Drossopoulou,et al.  Aliasing, Confinement, and Ownership in Object-Oriented Programming , 2008, ECOOP Workshops.

[4]  Vivek Sarkar,et al.  Practical Permissions for Race-Free Parallelism , 2012, ECOOP.

[5]  J ParkinsonMatthew,et al.  Uniqueness and reference immutability for safe parallelism , 2012 .

[6]  Jeffrey Overbey,et al.  A type and effect system for deterministic parallel Java , 2009, OOPSLA 2009.

[7]  Michael D. Ernst,et al.  Object and reference immutability using Java generics , 2007, ESEC-FSE '07.

[8]  Martín Abadi,et al.  Object Types against Races , 1999, CONCUR.

[9]  Sophia Drossopoulou,et al.  Generic Universe Types , 2007, ECOOP.

[10]  K. Rustan M. Leino,et al.  Flexible Immutability with Frozen Objects , 2008, VSTTE.

[11]  John C. Reynolds,et al.  Separation logic: a logic for shared mutable data structures , 2002, Proceedings 17th Annual IEEE Symposium on Logic in Computer Science.

[12]  Peter W. O'Hearn,et al.  Local Reasoning about Programs that Alter Data Structures , 2001, CSL.

[13]  Martín Abadi,et al.  Types for Safe Locking , 1999, ESOP.

[14]  K. Rustan M. Leino,et al.  Specification and verification , 2011, Commun. ACM.

[15]  Sophia Drossopoulou,et al.  Universes for Race Safety , 2007 .

[16]  Martin C. Rinard,et al.  ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), November 2002 Ownership Types for Safe Programming: Preventing Data Races and Deadlocks , 2022 .

[17]  Erik Poll,et al.  Type-based Object Immutability with Flexible Initialization - extended version , 2009 .

[18]  Adam Welc,et al.  Safe nondeterminism in a deterministic-by-default parallel language , 2011, POPL '11.

[19]  John Tang Boyland,et al.  Connecting effects and uniqueness with adoption , 2005, POPL '05.

[20]  Stephen N. Freund,et al.  Type-based race detection for Java , 2000, PLDI '00.

[21]  Steve Zdancewic,et al.  Lightweight linear types in system f° , 2010, TLDI '10.

[22]  Claudio V. Russo,et al.  Pause 'n' Play: Formalizing Asynchronous C# , 2012, ECOOP.

[23]  Michael D. Ernst,et al.  Ownership and immutability in generic Java , 2010, OOPSLA.

[24]  John Tang Boyland,et al.  Checking Interference with Fractional Permissions , 2003, SAS.

[25]  Martin C. Rinard,et al.  A parameterized type system for race-free Java programs , 2001, OOPSLA '01.

[26]  Philipp Haller,et al.  Isolated Actors for Race-Free Concurrent Programming , 2010 .

[27]  Robert DeLine,et al.  Adoption and focus: practical linear types for imperative programming , 2002, PLDI '02.

[28]  Carl Hewitt,et al.  Actor induction and meta-evaluation , 1973, POPL.

[29]  Mads Tofte,et al.  Implementation of the typed call-by-value λ-calculus using a stack of regions , 1994, POPL '94.

[30]  Richard Bornat,et al.  Variables as Resource in Hoare Logics , 2006, 21st Annual IEEE Symposium on Logic in Computer Science (LICS'06).

[31]  Dave Clarke,et al.  Ownership, Uniqueness, and Immutability , 2008, TOOLS.

[32]  Martin Odersky,et al.  Capabilities for Uniqueness and Borrowing , 2010, ECOOP.

[33]  Hongseok Yang,et al.  Views: compositional reasoning for concurrent programs , 2013, POPL.

[34]  John Tang Boyland,et al.  Alias burying: Unique variables without destructive reads , 2001, Softw. Pract. Exp..

[35]  Einar Broch Johnsen,et al.  Minimal Ownership for Active Objects , 2008, APLAS.

[36]  Michael D. Ernst,et al.  Javari: adding reference immutability to Java , 2005, OOPSLA '05.

[37]  Jonathan Aldrich,et al.  A type system for borrowing permissions , 2012, POPL '12.

[38]  Jonathan Aldrich,et al.  Modular typestate checking of aliased objects , 2007, OOPSLA.

[39]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.