Include new instruction execute_cpred to perform tail optimisation for
builtins. Required changes: - be careful about creeping in deallocate: it may be followed by something that is not a cut nor a proceed. - include new instruction in absmi.c: it is a merge of execute and call_cpred. - change compiler to generate execute even for C builtins. - be careful with dexecute: it may not be done if execute_op is a C builtin. - if we are in execute_cpred, the garbage collector cannot trust P: instead it must look at CP to find out the size of the current environment. The macro gc_P receives that information. - We don't need to change CP if we do a meta-call from within execute_cpred (and we in fact cannot). Check places where we do meta-calls: exec, clause in cdmgr, and lu_recorded.
This commit is contained in:
@@ -1881,7 +1881,10 @@ c_goal(Term Goal, int mod, compiler_struct *cglobs)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (p->PredFlags & (CPredFlag | AsmPredFlag | ModuleTransparentPredFlag)) {
|
||||
if ((p->PredFlags & (AsmPredFlag |
|
||||
ModuleTransparentPredFlag |
|
||||
UserCPredFlag)) ||
|
||||
p->FunctorOfPred == FunctorExecuteInMod) {
|
||||
#ifdef YAPOR
|
||||
if (p->PredFlags & SyncPredFlag)
|
||||
Yap_emit(sync_op, (CELL)p, (CELL)(p->ArityOfPE), &cglobs->cint);
|
||||
@@ -3123,7 +3126,7 @@ Yap_cclause(volatile Term inp_clause, int NOfArgs, int mod, volatile Term src)
|
||||
ARG3 = src;
|
||||
|
||||
YAPLeaveCriticalSection();
|
||||
if (!Yap_gcl(Yap_Error_Size, NOfArgs, ENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, NOfArgs, ENV, gc_P(P,CP))) {
|
||||
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
|
||||
Yap_Error_Term = inp_clause;
|
||||
}
|
||||
|
Reference in New Issue
Block a user