17 research outputs found

    Eta-Expansion Does The Trick (Revised Version)

    Get PDF
    Partial-evaluation folklore has it that massaging one's source programs can make them specialize better. In Jones, Gomard, and Sestoft's recent textbook, a whole chapter is dedicated to listing such "binding-time improvements": nonstandard use of continuation passing style, eta-expansion, and a popular transformation called "The Trick". We provide a unified view of these binding-time improvements, from a typing perspective.Just as a proper treatment of product values in partial evaluationrequires partially static values, a proper treatment of disjoint sums requires moving static contexts across dynamic case expressions. This requirement precisely accounts for the nonstandard use of continuation-passing style encountered in partial evaluation. Eta-expansion thusacts as a uniform binding-time coercion between values and contexts, be they of function type, product type, or disjoint-sum type. For the latter case, it enables "The Trick".In this article, we extend Gomard and Jones's partial evaluatorfor the lambda-calculus, lambda-Mix, with products and disjoint sums; we pointout how eta-expansion for (finite) disjoint sums enables The Trick; we generalize our earlier work by identifying that eta-expansion can be obtained in the binding-time analysis simply by adding two coercion rules; and we specify and prove the correctness of our extension to lambda-Mix.Keywords: Partial evaluation, binding-time analysis, program specialization,binding-time improvement, eta-expansion, static reduction

    Lambda-Dropping: Transforming Recursive Equations into Programs with Block Structure

    Get PDF
    Lambda-lifting a functional program transforms it into a set of recursiveequations. We present the symmetric transformation: lambda-dropping.Lambda-dropping a set of recursive equations restores blockstructure and lexical scope.For lack of scope, recursive equations must carry around all theparameters that any of their callees might possibly need. Both lambda-liftingand lambda-dropping thus require one to compute a transitiveclosure over the call graph:- for lambda-lifting: to establish the Def/Use path of each freevariable (these free variables are then added as parameters toeach of the functions in the call path);- for lambda-dropping: to establish the Def/Use path of each parameter(parameters whose use occurs in the same scope as theirdefinition do not need to be passed along in the call path).Without free variables, a program is scope-insensitive. Its blocks arethen free to float (for lambda-lifting) or to sink (for lambda-dropping)along the vertices of the scope tree.We believe lambda-lifting and lambda-dropping are interesting perse, both in principle and in practice, but our prime application is partialevaluation: except for Malmkjær and Ørbæk's case study presented atPEPM'95, most polyvariant specializers for procedural programs operateon recursive equations. To this end, in a pre-processing phase,they lambda-lift source programs into recursive equations. As a result,residual programs are also expressed as recursive equations, often withdozens of parameters, which most compilers do not handle efficiently.Lambda-dropping in a post-processing phase restores their block structureand lexical scope thereby significantly reducing both the compiletime and the run time of residual programs.

    Intensional Refinement Datatypes:With Application to Scalable Verification of Pattern-Match Safety

    Get PDF

    Abstract multiple specialization and its application to program parallelization.

    Get PDF
    Program specialization optimizes programs for known valúes of the input. It is often the case that the set of possible input valúes is unknown, or this set is infinite. However, a form of specialization can still be performed in such cases by means of abstract interpretation, specialization then being with respect to abstract valúes (substitutions), rather than concrete ones. We study the múltiple specialization of logic programs based on abstract interpretation. This involves in principie, and based on information from global analysis, generating several versions of a program predicate for different uses of such predicate, optimizing these versions, and, finally, producing a new, "multiply specialized" program. While múltiple specialization has received theoretical attention, little previous evidence exists on its practicality. In this paper we report on the incorporation of múltiple specialization in a parallelizing compiler and quantify its effects. A novel approach to the design and implementation of the specialization system is proposed. The resulting implementation techniques result in identical specializations to those of the best previously proposed techniques but require little or no modification of some existing abstract interpreters. Our results show that, using the proposed techniques, the resulting "abstract múltiple specialization" is indeed a relevant technique in practice. In particular, in the parallelizing compiler application, a good number of run-time tests are eliminated and invariants extracted automatically from loops, resulting generally in lower overheads and in several cases in increased speedups

    Implementation of multiple specialization in logic programs

    Get PDF
    We study the múltiple specialization of logic programs based on abstract interpretation. This involves in general generating several versions of a program predícate for different uses of such predícate, making use of information obtained from global analysis performed by an abstract interpreter, and finally producing a new, "multiply specialized" program. While the topic of múltiple specialization of logic programs has received considerable theoretical attention, it has never been actually incorporated in a compiler and its effects quantified. We perform such a study in the context of a parallelizing compiler and show that it is indeed a relevant technique in practice. Also, we propose an implementation technique which has the same power as the strongest of the previously proposed techniques but requires little or no modification of an existing abstract interpreter

    Towards Bridging the Gap Between Programming Languages and Partial Evaluation

    Get PDF
    International audiencePartial evaluation is a program-transformation technique that automatically specializes a program with respect to user-supplied invariants. Despite successful applications in areas such as graphics, operating systems, and software engineering, partial evaluators have yet to achieve widespread use. One reason is the difficulty of adequately describing specialization opportunities. Indeed, under-specialization or over-specialization often occurs, without any direct feedback to the user as to the source of the problem. We have developed a high-level, module-based language allowing the programmer to guide the choice of both the code to specialize and the invariants to exploit during the specialization process. To ease the use of partial evaluation, the syntax of this language is similar to the declaration syntax of the target language of the partial evaluator. To provide feedback to the programmer, declarations are checked throughout the analyses performed by partial evaluation. The language has been successfully used by a signal-processing expert in the design of a specializable Forward Error Correction component

    Poly-controlled partial evaluation and its application to resource-aware program specialization

    Get PDF
    La Evaluación Parcial es una técnica automática para la optimización de programas. Su objetivo principal es el de especializar un programa con respecto a parte de sus datos de entrada, los que se conocen como datos estáticos. La calidad del código generado por la evaluación parcial de programas lógicos depende, en gran medida, de la estrategia de control que se haya empleado. Desafortunadamente, aún estamos lejos de contar con una estrategia de control suficientemente sofisticada como para comportarse de manera óptima para cualquier programa. La principal contribución de esta tesis es el desarrollo de la Evaluación Parcial Policontrolada, un novedoso entorno para la evaluación parcial de programas lógicos, el cual es policontrolado en el sentido de que puede tomar en cuenta conjuntos de reglas de control global y local, en lugar de emplear una única combinación predeterminada (como es el caso de la evaluación parcial tradicional). Este entorno es más flexible que los enfoques existentes, ya que permite asignar diferentes reglas de control local y global a diferentes patrones de llamada. De este modo, es posible obtener programas especializados que no pueden ser generados usando evaluación parcial tradicional. En consecuencia, el entorno de evaluación parcial policontrolada puede generar conjuntos de programas especializados, en lugar de un único programa. A través de técnicas auto-ajustables, es posible hacer que este enfoque sea completamente automático. Dichas técnicas permiten medir la calidad de los diferentes programas especializados obtenidos. Este entorno es consciente de los recursos, en el sentido de que cada una de las soluciones obtenidas a través de la evaluación parcial policontrolada es valorada utilizando funciones de adecuación, las que pueden tener en cuenta factores tales como el tamaño de los programas especializados, o la cantidad de memoria que consumen, además de la velocidad del programa especializado que es el factor habitualmente considerado en otros entornos de evaluación parcial. Este entorno de evaluación parcial policontrolada ha sido implementado en el sistema CiaoPP, y evaluado con numerosos programas de prueba. Los resultados experimentales muestran que nuestra propuesta obtiene en muchos casos mejores especializaciones que aquellas generadas usando la evaluación parcial tradicional, especialmente cuando la especialización es consciente de los recursos. Otra de las principales contribuciones de esta tesis es la presentación de una visión unificada del problema de eliminar la polivarianza superflua en la evaluación parcial y en la especialización abstracta múltiple, a través del uso de un paso de minimización, el cual agrupa versiones equivalentes de predicados. Este paso se puede aplicar en la especialización de cualquier programa Prolog, inclusive aquellos que contienen llamadas a predicados predefinidos o predicados externos. Además, ofrecemos la posibilidad de agrupar versiones que no sean estrictamente equivalentes, con el propósito de obtener programas más pequeños
    corecore