Compiler support for lightweight concurrency

This paper describes the design of a direct-style, λ-calculus-based compiler intermediate representation (IR) suitable for implementing a wide range of surface-language concurrency features while allowing flexibility in the back-end implementation. The features that this IR includes to support concurrency include a weak but inexpensive form of continuations and primitives for thread creation, scheduling, and termination. Although this work has been done in the context of implementing concurrency for the MOBY programming language, the model is general and could be used in the context of other languages. In this paper, we describe the IR’s continuations and thread manipulation primitives and illustrate their expressiveness with examples of various concurrency operations. We define an operational semantics to specify the operations precisely and to provide a tool for reasoning about the correctness of implementations. To illustrate the flexibility of our the approach, we describe two existing implementations of the threading model — one based on a one-to-one mapping of language threads to POSIX threads and one based on a many-to-many mapping.

[1]  Rob Pike A Concurrent Window System , 1989, Comput. Syst..

[2]  Simon L. Peyton Jones,et al.  A single intermediate language that supports multiple implementations of exceptions , 2000, PLDI '00.

[3]  Robert Hieb,et al.  Representing control in the presence of first-class continuations , 1990, PLDI '90.

[4]  Marvin Theimer,et al.  Using threads in interactive systems: a case study , 1993, SOSP '93.

[5]  John H. Reppy Local CPS conversion in a direct-style compiler (extended abstract) , 2000 .

[6]  Riccardo Pucella,et al.  A framework for interoperability , 2001, Electron. Notes Theor. Comput. Sci..

[7]  Mauricio J. Serrano,et al.  Thin locks: featherweight Synchronization for Java , 2004, SIGP.

[8]  Mitchell Wand,et al.  Continuation-Based Multiprocessing , 1980, High. Order Symb. Comput..

[9]  R. Kent Dybvig,et al.  Representing control in the presence of one-shot continuations , 1996, PLDI '96.

[10]  John H. Reppy,et al.  Concurrent programming in ML , 1999 .

[11]  Mitchell Wand,et al.  Continuations and coroutines , 1984, LFP '84.

[12]  Walter H. Kohler,et al.  Concurrency Features for the Trellis/Owl Language , 1987, ECOOP.

[13]  Simon Peyton Jones,et al.  Featherweight concurrency in a portable assembly language , 2001 .

[14]  Andrew W. Appel,et al.  Iterated register coalescing , 1996, TOPL.

[15]  Harold Abelson,et al.  Revised5 report on the algorithmic language scheme , 1998, SIGP.

[16]  J. Gregory Morrisett,et al.  Adding threads to Standard ML , 1990 .

[17]  Mauricio J. Serrano,et al.  Thin locks: featherweight synchronization for Java , 1998, PLDI '98.

[18]  David Tarditi Compact garbage collection tables , 2000, ISMM '00.

[19]  John H. Reppy,et al.  The design of a class mechanism for Moby , 1999, PLDI '99.

[20]  Olin Shivers Continuations and threads: Expressing machine concurrency directly in advanced languages , 1997 .

[21]  John H. Reppy,et al.  CML: A Higher-Order Concurrent Language , 1991, PLDI.

[22]  Andrew W. Appel,et al.  Standard ML of New Jersey , 1991, PLILP.

[23]  Amer Diwan,et al.  Compiler support for garbage collection in a statically typed language , 1992, PLDI '92.

[24]  Jonathan Rees,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.

[25]  C Ansi,et al.  Draft proposed american national standard for information systems---programming language c , 1988 .

[26]  John H. Reppy,et al.  Asynchronous Signals is Standard ML , 1990 .

[27]  David R. Butenhof Programming with POSIX threads , 1993 .

[28]  Brian N. Bershad,et al.  Fast mutual exclusion for uniprocessors , 1992, ASPLOS V.

[29]  Simon L. Peyton Jones,et al.  C-: A Portable Assembly Language , 1997, Implementation of Functional Languages.

[30]  Fermin Reig,et al.  Annotations for Portable Intermediate Languages , 2001, BABEL.

[31]  R. Kent Dybvig,et al.  Revised5 Report on the Algorithmic Language Scheme , 1986, SIGP.

[32]  Arvind,et al.  M-Structures: Extending a Parallel, Non-strict, Functional Language with State , 1991, FPCA.

[33]  James M. Stichnoth,et al.  Support for garbage collection at every instruction in a Java compiler , 1999, PLDI '99.

[34]  Simon L. Peyton Jones,et al.  Concurrent Haskell , 1996, POPL '96.

[35]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[36]  Jaroslaw Milewski Functional Data Structures as Updatable Objects , 1990, IEEE Trans. Software Eng..

[37]  Brian N. Bershad,et al.  Scheduler activations: effective kernel support for the user-level management of parallelism , 1991, TOCS.

[38]  Barbara Liskov,et al.  Implementation of Argus , 1987, SOSP '87.

[39]  Emden R. Gansner,et al.  A multi-threaded higher-order user interface toolkit , 1993 .

[40]  Olin Shivers,et al.  Atomic heap transactions and fine-grain interrupts , 1999, ICFP '99.

[41]  Greg Morrisett,et al.  Mostly-Copying Collection: A Viable Alternative to Conservative Mark-Sweep , 1997 .

[42]  Amr Sabry,et al.  The essence of compiling with continuations , 1993, PLDI '93.

[43]  John H. Reppy,et al.  A Portable and Optimizing Back End for the SML/NJ Compiler , 1994, CC.