Compilation of compound terms in Prolog
Micha Meier · 1990
The execution of a compiled Prolog program can spend a significant amount of time in the unification of compound terms. We show that in the Warren Abstract Machine [7], the approach to compile this unification may be unnecessarily inefficient. When we analyse what are the redundant operations that the WAM executes, we can see that the inefficiency is mainly caused by the breadth-first approach to traverse the structures during the unification. We present here a method to compile the unification of compound terms which is based on a depth-first approach and show that it is both more general and more efficient than that of the original WAM. Furthermore we present a more efficient approach to compile compound terms in the body and also describe several possible optimizations. Our method was used in the implementation of the SEPIA system [4] developed at ECRC. III 1 Introduction The execution of Prolog programs consists mainly of procedure invocation and unification. The unification its...