Technical Report: DCC-98-2

Multiple Specialization through Local Analysis

Michel Ferreira and Luís Damas

Departamento de Ciência de Computadores & LIACC
Faculdade de Ciências, Universidade do Porto
Rua do Campo Alegre, 823 4150 Porto, Portugal

March 1998


Abstract

Program specialization is normally supported by global analysis of the program. Compilers use the information deduced to generate more efficient, specialized implementations of the program. This specialization can be single or multiple, depending if each procedure of the program is specialized into one or more versions. We present a Prolog compiler that does multiple specialization, using an algorithm that works over the WAM code, deducing the reachable procedure activations based on local analysis. The idea is to use the analysis that is done in the Prolog to WAM compilation, and that generates local specialized instructions, and to propagate this information through the entire program. The creation of multiple versions of predicates allows the propagation to be inter-procedural, and to achieve global program specialization. Results from an implementation generating C code as target language are presented, showing a performance comparable to native code Prolog compilers.

Keywords: Prolog Compilation, Code Specialization, Program Analysis.