Citation
Morales Caballero, José Francisco and Carro Liñares, Manuel and Hermenegildo, Manuel V.
(2004).
Improving the compilation of Prolog to C using moded types and determinism information.
Monografía (Technical Report).
Facultad de Informática (UPM), Madrid, España.
Abstract
Este trabajo describe el estado actual y ofrece resultados de rendimiento de un compilador de Prolog a C. La novedad de esta aproximación radica en un diseño flexible que acepta diferentes tipos de
información de alto nivel, expresada en un lenguaje estándar de aserciones y obtenida típicamente
por medio de análisis automático del programa Prolog inicial, para optimizar el código C resultante, que es procesado por un compilador C genérico para generar código nativo directamente
ejecutable. El proceso de traducción básico esencialmente mimetiza la expansión (unfolding) de un
emulador de bytecode codificado en C con respecto al código correspondiente al programa Prolog.
Se aplican optimizaciones al programa expandido. Esto es facilitado por un diseno˜ flexible de las
instrucciones de bytecode y sus componentes de bajo nivel. Esta aproximación permite reusar una
cantidad considerable de maquinaria del emulador: código C, representación de datos, rutinas de
manejo de memoria y áreas, etc., así como combinar código emulado con código nativo de una
forma relativamente directa. Presentamos el rendimiento de programas compilados con la versión
actual del sistema, tanto usando como no usando información de análisis.---ABSTRACT---We describe the current status of and provide performance results for a prototype compiler of
Prolog to C. The compiler is novel in that it is designed to accept different kinds of high-level
information, typically obtained via an automatic analysis of the initial Prolog program and expressed in a standardized language of assertions, and use this information to optimize the resulting
C code, which is then further processed by an off-the-shelf C compiler. The basic translation process used essentially mimics an unfolding of a C-coded bytecode emulator with respect to the
particular bytecode corresponding to the Prolog program. Optimizations are then applied to this
unfolded program. This is facilitated by a more flexible design of the bytecode instructions and
their lower-level components. This approach allows reusing a sizable amount of the machinery of
the bytecode emulator: ancillary pieces of C code, data definitions, memory management routines
and areas, etc., as well as mixing bytecode emulated code with natively compiled code in a relatively straightforward way. We report on the performance of programs compiled by the current
version of the system, both with and without analysis information.