Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!uunet!in1.uu.net!newsflash.concordia.ca!CC.UMontreal.CA!IRO.UMontreal.CA!tarau
From: tarau@IRO.UMontreal.CA (Paul Tarau)
Subject: Re: WAM compiler into C: need for references
Message-ID: <D42C5I.L3z@IRO.UMontreal.CA>
Keywords: WAM to C translation, Prolog Compilation
Sender: Paul Tarau
Organization: Universite de Moncton, Canada
References: <3hr44v$ob9@netserver.univ-lille1.fr>
Date: Wed, 15 Feb 1995 22:36:53 GMT
Lines: 58

In article <3hr44v$ob9@netserver.univ-lille1.fr> ciortuz@lifl.fr writes:
>There was short time ago a similar demand in this group for references on a WAM compiler into C.
>Is anybody so kind to answer again?

BinProlog 3.30 compiles to C. The technique allows to fine-tune the
amount of translation to avoid code explosion. The compiler and
a Postscript copy of the following paper are available from

ftp://clement.info.umoncton.ca/pub

@inproceedings{tdb95,
  author = {Tarau, Paul and Demoen, Bart and De Bosschere, Koen},
  title = "The {P}ower of {P}artial {T}ranslation: an {E}xperiment with
           the C-ification of {B}inary {P}rolog",
  booktitle = "Proceedings of the 1995 ACM Symposium on Applied
               Computing",
  publisher = "ACM Press",
  address = "Nashville/TN",
  month = feb,
  year = 1995
}


ABSTRACT

We describe a new language translation framework ({\em partial translation}) and the implementation of one of its instances:  the {\em C-ification} of Binary Prolog.

Partial C-ification is a translation framework which compiles sequences
of emulator instructions down to native code (on top of a C compiler).
In the case of logic programming languages, their complex control
structure,  some large instructions, and the management of the symbol
table are left to the emulator while the native code chunks will deal
with relatively long sequences of  simple instructions.

The technique can be seen as an automatic {\em specialization} with
respect to a given program of the traditional {\em instruction folding
techniques} used to speed-up emulators.

When the target language of the host compiler is the same as the
implementation language of the emulator (say C), the emulator, the
representation  of the byte code as a C data structure, some other
C-ified library routines and hand-written C-code can all be compiled
and linked together to a form a  stand-alone application.

We give full details and performance analysis of the C-ification of a
continuation passing Binary Prolog engine for which large write-mode
sequences and the absence of a call-return mechanism make the framework
particularly well suited.

The framework is shown as  practical and easy to implement and it
compares favorably with instruction folding techniques used
traditionally to speedup emulators.

{\em Keywords:  Programming language translation techniques,
Compilation of binary Prolog, WAM, BinWAM, Prolog to C translation}


Paul Tarau
