fix interrupt handling, especially for ! and ;
avoid using S.
This commit is contained in:
parent
279a057d80
commit
a719c19d03
245
C/absmi.c
245
C/absmi.c
@ -525,14 +525,23 @@ push_live_regs(yamop *pco)
|
|||||||
CELL *lab = (CELL *)(pco->u.l.l);
|
CELL *lab = (CELL *)(pco->u.l.l);
|
||||||
CELL max = lab[0];
|
CELL max = lab[0];
|
||||||
CELL curr = lab[1];
|
CELL curr = lab[1];
|
||||||
|
Term tp = MkIntegerTerm((Int)pco);
|
||||||
|
Term tcp = MkIntegerTerm((Int)CP);
|
||||||
|
Term tenv = MkIntegerTerm((Int)(LCL0-ENV));
|
||||||
|
Term tyenv = MkIntegerTerm((Int)(LCL0-YENV));
|
||||||
CELL *start = HR;
|
CELL *start = HR;
|
||||||
Int tot = 0;
|
Int tot = 0;
|
||||||
|
|
||||||
if (max) {
|
HR++;
|
||||||
|
*HR++ = tp;
|
||||||
|
*HR++ = tcp;
|
||||||
|
*HR++ = tenv;
|
||||||
|
*HR++ = tyenv;
|
||||||
|
tot += 4;
|
||||||
|
{
|
||||||
CELL i;
|
CELL i;
|
||||||
|
|
||||||
lab += 2;
|
lab += 2;
|
||||||
HR++;
|
|
||||||
for (i=0; i <= max; i++) {
|
for (i=0; i <= max; i++) {
|
||||||
if (i == 8*CellSize) {
|
if (i == 8*CellSize) {
|
||||||
curr = lab[0];
|
curr = lab[0];
|
||||||
@ -570,8 +579,6 @@ push_live_regs(yamop *pco)
|
|||||||
}
|
}
|
||||||
start[0] = (CELL)Yap_MkFunctor(AtomTrue, tot);
|
start[0] = (CELL)Yap_MkFunctor(AtomTrue, tot);
|
||||||
return(AbsAppl(start));
|
return(AbsAppl(start));
|
||||||
} else {
|
|
||||||
return(TermNil);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -615,11 +622,12 @@ check_alarm_fail_int(int CONT USES_REGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stack_overflow( CELL *env, yamop *cp USES_REGS )
|
stack_overflow( PredEntry *pe, CELL *env, yamop *cp USES_REGS )
|
||||||
{
|
{
|
||||||
if ((Int)(Unsigned(YREG) - Unsigned(HR)) < StackGap( PASS_REGS1 ) ||
|
if ((Int)(Unsigned(YREG) - Unsigned(HR)) < StackGap( PASS_REGS1 ) ||
|
||||||
Yap_undo_signal( YAP_STOVF_SIGNAL )) {
|
Yap_undo_signal( YAP_STOVF_SIGNAL )) {
|
||||||
if (!Yap_locked_gc(((PredEntry *)(S))->ArityOfPE, env, cp)) {
|
S = (CELL *)pe;
|
||||||
|
if (!Yap_locked_gc(pe->ArityOfPE, env, cp)) {
|
||||||
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
|
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -632,7 +640,7 @@ static int
|
|||||||
code_overflow( CELL *yenv USES_REGS )
|
code_overflow( CELL *yenv USES_REGS )
|
||||||
{
|
{
|
||||||
if (Yap_undo_signal( YAP_CDOVF_SIGNAL )) {
|
if (Yap_undo_signal( YAP_CDOVF_SIGNAL )) {
|
||||||
CELL cut_b = LCL0-(CELL *)(S[E_CB]);
|
CELL cut_b = LCL0-(CELL *)(yenv[E_CB]);
|
||||||
|
|
||||||
/* do a garbage collection first to check if we can recover memory */
|
/* do a garbage collection first to check if we can recover memory */
|
||||||
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
|
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
|
||||||
@ -640,8 +648,8 @@ code_overflow( CELL *yenv USES_REGS )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
CACHE_A1();
|
CACHE_A1();
|
||||||
if (S == ASP) {
|
if (yenv == ASP) {
|
||||||
S[E_CB] = (CELL)(LCL0-cut_b);
|
yenv[E_CB] = (CELL)(LCL0-cut_b);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -649,9 +657,8 @@ code_overflow( CELL *yenv USES_REGS )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
interrupt_handler( USES_REGS1 )
|
interrupt_handler( PredEntry *pe USES_REGS )
|
||||||
{
|
{
|
||||||
PredEntry *pe = (PredEntry *)S;
|
|
||||||
|
|
||||||
// printf("D %lx %p\n", LOCAL_ActiveSignals, P);
|
// printf("D %lx %p\n", LOCAL_ActiveSignals, P);
|
||||||
/* tell whether we can creep or not, this is hard because we will
|
/* tell whether we can creep or not, this is hard because we will
|
||||||
@ -727,8 +734,103 @@ interrupt_handler( USES_REGS1 )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// interrupt handling code that sets up the case when we do not have
|
||||||
|
// a guaranteed environment.
|
||||||
static int
|
static int
|
||||||
interrupt_handlerc( USES_REGS1 )
|
safe_interrupt_handler( PredEntry *pe USES_REGS )
|
||||||
|
{
|
||||||
|
CELL *npt = HR;
|
||||||
|
|
||||||
|
// printf("D %lx %p\n", LOCAL_ActiveSignals, P);
|
||||||
|
/* tell whether we can creep or not, this is hard because we will
|
||||||
|
lose the info RSN
|
||||||
|
*/
|
||||||
|
BEGD(d0);
|
||||||
|
S = (CELL *)pe;
|
||||||
|
d0 = pe->ArityOfPE;
|
||||||
|
if (d0 == 0) {
|
||||||
|
HR[1] = MkAtomTerm((Atom) pe->FunctorOfPred);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HR[d0 + 2] = AbsAppl(HR);
|
||||||
|
HR += d0+1+2;
|
||||||
|
*npt++ = (CELL) pe->FunctorOfPred;
|
||||||
|
BEGP(pt1);
|
||||||
|
pt1 = XREGS + 1;
|
||||||
|
for (; d0 > 0; --d0) {
|
||||||
|
BEGD(d1);
|
||||||
|
d1 = *pt1;
|
||||||
|
loop:
|
||||||
|
if (!IsVarTerm(d1)) {
|
||||||
|
/* just copy it to the heap */
|
||||||
|
pt1++;
|
||||||
|
*npt++ = d1;
|
||||||
|
} else {
|
||||||
|
if (VarOfTerm(d1) < H0 || VarOfTerm(d1) > HR) {
|
||||||
|
d1 = Deref(d1);
|
||||||
|
if (VarOfTerm(d1) < H0 || VarOfTerm(d1) > HR) {
|
||||||
|
Term v = MkVarTerm();
|
||||||
|
Bind( VarOfTerm(d1),v );
|
||||||
|
} else {
|
||||||
|
goto loop;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*npt++ = d1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ENDD(d1);
|
||||||
|
}
|
||||||
|
ENDP(pt1);
|
||||||
|
}
|
||||||
|
ENDD(d0);
|
||||||
|
npt[0] = Yap_Module_Name(pe);
|
||||||
|
ARG1 = AbsPair(npt);
|
||||||
|
|
||||||
|
HR += 2;
|
||||||
|
#ifdef COROUTINING
|
||||||
|
if (Yap_undo_signal( YAP_WAKEUP_SIGNAL )) {
|
||||||
|
CalculateStackGap( PASS_REGS1 );
|
||||||
|
ARG2 = Yap_ListOfWokenGoals();
|
||||||
|
pe = WakeUpCode;
|
||||||
|
/* no more goals to wake up */
|
||||||
|
Yap_UpdateTimedVar(LOCAL_WokenGoals,TermNil);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CalculateStackGap( PASS_REGS1 );
|
||||||
|
pe = CreepCode;
|
||||||
|
}
|
||||||
|
UNLOCK(LOCAL_SignalLock);
|
||||||
|
// allocate an fill out an environment
|
||||||
|
YENV = ASP;
|
||||||
|
CACHE_Y_AS_ENV(YREG);
|
||||||
|
ENV_YREG[E_CP] = (CELL) CP;
|
||||||
|
ENV_YREG[E_E] = (CELL) ENV;
|
||||||
|
#ifdef DEPTH_LIMIT
|
||||||
|
ENV_YREG[E_DEPTH] = DEPTH;
|
||||||
|
#endif /* DEPTH_LIMIT */
|
||||||
|
ENV = ENV_YREG;
|
||||||
|
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CP));
|
||||||
|
WRITEBACK_Y_AS_ENV();
|
||||||
|
ENDCACHE_Y_AS_ENV();
|
||||||
|
CP = P;
|
||||||
|
P = pe->CodeOfPred;
|
||||||
|
#ifdef DEPTH_LIMIT
|
||||||
|
if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is primitives */
|
||||||
|
if (pe->ModuleOfPred) {
|
||||||
|
if (DEPTH == MkIntTerm(0))
|
||||||
|
return FALSE;
|
||||||
|
else DEPTH = RESET_DEPTH();
|
||||||
|
}
|
||||||
|
} else if (pe->ModuleOfPred) {
|
||||||
|
DEPTH -= MkIntConstant(2);
|
||||||
|
}
|
||||||
|
#endif /* DEPTH_LIMIT */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
interrupt_handlerc( PredEntry *pe USES_REGS )
|
||||||
{
|
{
|
||||||
/* do creep in call */
|
/* do creep in call */
|
||||||
ENV = YENV;
|
ENV = YENV;
|
||||||
@ -753,18 +855,20 @@ interrupt_handlerc( USES_REGS1 )
|
|||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
/* setup GB */
|
/* setup GB */
|
||||||
YENV[E_CB] = (CELL) B;
|
YENV[E_CB] = (CELL) B;
|
||||||
return interrupt_handler( PASS_REGS1 );
|
return interrupt_handler( pe PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
interrupt_handler_either( USES_REGS1 )
|
interrupt_handler_either( Term t_cut, PredEntry *pe USES_REGS )
|
||||||
{
|
{
|
||||||
ENV = YENV;
|
int rc;
|
||||||
CP = NEXTOP(P, Osbpp);
|
|
||||||
YENV = (CELL *) (((char *) YENV) + P->u.Osbpp.s);
|
ARG1 = push_live_regs(NEXTOP(P, Osbpp));
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
{
|
{
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||||
|
// protect registers before we mess about.
|
||||||
|
// recompute YENV and get ASP
|
||||||
#ifdef YAPOR_SBA
|
#ifdef YAPOR_SBA
|
||||||
if (YENV > (CELL *) top_b || YENV < HR) YENV = (CELL *) top_b;
|
if (YENV > (CELL *) top_b || YENV < HR) YENV = (CELL *) top_b;
|
||||||
#else
|
#else
|
||||||
@ -776,17 +880,18 @@ interrupt_handler_either( USES_REGS1 )
|
|||||||
if (YENV > (CELL *) B)
|
if (YENV > (CELL *) B)
|
||||||
YENV = (CELL *) B;
|
YENV = (CELL *) B;
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
/* setup GB */
|
P = NEXTOP(P, Osbpp);
|
||||||
ARG1 = push_live_regs(CP);
|
// should we cut? If t_cut == INT(0) no
|
||||||
/* ARG0 has an extra argument for suspended cuts */
|
ARG2 = t_cut;
|
||||||
ARG2 = XREGS[0];
|
// ASP
|
||||||
YENV[E_CB] = (CELL) B;
|
|
||||||
SET_ASP(YENV, E_CB*sizeof(CELL));
|
SET_ASP(YENV, E_CB*sizeof(CELL));
|
||||||
return interrupt_handler( PASS_REGS1 );
|
// do the work.
|
||||||
|
rc = safe_interrupt_handler( pe PASS_REGS );
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* totrace interrupt calls */
|
/* to trace interrupt calls */
|
||||||
//#define DEBUG_INTERRUPTS 1
|
// #define DEBUG_INTERRUPTS 1
|
||||||
|
|
||||||
#ifdef DEBUG_INTERRUPTS
|
#ifdef DEBUG_INTERRUPTS
|
||||||
static int trace_interrupts = TRUE;
|
static int trace_interrupts = TRUE;
|
||||||
@ -810,11 +915,10 @@ interrupt_fail( USES_REGS1 )
|
|||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
S = (CELL *)RepPredProp(Yap_GetPredPropByAtom(AtomFail,0));
|
|
||||||
/* make sure we have the correct environment for continuation */
|
/* make sure we have the correct environment for continuation */
|
||||||
ENV = B->cp_env;
|
ENV = B->cp_env;
|
||||||
YENV = (CELL *)B;
|
YENV = (CELL *)B;
|
||||||
return interrupt_handler( PASS_REGS1 );
|
return interrupt_handler( RepPredProp(Yap_GetPredPropByAtom(AtomFail,0)) PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -836,17 +940,16 @@ interrupt_execute( USES_REGS1 )
|
|||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
S = (CELL *) P->u.pp.p;
|
|
||||||
SET_ASP(YENV, E_CB*sizeof(CELL));
|
SET_ASP(YENV, E_CB*sizeof(CELL));
|
||||||
if ((v = code_overflow(YENV PASS_REGS)) >= 0) {
|
if ((v = code_overflow(YENV PASS_REGS)) >= 0) {
|
||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if ((v = stack_overflow(ENV, CP PASS_REGS )) >= 0) {
|
if ((v = stack_overflow(P->u.pp.p, ENV, CP PASS_REGS )) >= 0) {
|
||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
return interrupt_handler( PASS_REGS1 );
|
return interrupt_handler( P->u.pp.p PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -869,17 +972,16 @@ interrupt_call( USES_REGS1 )
|
|||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
S = (CELL *) P->u.Osbpp.p;
|
|
||||||
SET_ASP(YENV, P->u.Osbpp.s);
|
SET_ASP(YENV, P->u.Osbpp.s);
|
||||||
if ((v = code_overflow(YENV PASS_REGS)) >= 0) {
|
if ((v = code_overflow(YENV PASS_REGS)) >= 0) {
|
||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if ((v = stack_overflow(YENV, NEXTOP(P, Osbpp) PASS_REGS )) >= 0) {
|
if ((v = stack_overflow( P->u.Osbpp.p, YENV, NEXTOP(P, Osbpp) PASS_REGS )) >= 0) {
|
||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
return interrupt_handlerc( PASS_REGS1 );
|
return interrupt_handlerc( P->u.Osbpp.p PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -901,7 +1003,6 @@ interrupt_pexecute( PredEntry *pen USES_REGS )
|
|||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return 2; /* keep on creeping */
|
return 2; /* keep on creeping */
|
||||||
}
|
}
|
||||||
S = (CELL *) pen;
|
|
||||||
SET_ASP(YENV, E_CB*sizeof(CELL));
|
SET_ASP(YENV, E_CB*sizeof(CELL));
|
||||||
/* setup GB */
|
/* setup GB */
|
||||||
YENV[E_CB] = (CELL) B;
|
YENV[E_CB] = (CELL) B;
|
||||||
@ -909,12 +1010,12 @@ interrupt_pexecute( PredEntry *pen USES_REGS )
|
|||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if ((v = stack_overflow(ENV, NEXTOP(P, Osbmp) PASS_REGS )) >= 0) {
|
if ((v = stack_overflow( pen, ENV, NEXTOP(P, Osbmp) PASS_REGS )) >= 0) {
|
||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
CP = NEXTOP(P, Osbmp);
|
CP = NEXTOP(P, Osbmp);
|
||||||
return interrupt_handler( PASS_REGS1 );
|
return interrupt_handler( pen PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't forget I cannot creep at deallocate (where to?) */
|
/* don't forget I cannot creep at deallocate (where to?) */
|
||||||
@ -956,14 +1057,16 @@ interrupt_deallocate( USES_REGS1 )
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if (Yap_has_a_signal()) {
|
if (Yap_has_a_signal()) {
|
||||||
|
PredEntry *pe;
|
||||||
|
|
||||||
if (Yap_op_from_opcode(P->opc) == _cut_e) {
|
if (Yap_op_from_opcode(P->opc) == _cut_e) {
|
||||||
/* followed by a cut */
|
/* followed by a cut */
|
||||||
ARG1 = MkIntegerTerm(LCL0-(CELL *)S[E_CB]);
|
ARG1 = MkIntegerTerm(LCL0-(CELL *)S[E_CB]);
|
||||||
S = (CELL *)RepPredProp(Yap_GetPredPropByFunc(FunctorCutBy,1));
|
pe = RepPredProp(Yap_GetPredPropByFunc(FunctorCutBy,1));
|
||||||
} else {
|
} else {
|
||||||
S = (CELL *)RepPredProp(Yap_GetPredPropByAtom(AtomTrue,0));
|
pe = RepPredProp(Yap_GetPredPropByAtom(AtomTrue,0));
|
||||||
}
|
}
|
||||||
return interrupt_handler( PASS_REGS1 );
|
return interrupt_handler( pe PASS_REGS );
|
||||||
}
|
}
|
||||||
if (!Yap_locked_gc(0, ENV, CP)) {
|
if (!Yap_locked_gc(0, ENV, CP)) {
|
||||||
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
|
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
|
||||||
@ -978,6 +1081,7 @@ interrupt_deallocate( USES_REGS1 )
|
|||||||
static int
|
static int
|
||||||
interrupt_cut( USES_REGS1 )
|
interrupt_cut( USES_REGS1 )
|
||||||
{
|
{
|
||||||
|
Term t_cut = MkIntegerTerm(LCL0-(CELL *)YENV[E_CB]);
|
||||||
int v;
|
int v;
|
||||||
#ifdef DEBUG_INTERRUPTS
|
#ifdef DEBUG_INTERRUPTS
|
||||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||||
@ -993,15 +1097,14 @@ interrupt_cut( USES_REGS1 )
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
S = (CELL *)PredRestoreRegs;
|
|
||||||
XREGS[0] = MkIntegerTerm(LCL0-(CELL *)YENV[E_CB]);
|
|
||||||
P = NEXTOP(P,s);
|
P = NEXTOP(P,s);
|
||||||
return interrupt_handler_either( PASS_REGS1 );
|
return interrupt_handler_either( t_cut, PredRestoreRegs PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
interrupt_cut_t( USES_REGS1 )
|
interrupt_cut_t( USES_REGS1 )
|
||||||
{
|
{
|
||||||
|
Term t_cut = MkIntegerTerm(LCL0-(CELL *)YENV[E_CB]);
|
||||||
int v;
|
int v;
|
||||||
#ifdef DEBUG_INTERRUPTS
|
#ifdef DEBUG_INTERRUPTS
|
||||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||||
@ -1018,17 +1121,41 @@ interrupt_cut_t( USES_REGS1 )
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
XREGS[0] = MkIntegerTerm(LCL0-(CELL *)S[E_CB]);
|
|
||||||
S = (CELL *)PredRestoreRegs;
|
|
||||||
P = NEXTOP(P,s);
|
P = NEXTOP(P,s);
|
||||||
return interrupt_handler_either( PASS_REGS1 );
|
return interrupt_handler_either( t_cut, PredRestoreRegs PASS_REGS );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
interrupt_cut_e( USES_REGS1 )
|
||||||
|
{
|
||||||
|
Term t_cut = MkIntegerTerm(LCL0-(CELL *)S[E_CB]);
|
||||||
|
int v;
|
||||||
|
#ifdef DEBUG_INTERRUPTS
|
||||||
|
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||||
|
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||||
|
#endif
|
||||||
|
LOCK(LOCAL_SignalLock);
|
||||||
|
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0) {
|
||||||
|
UNLOCK(LOCAL_SignalLock);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
if (!Yap_has_a_signal()
|
||||||
|
|| Yap_only_has_signals(YAP_CDOVF_SIGNAL , YAP_CREEP_SIGNAL )) {
|
||||||
|
UNLOCK(LOCAL_SignalLock);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
/* find something to fool S */
|
||||||
|
P = NEXTOP(P,s);
|
||||||
|
return interrupt_handler_either( t_cut, PredRestoreRegs PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
interrupt_commit_y( USES_REGS1 )
|
interrupt_commit_y( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
#ifdef DEBUG_INTERRUPTS
|
Term t_cut = YENV[P->u.yps.y];
|
||||||
|
|
||||||
|
#ifdef DEBUG_INTERRUPTS
|
||||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||||
#endif
|
#endif
|
||||||
@ -1043,17 +1170,17 @@ interrupt_commit_y( USES_REGS1 )
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
S = (CELL *)PredRestoreRegs;
|
|
||||||
XREGS[0] = YENV[P->u.yps.y];
|
|
||||||
P = NEXTOP(P,yps);
|
P = NEXTOP(P,yps);
|
||||||
return interrupt_handler_either( PASS_REGS1 );
|
return interrupt_handler_either( t_cut, PredRestoreRegs PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
interrupt_commit_x( USES_REGS1 )
|
interrupt_commit_x( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
#ifdef DEBUG_INTERRUPTS
|
Term t_cut = XREG(P->u.xps.x);
|
||||||
|
|
||||||
|
#ifdef DEBUG_INTERRUPTS
|
||||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||||
#endif
|
#endif
|
||||||
@ -1069,7 +1196,6 @@ interrupt_commit_x( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
PP = P->u.xps.p0;
|
PP = P->u.xps.p0;
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
S = (CELL *)PredRestoreRegs;
|
|
||||||
if (P->opc == Yap_opcode(_fcall)) {
|
if (P->opc == Yap_opcode(_fcall)) {
|
||||||
/* fill it up */
|
/* fill it up */
|
||||||
CACHE_Y_AS_ENV(YREG);
|
CACHE_Y_AS_ENV(YREG);
|
||||||
@ -1080,9 +1206,8 @@ interrupt_commit_x( USES_REGS1 )
|
|||||||
#endif /* DEPTH_LIMIT */
|
#endif /* DEPTH_LIMIT */
|
||||||
ENDCACHE_Y_AS_ENV();
|
ENDCACHE_Y_AS_ENV();
|
||||||
}
|
}
|
||||||
XREGS[0] = XREG(P->u.xps.x);
|
|
||||||
P = NEXTOP(P,xps);
|
P = NEXTOP(P,xps);
|
||||||
return interrupt_handler_either( PASS_REGS1 );
|
return interrupt_handler_either( t_cut, PredRestoreRegs PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1105,7 +1230,6 @@ interrupt_either( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
PP = P->u.Osblp.p0;
|
PP = P->u.Osblp.p0;
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
S = (CELL *)RepPredProp(Yap_GetPredPropByFunc(FunctorRestoreRegs1,0));
|
|
||||||
SET_ASP(YENV, P->u.Osbpp.s);
|
SET_ASP(YENV, P->u.Osbpp.s);
|
||||||
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);
|
||||||
@ -1113,23 +1237,25 @@ interrupt_either( USES_REGS1 )
|
|||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if ((v = stack_overflow(YENV, NEXTOP(P, Osbpp) PASS_REGS )) >= 0) {
|
if ((v = stack_overflow(RepPredProp(Yap_GetPredPropByFunc(FunctorRestoreRegs1,0)), YENV, NEXTOP(P, Osbpp) PASS_REGS )) >= 0) {
|
||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
return interrupt_handler_either( PASS_REGS1 );
|
return interrupt_handler_either( MkIntTerm(0), RepPredProp(Yap_GetPredPropByFunc(FunctorRestoreRegs1,0)) PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
interrupt_dexecute( USES_REGS1 )
|
interrupt_dexecute( USES_REGS1 )
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
|
PredEntry *pe;
|
||||||
|
|
||||||
#ifdef DEBUG_INTERRUPTS
|
#ifdef DEBUG_INTERRUPTS
|
||||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s/%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s/%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||||
#endif
|
#endif
|
||||||
PP = P->u.pp.p0;
|
PP = P->u.pp.p0;
|
||||||
|
pe = P->u.pp.p;
|
||||||
LOCK(LOCAL_SignalLock);
|
LOCK(LOCAL_SignalLock);
|
||||||
if (Yap_has_signal(YAP_CREEP_SIGNAL) &&
|
if (Yap_has_signal(YAP_CREEP_SIGNAL) &&
|
||||||
(PP->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag))) {
|
(PP->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag))) {
|
||||||
@ -1137,7 +1263,6 @@ interrupt_dexecute( USES_REGS1 )
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
/* set S for next instructions */
|
/* set S for next instructions */
|
||||||
S = (CELL *) P->u.pp.p;
|
|
||||||
ASP = YENV+E_CB;
|
ASP = YENV+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);
|
||||||
@ -1145,7 +1270,7 @@ interrupt_dexecute( USES_REGS1 )
|
|||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if ((v = stack_overflow((CELL *)YENV[E_E], (yamop *)YENV[E_CP] PASS_REGS )) >= 0) {
|
if ((v = stack_overflow( P->u.pp.p, (CELL *)YENV[E_E], (yamop *)YENV[E_CP] PASS_REGS )) >= 0) {
|
||||||
UNLOCK(LOCAL_SignalLock);
|
UNLOCK(LOCAL_SignalLock);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -1177,7 +1302,7 @@ interrupt_dexecute( USES_REGS1 )
|
|||||||
YENV[E_CB] = (CELL) B;
|
YENV[E_CB] = (CELL) B;
|
||||||
|
|
||||||
/* and now CREEP */
|
/* and now CREEP */
|
||||||
return interrupt_handler( PASS_REGS1 );
|
return interrupt_handler( pe PASS_REGS );
|
||||||
}
|
}
|
||||||
|
|
||||||
Int
|
Int
|
||||||
@ -3223,7 +3348,7 @@ Yap_absmi(int inp)
|
|||||||
|
|
||||||
#ifdef COROUTINING
|
#ifdef COROUTINING
|
||||||
NoStackCutE:
|
NoStackCutE:
|
||||||
PROCESS_INT(interrupt_cut_t, do_cut_e);
|
PROCESS_INT(interrupt_cut_e, do_cut_e);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ENDOp();
|
ENDOp();
|
||||||
|
52
C/exec.c
52
C/exec.c
@ -30,7 +30,6 @@ static Int EnterCreepMode(Term, Term CACHE_TYPE);
|
|||||||
static Int p_save_cp( USES_REGS1 );
|
static Int p_save_cp( USES_REGS1 );
|
||||||
static Int p_execute( USES_REGS1 );
|
static Int p_execute( USES_REGS1 );
|
||||||
static Int p_execute0( USES_REGS1 );
|
static Int p_execute0( USES_REGS1 );
|
||||||
static int execute_pred(PredEntry *ppe, CELL *pt USES_REGS);
|
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
cp_as_integer(choiceptr cp USES_REGS)
|
cp_as_integer(choiceptr cp USES_REGS)
|
||||||
@ -676,7 +675,7 @@ p_do_goal_expansion( USES_REGS1 )
|
|||||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod) ) ) &&
|
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod) ) ) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
execute_pred(pe, NULL PASS_REGS) ) {
|
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||||
out = TRUE;
|
out = TRUE;
|
||||||
ARG3 = ARG2;
|
ARG3 = ARG2;
|
||||||
goto complete;
|
goto complete;
|
||||||
@ -685,7 +684,7 @@ p_do_goal_expansion( USES_REGS1 )
|
|||||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE ) ) ) &&
|
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE ) ) ) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
execute_pred(pe, NULL PASS_REGS) ) {
|
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||||
out = TRUE;
|
out = TRUE;
|
||||||
ARG3 = ARG2;
|
ARG3 = ARG2;
|
||||||
goto complete;
|
goto complete;
|
||||||
@ -696,7 +695,7 @@ p_do_goal_expansion( USES_REGS1 )
|
|||||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE ) ) ) &&
|
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE ) ) ) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
execute_pred(pe, NULL PASS_REGS) ) {
|
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||||
out = TRUE;
|
out = TRUE;
|
||||||
goto complete;
|
goto complete;
|
||||||
}
|
}
|
||||||
@ -706,7 +705,7 @@ p_do_goal_expansion( USES_REGS1 )
|
|||||||
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE ) ) ) &&
|
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE ) ) ) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
execute_pred(pe, NULL PASS_REGS) ) {
|
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||||
ARG3 = ARG2;
|
ARG3 = ARG2;
|
||||||
out = TRUE;
|
out = TRUE;
|
||||||
}
|
}
|
||||||
@ -738,7 +737,7 @@ p_do_term_expansion( USES_REGS1 )
|
|||||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, cmod) ) ) &&
|
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, cmod) ) ) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
execute_pred(pe, NULL PASS_REGS) ) {
|
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||||
out = TRUE;
|
out = TRUE;
|
||||||
goto complete;
|
goto complete;
|
||||||
}
|
}
|
||||||
@ -746,7 +745,7 @@ p_do_term_expansion( USES_REGS1 )
|
|||||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE ) ) ) &&
|
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE ) ) ) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
execute_pred(pe, NULL PASS_REGS) ) {
|
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||||
out = TRUE;
|
out = TRUE;
|
||||||
goto complete;
|
goto complete;
|
||||||
}
|
}
|
||||||
@ -755,7 +754,7 @@ p_do_term_expansion( USES_REGS1 )
|
|||||||
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, USER_MODULE ) ) ) &&
|
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, USER_MODULE ) ) ) &&
|
||||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
execute_pred(pe, NULL PASS_REGS) ) {
|
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||||
out = TRUE;
|
out = TRUE;
|
||||||
}
|
}
|
||||||
complete:
|
complete:
|
||||||
@ -1215,8 +1214,8 @@ Yap_exec_absmi(int top)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
int
|
||||||
execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
|
Yap_execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
|
||||||
{
|
{
|
||||||
yamop *saved_p, *saved_cp;
|
yamop *saved_p, *saved_cp;
|
||||||
yamop *CodeAdr;
|
yamop *CodeAdr;
|
||||||
@ -1226,15 +1225,9 @@ execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
|
|||||||
saved_cp = CP;
|
saved_cp = CP;
|
||||||
|
|
||||||
PELOCK(81,ppe);
|
PELOCK(81,ppe);
|
||||||
if (ppe->ArityOfPE == 0) {
|
|
||||||
CodeAdr = ppe->CodeOfPred;
|
|
||||||
UNLOCK(ppe->PELock);
|
|
||||||
out = do_goal(CodeAdr, 0, pt, FALSE PASS_REGS);
|
|
||||||
} else {
|
|
||||||
CodeAdr = ppe->CodeOfPred;
|
CodeAdr = ppe->CodeOfPred;
|
||||||
UNLOCK(ppe->PELock);
|
UNLOCK(ppe->PELock);
|
||||||
out = do_goal(CodeAdr, ppe->ArityOfPE, pt, FALSE PASS_REGS);
|
out = do_goal(CodeAdr, ppe->ArityOfPE, pt, FALSE PASS_REGS);
|
||||||
}
|
|
||||||
|
|
||||||
if (out == 1) {
|
if (out == 1) {
|
||||||
choiceptr cut_B;
|
choiceptr cut_B;
|
||||||
@ -1335,7 +1328,7 @@ Yap_execute_goal(Term t, int nargs, Term mod)
|
|||||||
if (pe == NIL) {
|
if (pe == NIL) {
|
||||||
return CallMetaCall(t, mod PASS_REGS);
|
return CallMetaCall(t, mod PASS_REGS);
|
||||||
}
|
}
|
||||||
return execute_pred(ppe, pt PASS_REGS);
|
return Yap_execute_pred(ppe, pt PASS_REGS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1430,13 +1423,17 @@ Yap_RunTopGoal(Term t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
restore_regs(Term t USES_REGS)
|
restore_regs(Term t, int restore_all USES_REGS)
|
||||||
{
|
{
|
||||||
if (IsApplTerm(t)) {
|
if (IsApplTerm(t)) {
|
||||||
Int i;
|
Int i;
|
||||||
Int max = ArityOfFunctor(FunctorOfTerm(t));
|
Int max = ArityOfFunctor(FunctorOfTerm(t))-4;
|
||||||
CELL *ptr = RepAppl(t)+1;
|
CELL *ptr = RepAppl(t)+5;
|
||||||
|
|
||||||
|
P = (yamop *)IntegerOfTerm(ptr[-4]);
|
||||||
|
CP = (yamop *)IntegerOfTerm(ptr[-3]);
|
||||||
|
ENV = (CELL *)(LCL0-IntegerOfTerm(ptr[-2]));
|
||||||
|
YENV = (CELL *)(LCL0-IntegerOfTerm(ptr[-1]));
|
||||||
for (i = 0; i < max; i += 2) {
|
for (i = 0; i < max; i += 2) {
|
||||||
Int j = IntOfTerm(ptr[0]);
|
Int j = IntOfTerm(ptr[0]);
|
||||||
XREGS[j] = ptr[1];
|
XREGS[j] = ptr[1];
|
||||||
@ -1455,7 +1452,7 @@ p_restore_regs( USES_REGS1 )
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if (IsAtomTerm(t)) return(TRUE);
|
if (IsAtomTerm(t)) return(TRUE);
|
||||||
restore_regs(t PASS_REGS);
|
restore_regs(t, FALSE PASS_REGS);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1466,13 +1463,15 @@ p_restore_regs2( USES_REGS1 )
|
|||||||
|
|
||||||
Term t = Deref(ARG1), d0;
|
Term t = Deref(ARG1), d0;
|
||||||
choiceptr pt0;
|
choiceptr pt0;
|
||||||
|
Int d;
|
||||||
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,t,"support for coroutining");
|
Yap_Error(INSTANTIATION_ERROR,t,"support for coroutining");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
d0 = Deref(ARG2);
|
d0 = Deref(ARG2);
|
||||||
if (!IsAtomTerm(t)) {
|
if (!IsAtomTerm(t)) {
|
||||||
restore_regs(t PASS_REGS);
|
restore_regs(t, TRUE PASS_REGS);
|
||||||
}
|
}
|
||||||
if (IsVarTerm(d0)) {
|
if (IsVarTerm(d0)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,d0,"support for coroutining");
|
Yap_Error(INSTANTIATION_ERROR,d0,"support for coroutining");
|
||||||
@ -1481,13 +1480,16 @@ p_restore_regs2( USES_REGS1 )
|
|||||||
if (!IsIntegerTerm(d0)) {
|
if (!IsIntegerTerm(d0)) {
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
d = IntegerOfTerm(d0);
|
||||||
|
if (!d)
|
||||||
|
return TRUE;
|
||||||
#if YAPOR_SBA
|
#if YAPOR_SBA
|
||||||
pt0 = (choiceptr)IntegerOfTerm(d0);
|
pt0 = (choiceptr)d;
|
||||||
#else
|
#else
|
||||||
pt0 = (choiceptr)(LCL0-IntOfTerm(d0));
|
pt0 = (choiceptr)(LCL0-d);
|
||||||
#endif
|
#endif
|
||||||
/* find where to cut to */
|
/* find where to cut to */
|
||||||
if (pt0 > B) {
|
if ((CELL *)pt0 != LCL0 && pt0 > B) {
|
||||||
/* Wow, we're gonna cut!!! */
|
/* Wow, we're gonna cut!!! */
|
||||||
while (B->cp_b < pt0) {
|
while (B->cp_b < pt0) {
|
||||||
while (POP_CHOICE_POINT(B->cp_b))
|
while (POP_CHOICE_POINT(B->cp_b))
|
||||||
|
Reference in New Issue
Block a user