scispace - formally typeset
Search or ask a question
Book ChapterDOI

Flow-Directed Closure Conversion for Typed Languages

TL;DR: Experimental results over a range of benchmarks including large real-world programs such as the compiler itself and the ML-Kit indicate that the compile-time cost of flow analysis and closure conversion is extremely small, and that the dispatches and coercions inserted by the algorithm are dynamically infrequent.
Abstract: This paper presents a new closure conversion algorithm for simply-typed languages. We have have implemented the algorithm as part of MLton, a whole-program compiler for Standard ML (SML). MLton first applies all functors and eliminates polymorphism by code duplication to produce a simply-typed program. MLton then performs closure conversion to produce a first-order, simply-typed program. In contrast to typical functional language implementations, MLton performs most optimizations on the first-order language, after closure conversion. There are two notable contributions of our work: 1. The translation uses a general flow-analysis framework which includes OCFA. The types in the target language fully capture the results of the analysis. MLton uses the analysis to insert coercions to translate between different representations of a closure to preserve type correctness of the target language program. 2. The translation is practical. Experimental results over a range of benchmarks including large real-world programs such as the compiler itself and the ML-Kit [25] indicate that the compile-time cost of flow analysis and closure conversion is extremely small, and that the dispatches and coercions inserted by the algorithm are dynamically infrequent.

Content maybe subject to copyright    Report

Citations
More filters
Proceedings ArticleDOI
05 Sep 2001
TL;DR: Practical applications of defunctionalization are studied and new connections between seemingly unrelated higher-order and first-order specifications and between their correctness proofs are uncovered.
Abstract: Reynolds's defunctionalization technique is a whole-program transformation from higher-order to first-order functional programs. We study practical applications of this transformation and uncover new connections between seemingly unrelated higher-order and first-order specifications and between their correctness proofs. Defunctionalization therefore appearsboth as a springboard for rev ealing new connections and as a bridge for transferring existing results between the first-order world and the higher-order world.

180 citations

Posted Content
TL;DR: Buffet as mentioned in this paper is a built system that provides inexpensive RAM and dynamic control flow for verifiable computations, allowing the programmer to express programs in an expansive subset of C (disallowing only goto and function pointers).
Abstract: Recent work on proof-based verifiable computation has resulted in built systems that employ tools from complexity theory and cryptography to address a basic problem in systems security: allowing a local computer to outsource the execution of a program while providing the local computer with a guarantee of integrity and the remote computer with a guarantee of privacy. However, support for programs that use RAM and control flow has been problematic. State of the art systems either restrict the use of these constructs (e.g., requiring static loop bounds), incur sizeable overhead on every step, or pay tremendous costs when the constructs are invoked. This paper describes Buffet, a built system that solves these problems by providing inexpensive “a la carte” RAM and dynamic control flow. Buffet composes an elegant prior approach to RAM with a novel adaptation of techniques from the compilers literature. Buffet allows the programmer to express programs in an expansive subset of C (disallowing only “goto” and function pointers), can handle essentially any example in the verifiable computation literature, and achieves the best performance in the area by multiple orders of magnitude.

111 citations

Proceedings ArticleDOI
15 Jan 2003
TL;DR: TALT is the first formalized typed assembly language to provide any of these features, including heterogeneous tuples, disjoint sums, and a general account of addressing modes, which are shown by machine-checkable proofs.
Abstract: We present the design of a typed assembly language called TALT that supports heterogeneous tuples, disjoint sums, and a general account of addressing modes. TALT also implements the von Neumann model in which programs are stored in memory, and supports relative addressing. Type safety for execution and for garbage collection are shown by machine-checkable proofs. TALT is the first formalized typed assembly language to provide any of these features.

104 citations

Proceedings ArticleDOI
01 Feb 2015
TL;DR: Buffet as discussed by the authors is a built system that provides inexpensive RAM and dynamic control flow for verifiable computations, allowing the programmer to express programs in an expansive subset of C (disallowing only goto and function pointers).
Abstract: Recent work on proof-based verifiable computation has resulted in built systems that employ tools from complexity theory and cryptography to address a basic problem in systems security: allowing a local computer to outsource the execution of a program while providing the local computer with a guarantee of integrity and the remote computer with a guarantee of privacy. However, support for programs that use RAM and control flow has been problematic. State of the art systems either restrict the use of these constructs (e.g., requiring static loop bounds), incur sizeable overhead on every step, or pay tremendous costs when the constructs are invoked. This paper describes Buffet, a built system that solves these problems by providing inexpensive “a la carte” RAM and dynamic control flow. Buffet composes an elegant prior approach to RAM with a novel adaptation of techniques from the compilers literature. Buffet allows the programmer to express programs in an expansive subset of C (disallowing only “goto” and function pointers), can handle essentially any example in the verifiable computation literature, and achieves the best performance in the area by multiple orders of magnitude.

92 citations

Journal ArticleDOI
Jan Midtgaard1
TL;DR: In this article, control-flow analysis of functional programs is surveyed by structuring the multitude of formulations and approximations and comparing them.
Abstract: We present a survey of control-flow analysis of functional programs, which has been the subject of extensive investigation throughout the past 30 years. Analyses of the control flow of functional programs have been formulated in multiple settings and have led to many different approximations, starting with the seminal works of Jones, Shivers, and Sestoft. In this article, we survey control-flow analysis of functional programs by structuring the multitude of formulations and approximations and comparing them.

