Ii. Under WAM
It has been imperative for decades. Functional or logical language compilers are broken down in several steps. In particular, an abstract machine is used as a high-levelSource codeAnd low-level executable targetsCodeThe intermediate layer between them. In fact, since Pascal and p-code, the abstract machine has been emphasizing as the backbone of the compilation process. The logic language is no exception here. compiling a Prolog Into a wam command is a de facto standard and well-known process. However, WAM code cannot be executed directly on mainstream computers. Therefore, some treatments are needed to make executable files. There are two classic methods to execute WAM code: a wam simulator or translator converts it into a machine code.
The simulated WAM code usually comes with the first solution. In this way, WAM commands (bytecode) are simply considered as data and will be processed by some simulators.ProgramProcessing, usually written in C or assembly language. The advantage of a simulator is its simple written form (about 3000 lines of unoptimized C code). It is portable when used in languages such as C. It can create and dynamically modify WAM code. These advantages make it a major trend among developers of the PROLOG Language. However, this method has a major drawback in the overhead cycle of simulation: Reading, decoding, and execution. Another drawback is that it is impossible to generate an autonomous executable program as the output, because the simulator already exists.
Production machine code features, roughly opposite to simulation. Writing a translator from the abstract code machine code is an arduous task and requires an in-depth understanding of the target machine. The good performance at this price, especially the code optimized in the RISC architecture, is essential. Such a compiler is a new architecture that is not easily transplanted: The machine is particularly good and may become a fatal weakness of another machine in some ways. On the other hand, the development of machine code compilers, including many classic parts, may be painful, but enough technology is well known, such as register allocation.
Since these methods do not comply with our requirements, we decided to try another method to translate from prolog to C. To compensate for the lack of optimization (for simplicity) and the lack of simulation overhead (acquisition and decoding), the C compiler will generate native code. In this way, we will combine the advantages of simulation and compilation to machine code. However, without such experience [1], we had decided to develop our system 1 as early as 1991. Even today, three years have passed, it is appropriate that we do not implement C-Compiled Prolog in addition to our own wamcc system. However, during this period, the following options are available for determining the language of ownership: Janus [7], kl1 [3], and Erlang [8]. They are all based on different compilation plans. What's interesting is that they are compared with wamcc for deterministic Prolog.
[1] AlthoughInEnd of 1980s,ExistingECRCUnsuccessfulLab.