YAP_FAIL_ERROR in case a fail has been requested, but not accepetd yet.
This commit is contained in:
parent
268a378ba0
commit
c6f41e2970
75
C/absmi.c
75
C/absmi.c
@ -2652,6 +2652,12 @@ Yap_absmi(int inp)
|
|||||||
NoStackCall:
|
NoStackCall:
|
||||||
PP = PREG->u.Osbpp.p0;
|
PP = PREG->u.Osbpp.p0;
|
||||||
/* on X86 machines S will not actually be holding the pointer to pred */
|
/* on X86 machines S will not actually be holding the pointer to pred */
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
if (ActiveSignals & YAP_CREEP_SIGNAL) {
|
if (ActiveSignals & YAP_CREEP_SIGNAL) {
|
||||||
PredEntry *ap = PREG->u.Osbpp.p;
|
PredEntry *ap = PREG->u.Osbpp.p;
|
||||||
SREG = (CELL *) ap;
|
SREG = (CELL *) ap;
|
||||||
@ -2687,6 +2693,12 @@ Yap_absmi(int inp)
|
|||||||
{
|
{
|
||||||
CELL cut_b = LCL0-(CELL *)(SREG[E_CB]);
|
CELL cut_b = LCL0-(CELL *)(SREG[E_CB]);
|
||||||
|
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
don't do a creep here; also, if our instruction is followed by
|
don't do a creep here; also, if our instruction is followed by
|
||||||
a execute_c, just wait a bit more */
|
a execute_c, just wait a bit more */
|
||||||
@ -2735,6 +2747,12 @@ Yap_absmi(int inp)
|
|||||||
if (!ActiveSignals || ActiveSignals & YAP_CDOVF_SIGNAL) {
|
if (!ActiveSignals || ActiveSignals & YAP_CDOVF_SIGNAL) {
|
||||||
goto do_commit_b_y;
|
goto do_commit_b_y;
|
||||||
}
|
}
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
FAIL();
|
||||||
|
}
|
||||||
if (!(ActiveSignals & YAP_CREEP_SIGNAL)) {
|
if (!(ActiveSignals & YAP_CREEP_SIGNAL)) {
|
||||||
SREG = (CELL *)RepPredProp(Yap_GetPredPropByFunc(FunctorRestoreRegs,0));
|
SREG = (CELL *)RepPredProp(Yap_GetPredPropByFunc(FunctorRestoreRegs,0));
|
||||||
XREGS[0] = YREG[PREG->u.yp.y];
|
XREGS[0] = YREG[PREG->u.yp.y];
|
||||||
@ -2751,6 +2769,12 @@ Yap_absmi(int inp)
|
|||||||
if (!ActiveSignals || ActiveSignals & YAP_CDOVF_SIGNAL) {
|
if (!ActiveSignals || ActiveSignals & YAP_CDOVF_SIGNAL) {
|
||||||
goto do_commit_b_x;
|
goto do_commit_b_x;
|
||||||
}
|
}
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
FAIL();
|
||||||
|
}
|
||||||
if (!(ActiveSignals & YAP_CREEP_SIGNAL)) {
|
if (!(ActiveSignals & YAP_CREEP_SIGNAL)) {
|
||||||
SREG = (CELL *)RepPredProp(Yap_GetPredPropByFunc(FunctorRestoreRegs,0));
|
SREG = (CELL *)RepPredProp(Yap_GetPredPropByFunc(FunctorRestoreRegs,0));
|
||||||
#if USE_THREADED_CODE
|
#if USE_THREADED_CODE
|
||||||
@ -2777,8 +2801,15 @@ Yap_absmi(int inp)
|
|||||||
|
|
||||||
/* Problem: have I got an environment or not? */
|
/* Problem: have I got an environment or not? */
|
||||||
NoStackFail:
|
NoStackFail:
|
||||||
|
if (ActiveSignals && ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
/* we're happy */
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
if (!ActiveSignals || ActiveSignals & YAP_CDOVF_SIGNAL) {
|
if (!ActiveSignals || ActiveSignals & (YAP_CDOVF_SIGNAL)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (!(ActiveSignals & YAP_CREEP_SIGNAL)) {
|
if (!(ActiveSignals & YAP_CREEP_SIGNAL)) {
|
||||||
@ -2793,6 +2824,12 @@ Yap_absmi(int inp)
|
|||||||
|
|
||||||
/* don't forget I cannot creep at ; */
|
/* don't forget I cannot creep at ; */
|
||||||
NoStackEither:
|
NoStackEither:
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
PP = PREG->u.Osblp.p0;
|
PP = PREG->u.Osblp.p0;
|
||||||
if (ActiveSignals & YAP_CREEP_SIGNAL) {
|
if (ActiveSignals & YAP_CREEP_SIGNAL) {
|
||||||
goto either_notest;
|
goto either_notest;
|
||||||
@ -2870,6 +2907,12 @@ Yap_absmi(int inp)
|
|||||||
goto creep;
|
goto creep;
|
||||||
|
|
||||||
NoStackDExecute:
|
NoStackDExecute:
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
PP = PREG->u.pp.p0;
|
PP = PREG->u.pp.p0;
|
||||||
if (ActiveSignals & YAP_CREEP_SIGNAL) {
|
if (ActiveSignals & YAP_CREEP_SIGNAL) {
|
||||||
PredEntry *ap = PREG->u.pp.p;
|
PredEntry *ap = PREG->u.pp.p;
|
||||||
@ -2942,6 +2985,12 @@ Yap_absmi(int inp)
|
|||||||
|
|
||||||
/* try performing garbage collection */
|
/* try performing garbage collection */
|
||||||
|
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
ASP = YREG+E_CB;
|
ASP = YREG+E_CB;
|
||||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||||
@ -2985,6 +3034,12 @@ Yap_absmi(int inp)
|
|||||||
/* and now CREEP */
|
/* and now CREEP */
|
||||||
|
|
||||||
creep:
|
creep:
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
/* I need this for Windows and other systems where SIGINT
|
/* I need this for Windows and other systems where SIGINT
|
||||||
is not proceesed by same thread as absmi */
|
is not proceesed by same thread as absmi */
|
||||||
@ -13848,6 +13903,12 @@ Yap_absmi(int inp)
|
|||||||
|
|
||||||
ENDD(d0);
|
ENDD(d0);
|
||||||
NoStackPExecute2:
|
NoStackPExecute2:
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
PP = PredMetaCall;
|
PP = PredMetaCall;
|
||||||
SREG = (CELL *) pen;
|
SREG = (CELL *) pen;
|
||||||
ASP = ENV_YREG;
|
ASP = ENV_YREG;
|
||||||
@ -14047,6 +14108,12 @@ Yap_absmi(int inp)
|
|||||||
|
|
||||||
ENDD(d0);
|
ENDD(d0);
|
||||||
NoStackPExecute:
|
NoStackPExecute:
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
PP = PredMetaCall;
|
PP = PredMetaCall;
|
||||||
SREG = (CELL *) pen;
|
SREG = (CELL *) pen;
|
||||||
ASP = ENV_YREG;
|
ASP = ENV_YREG;
|
||||||
@ -14317,6 +14384,12 @@ Yap_absmi(int inp)
|
|||||||
ENDD(d0);
|
ENDD(d0);
|
||||||
ENDP(pt0);
|
ENDP(pt0);
|
||||||
NoStackPTExecute:
|
NoStackPTExecute:
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
PP = NULL;
|
PP = NULL;
|
||||||
WRITEBACK_Y_AS_ENV();
|
WRITEBACK_Y_AS_ENV();
|
||||||
SREG = (CELL *) pen;
|
SREG = (CELL *) pen;
|
||||||
|
@ -455,6 +455,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
where = TermNil;
|
where = TermNil;
|
||||||
Yap_PrologMode &= ~AbortMode;
|
Yap_PrologMode &= ~AbortMode;
|
||||||
Yap_PrologMode |= InErrorMode;
|
Yap_PrologMode |= InErrorMode;
|
||||||
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
P = FAILCODE;
|
P = FAILCODE;
|
||||||
} else {
|
} else {
|
||||||
if (IsVarTerm(where)) {
|
if (IsVarTerm(where)) {
|
||||||
@ -1874,7 +1875,6 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
} else {
|
} else {
|
||||||
if (type == PURE_ABORT) {
|
if (type == PURE_ABORT) {
|
||||||
Yap_JumpToEnv(MkAtomTerm(AtomDAbort));
|
Yap_JumpToEnv(MkAtomTerm(AtomDAbort));
|
||||||
CreepFlag = LCL0-ASP;
|
|
||||||
} else
|
} else
|
||||||
Yap_JumpToEnv(Yap_MkApplTerm(fun, 2, nt));
|
Yap_JumpToEnv(Yap_MkApplTerm(fun, 2, nt));
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
|
8
C/exec.c
8
C/exec.c
@ -971,6 +971,8 @@ exec_absmi(int top)
|
|||||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
LOCK(SignalLock);
|
LOCK(SignalLock);
|
||||||
|
/* forget any signals active, we're reborne */
|
||||||
|
ActiveSignals = 0;
|
||||||
CreepFlag = CalculateStackGap();
|
CreepFlag = CalculateStackGap();
|
||||||
Yap_PrologMode = UserMode;
|
Yap_PrologMode = UserMode;
|
||||||
UNLOCK(SignalLock);
|
UNLOCK(SignalLock);
|
||||||
@ -1002,6 +1004,10 @@ exec_absmi(int top)
|
|||||||
Yap_CloseSlots();
|
Yap_CloseSlots();
|
||||||
out = Yap_absmi(0);
|
out = Yap_absmi(0);
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
|
/* make sure we don't leave a FAIL signal hanging around */
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
if (!ActiveSignals)
|
||||||
|
CreepFlag = CalculateStackGap();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1505,6 +1511,7 @@ JumpToEnv(Term t) {
|
|||||||
EX = BallTerm;
|
EX = BallTerm;
|
||||||
BallTerm = NULL;
|
BallTerm = NULL;
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1546,6 +1553,7 @@ JumpToEnv(Term t) {
|
|||||||
/* B->cp_h = H; */
|
/* B->cp_h = H; */
|
||||||
/* I could backtrack here, but it is easier to leave the unwinding
|
/* I could backtrack here, but it is easier to leave the unwinding
|
||||||
to the emulator */
|
to the emulator */
|
||||||
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
/* try to recover space */
|
/* try to recover space */
|
||||||
|
11
C/sysbits.c
11
C/sysbits.c
@ -2987,6 +2987,14 @@ p_first_signal(void)
|
|||||||
UNLOCK(SignalLock);
|
UNLOCK(SignalLock);
|
||||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigStatistics));
|
return Yap_unify(ARG1, MkAtomTerm(AtomSigStatistics));
|
||||||
}
|
}
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||||
|
#ifdef THREADS
|
||||||
|
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
|
||||||
|
#endif
|
||||||
|
UNLOCK(SignalLock);
|
||||||
|
return Yap_unify(ARG1, MkAtomTerm(AtomFail));
|
||||||
|
}
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
|
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
|
||||||
#endif
|
#endif
|
||||||
@ -3040,6 +3048,9 @@ p_continue_signals(void)
|
|||||||
if (ActiveSignals & YAP_STATISTICS_SIGNAL) {
|
if (ActiveSignals & YAP_STATISTICS_SIGNAL) {
|
||||||
Yap_signal(YAP_STATISTICS_SIGNAL);
|
Yap_signal(YAP_STATISTICS_SIGNAL);
|
||||||
}
|
}
|
||||||
|
if (ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||||
|
Yap_signal(YAP_FAIL_SIGNAL);
|
||||||
|
}
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
|
pthread_mutex_unlock(&(MY_ThreadHandle.tlock));
|
||||||
#endif
|
#endif
|
||||||
|
3
H/Yap.h
3
H/Yap.h
@ -620,7 +620,8 @@ typedef enum
|
|||||||
YAP_DELAY_CREEP_SIGNAL = 0x10000, /* received a creep but should not do it */
|
YAP_DELAY_CREEP_SIGNAL = 0x10000, /* received a creep but should not do it */
|
||||||
YAP_AGC_SIGNAL = 0x20000, /* call atom garbage collector asap */
|
YAP_AGC_SIGNAL = 0x20000, /* call atom garbage collector asap */
|
||||||
YAP_PIPE_SIGNAL = 0x40000, /* call atom garbage collector asap */
|
YAP_PIPE_SIGNAL = 0x40000, /* call atom garbage collector asap */
|
||||||
YAP_VTALARM_SIGNAL = 0x80000 /* received SIGVTALARM */
|
YAP_VTALARM_SIGNAL = 0x80000, /* received SIGVTALARM */
|
||||||
|
YAP_FAIL_SIGNAL = 0x100000 /* P = FAILCODE */
|
||||||
} yap_signals;
|
} yap_signals;
|
||||||
|
|
||||||
#define NUMBER_OF_YAP_FLAGS LAST_FLAG
|
#define NUMBER_OF_YAP_FLAGS LAST_FLAG
|
||||||
|
@ -89,6 +89,9 @@
|
|||||||
'$continue_signals',
|
'$continue_signals',
|
||||||
statistics,
|
statistics,
|
||||||
'$execute0'(G,M).
|
'$execute0'(G,M).
|
||||||
|
% the next one should never be called...
|
||||||
|
'$do_signal'(fail, [_|_]) :-
|
||||||
|
fail.
|
||||||
'$do_signal'(sig_stack_dump, [M|G]) :-
|
'$do_signal'(sig_stack_dump, [M|G]) :-
|
||||||
'$continue_signals',
|
'$continue_signals',
|
||||||
'$stack_dump',
|
'$stack_dump',
|
||||||
|
Reference in New Issue
Block a user