83 citations

References
More filters
Book
01 Jan 1990
TL;DR: This book provides a formal definition of Standard ML for the benefit of all concerned with the language, including users and implementers, and the authors have defined their semantic objects in mathematical notation that is completely independent of StandardML.
Abstract: From the Publisher: Standard ML is general-purpose programming language designed for large projects. This book provides a formal definition of Standard ML for the benefit of all concerned with the language, including users and implementers. Because computer programs are increasingly required to withstand rigorous analysis, it is all the more important that the language in which they are written be defined with full rigor. The authors have defined their semantic objects in mathematical notation that is completely independent of Standard ML.

2,389 citations

Book
01 May 1997
TL;DR: Part 1 Syntax of the core: reserved words special constants comments identifiers lexical analysis infixed operators derived forms grammar syntactic restrictions.
Abstract: Part 1 Syntax of the core: reserved words special constants comments identifiers lexical analysis infixed operators derived forms grammar syntactic restrictions. Part 2 Syntax of modules: reserved words identifiers infixed operators grammar for modules syntactic restrictions. Part 3 Static semantics for the core: simple objects compound objects projection, injection and modification types and type functions type schemes scope of explicit type variables non-expansive expressions closure type structures and type environments inference rules further restrictions. Part 4 Static semantics for modules: semantic objects type realization signature instantiation functor signature instantiation enrichment signature matching inference rules. Part 5 Dynamic semantics for the core: reduced syntax simple objects compound objects basic values basic exceptions function closures inference rules. Part 6 Dynamic semantics for modules: reduced syntax compound objects inference rules. Part 7 Programmes. Part 8 Appendices.

971 citations


"Flow-Directed Closure Conversion fo..." refers background in this paper

  • ...” In this regard, the semantics of exceptions is similar to the presentation given in [15]....

    [...]

Proceedings ArticleDOI
01 Aug 1972
TL;DR: The definition of a simple applicative programming language by means of an interpreter written in a similar language is considered, and the treatment of imperative features such as jumps and assignment is discussed.
Abstract: Higher-order programming languages (i.e., languages in which procedures or labels can occur as values) are usually defined by interpreters which are themselves written in a programming language based on the lambda calculus (i.e., an applicative language such as pure LISP). Examples include McCarthy's definition of LISP, Landin's SECD machine, the Vienna definition of PL/I, Reynolds' definitions of GEDANKEN, and recent unpublished work by L. Morris and C. Wadsworth. Such definitions can be classified according to whether the interpreter contains higher-order functions, and whether the order of application (i.e., call-by-value versus call-by-name) in the defined language depends upon the order of application in the defining language. As an example, we consider the definition of a simple applicative programming language by means of an interpreter written in a similar language. Definitions in each of the above classifications are derived from one another by informal but constructive methods. The treatment of imperative features such as jumps and assignment is also discussed.

743 citations


"Flow-Directed Closure Conversion fo..." refers methods in this paper

  • ...Like previous work on defunctionalization [19,3], the translation implements closures as elements of a datatype, and dispatches at call-sites to the appropriate code....

    [...]

  • ...Inspired by a technique first described by Reynolds [19], they suggest representing closures as members of a datatype, with one datatype for each different arrow type in the source program....

    [...]

Book
29 Nov 1991
TL;DR: In this article, the authors show how continuation-passing style is used as an intermediate representation to perform optimizations and program transformations for modern languages like ML, and show how concepts from the theory of programming languages can be applied to the production of practical optimizing compilers.
Abstract: This book shows how continuation-passing style is used as an intermediate representation to perform optimizations and program transformations. Continuations can be used to compile most programming languages. The method is illustrated in a compiler for the programming language Standard ML. Prior knowledge of ML, however, is not necessary, as the author carefully explains each concept as it arises. This is the first book to show how concepts from the theory of programming languages can be applied to the production of practical optimizing compilers for modern languages like ML. All the details of compiling are covered, including the interface to a runtime system and garbage collector.

734 citations

Proceedings ArticleDOI
01 May 1996
TL;DR: TIL introduced and popularized the notion of a certifying compiler, which attaches a checkable certificate of safety to its generated code, inspiring the development of Proof-Carrying Code and Typed Assembly Language as certified object code formats.
Abstract: The goal of the TIL project was to explore the use of Typed Intermediate Languages to produce high-performance native code from Standard ML (SML). We believed that existing SML compilers were doing a good job of conventional functional language optimizations, as one might find in a LISP compiler, but that inadequate use was made of the rich type information present in the source language. Our goal was to show that we could get much greater performance by propagating type information through to the back end of the compiler, without sacrificing the advantages afforded by loop-oriented and other optimizations.We also confirmed that using typed intermediate languages dramatically improved the reliability and maintainability of the compiler itself. In particular, we were able to use the type system to express critical invariants, and enforce those invariants through type checking. In this respect, TIL introduced and popularized the notion of a certifying compiler, which attaches a checkable certificate of safety to its generated code. In turn, this led directly to the idea of certified object code, inspiring the development of Proof-Carrying Code and Typed Assembly Language as certified object code formats.

311 citations


Additional excerpts

  • ...Our work is also related to other compiler eorts based on typed intermediate representations [ 23 ,14]....

    [...]