3.4 WAM-JIT Interface

In terms of the C call stack, the WAM emulator calls the JIT runtime system, but the latter never calls the WAM emulator. Recursive nesting can only happen in the foreign language interface, if the foreign function calls Prolog, and similarly in a predicate implemented as a C function, if the C function calls Prolog.

The WAM emulator has a general mechanism to dispatch on the predicate type. When it sees a jitex predicate, it routes the call with call site w->insn and callee w->predicate to the ABI function:

int call_native(struct worker *w);

The WAM instruction set has been extended by the special instruction NATIVE_OP, and it is legal for w->next_insn to point to it, i.e., it is a legal continuation. As for all continuations, the half word preceding it is the environment size field. The word following it points to the WAM code equivalent of the continuation, immediately followed by the native code of the continuation. When the WAM emulator sees it, it routes the call with w->insn pointing to it to the ABI function:

int proceed_native(struct worker *w);

Both ABI function return the values:

0

jitex code backtracks into wamex code.

1

jitex code proceeds to wamex code at address w->insn, in read mode if x(0) is nonvar and in write mode otherwise.

2

jitex code calls wamex code with call site w->insn and callee w->predicate.

3

jitex code proceeds to the WAM instruction PROGRESS.


Send feedback on this subject.