Structure Sharing (SS) and Structure Copying (SC) are two commonly used term representation methods in various Prolog systems. SS was used in earlier Prolog implementations while SC has been accepted as the de facto standard in modern Prolog implementations. Most abstract machines dedicated to Prolog, such as the Warren Abstract Machine(WAM) and the Vienna Abstract Machine(VAM), adopt SC as the fundamental component to implement efficient unification. However, practical comparison of SS and SC shown that programs can be written which make any one method almost arbitrarily worse than the other. In this paper, I propose a new Prolog implementation approach — Program Sharing (PS). The major contribution of this work is that PS has the advantages of both SC (representing terms of different types to fit in the size of a machine word) and SS (low overhead in constructing a dynamic structure instance), and the concept of program sharing could be used to realize all special-case instruction-driven unification. This method has been adopted in the design of a new Prolog abstract machine — the LAM1/2. I have implemented an experimental LAM1/2-emulator in C. Benchmarks show that this new approach is at least as efficient as the WAM-based systems in general while exhibits much better performance to those tasks involving large, complex data structures.
[1]
Philippe Codognet,et al.
WAMCC: Compiling Prolog to C
,
1995,
ICLP.
[2]
Ulrich Neumerkel,et al.
The Vienna Abstract Machine
,
1990,
PLILP.
[3]
Maurice Bruynooghe,et al.
The memory management of PROLOG implementations
,
1980
.
[4]
Péter Szeredi,et al.
MProlog: an Implementation Overview
,
1993,
ICLP-Workshops on Implementation of Logic Programming Systems.
[5]
Hassan Aït-Kaci,et al.
Warren's Abstract Machine: A Tutorial Reconstruction
,
1991
.
[6]
Peter Van Roy,et al.
High-performance logic programming with the Aquarius Prolog compiler
,
1992,
Computer.
[7]
Howard Jay Siegel,et al.
Mapping computer-vision-related tasks onto reconfigurable parallel-processing systems
,
1992,
Computer.
[8]
Giancarlo Succi,et al.
Implementations of Logic Programming Systems
,
2012,
Springer US.
[9]
David H. D. Warren.
Logic programming and compiler writing
,
1980,
Softw. Pract. Exp..