use PP with care:

- clean after interrupt;
  - use it only for indexing code.
This commit is contained in:
Vítor Santos Costa 2014-10-19 01:48:38 +01:00
parent 827be2f8d0
commit 18506025c3
3 changed files with 53 additions and 27 deletions

View File

@ -949,6 +949,7 @@ interrupt_execute( USES_REGS1 )
if ((v = check_alarm_fail_int( true PASS_REGS )) >= 0) {
return v;
}
if (PP) UNLOCKPE(1,PP);
PP = P->y_u.pp.p0;
if ((PP->ExtraPredFlags & (NoTracePredFlag|HiddenPredFlag)) && Yap_only_has_signal(YAP_CREEP_SIGNAL)) {
return 2;
@ -975,6 +976,7 @@ interrupt_call( USES_REGS1 )
if ((v = check_alarm_fail_int( true PASS_REGS )) >= 0) {
return v;
}
if (PP) UNLOCKPE(1,PP);
PP = P->y_u.Osbpp.p0;
if (Yap_only_has_signal(YAP_CREEP_SIGNAL) &&
(PP->ExtraPredFlags & (NoTracePredFlag|HiddenPredFlag)) ) {
@ -1002,6 +1004,7 @@ interrupt_pexecute( PredEntry *pen USES_REGS )
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0) {
return v;
}
if (PP) UNLOCKPE(1,PP);
PP = NULL;
if (Yap_only_has_signal(YAP_CREEP_SIGNAL)) {
return 2; /* keep on creeping */
@ -1046,6 +1049,7 @@ interrupt_deallocate( USES_REGS1 )
} else {
CELL cut_b = LCL0-(CELL *)(S[E_CB]);
if (PP) UNLOCKPE(1,PP);
PP = PREVOP(P,p)->y_u.p.p;
ASP = YENV+E_CB;
/* cut_e */
@ -1174,6 +1178,7 @@ interrupt_commit_x( USES_REGS1 )
if (Yap_only_has_signals(YAP_CDOVF_SIGNAL , YAP_CREEP_SIGNAL )) {
return 2;
}
if (PP) UNLOCKPE(1,PP);
PP = P->y_u.xps.p0;
/* find something to fool S */
if (P->opc == Yap_opcode(_fcall)) {
@ -1205,6 +1210,7 @@ interrupt_either( USES_REGS1 )
if (Yap_only_has_signal(YAP_CREEP_SIGNAL)) {
return 2;
}
if (PP) UNLOCKPE(1,PP);
PP = P->y_u.Osblp.p0;
/* find something to fool S */
SET_ASP(YENV, P->y_u.Osbpp.s);
@ -1229,6 +1235,7 @@ interrupt_dexecute( USES_REGS1 )
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
if (PP) UNLOCKPE(1,PP);
PP = P->y_u.pp.p0;
pe = P->y_u.pp.p;
if ((PP->ExtraPredFlags & (NoTracePredFlag|HiddenPredFlag)) && Yap_only_has_signal(YAP_CREEP_SIGNAL)) {
@ -2042,6 +2049,13 @@ Yap_absmi(int inp)
UInt timestamp;
CACHE_Y(B);
#if defined(YAPOR) || defined(THREADS)
if (PP != PREG->y_u.OtaLl.d->ClPred) {
if (PP) UNLOCKPE(15,PP);
PP = PREG->y_u.OtaLl.d->ClPred;
PELOCK(15,PP);
}
#endif
timestamp = IntegerOfTerm(((CELL *)(B_YREG+1))[PREG->y_u.OtaLl.s]);
if (!VALID_TIMESTAMP(timestamp, PREG->y_u.OtaLl.d)) {
/* jump to next instruction */
@ -2077,6 +2091,13 @@ Yap_absmi(int inp)
LogUpdClause *lcl = PREG->y_u.OtILl.d;
UInt timestamp = IntegerOfTerm(((CELL *)(B_YREG+1))[ap->ArityOfPE]);
#if defined(YAPOR) || defined(THREADS)
if (PP != ap) {
if (PP) UNLOCKPE(16,PP);
PP = ap;
PELOCK(16,PP);
}
#endif
if (!VALID_TIMESTAMP(timestamp, lcl)) {
/* jump to next alternative */
PREG = FAILCODE;
@ -2089,8 +2110,6 @@ Yap_absmi(int inp)
/* HEY, leave indexing block alone!! */
/* check if we are the ones using this code */
#if MULTIPLE_STACKS
PELOCK(1, ap);
PP = ap;
DEC_CLREF_COUNT(cl);
/* clear the entry from the trail */
B->cp_tr--;
@ -2322,6 +2341,13 @@ Yap_absmi(int inp)
UInt timestamp;
CACHE_Y(B);
#if defined(YAPOR) || defined(THREADS)
if (PP != PREG->y_u.OtaLl.d->ClPred) {
if (PP) UNLOCKPE(15,PP);
PP = PREG->y_u.OtaLl.d->ClPred;
PELOCK(15,PP);
}
#endif
timestamp = IntegerOfTerm(((CELL *)(B_YREG+1))[PREG->y_u.OtaLl.s]);
if (!VALID_TIMESTAMP(timestamp, PREG->y_u.OtaLl.d)) {
/* jump to next instruction */
@ -2371,6 +2397,13 @@ Yap_absmi(int inp)
LogUpdClause *lcl = PREG->y_u.OtILl.d;
UInt timestamp = IntegerOfTerm(((CELL *)(B_YREG+1))[ap->ArityOfPE]);
#if defined(YAPOR) || defined(THREADS)
if (PP != ap) {
if (PP) UNLOCKPE(16,PP);
PP = ap;
PELOCK(16,PP);
}
#endif
if (!VALID_TIMESTAMP(timestamp, lcl)) {
/* jump to next alternative */
PREG = FAILCODE;
@ -2511,8 +2544,10 @@ Yap_absmi(int inp)
/* lock logical updates predicate. */
Op(unlock_lu, e);
#if defined(YAPOR) || defined(THREADS)
if (PP) {
UNLOCKPE(1,PP);
PP = NULL;
}
#endif
PREG = NEXTOP(PREG, e);
GONext();
@ -8620,7 +8655,8 @@ Yap_absmi(int inp)
CACHE_Y(B);
#if defined(YAPOR) || defined(THREADS)
if (!PP) {
if (PP != PREG->y_u.OtaLl.d->ClPred) {
if (PP) UNLOCKPE(15,PP);
PP = PREG->y_u.OtaLl.d->ClPred;
PELOCK(15,PP);
}
@ -8660,9 +8696,10 @@ Yap_absmi(int inp)
/* fprintf(stderr,"- %p/%p %d %d %p\n",PREG,ap,timestamp,ap->TimeStampOfPred,PREG->y_u.OtILl.d->ClCode);*/
#if defined(YAPOR) || defined(THREADS)
if (!PP) {
PELOCK(16,ap);
if (PP != ap) {
if (PP) UNLOCKPE(16,PP);
PP = ap;
PELOCK(16,PP);
}
#endif
if (!VALID_TIMESTAMP(timestamp, lcl)) {

View File

@ -3054,6 +3054,13 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
code_p = a_try(_try_me, 0, LOCAL_IPredArity, code_p, pass_no, cip);
#endif /* YAPOR */
}
#if THREADS||YAPOR
if (log_update) {
// separate from indexing code,
//clauses are protected by time-stamps
code_p = a_e(_unlock_lu, code_p, pass_no);
}
#endif
} else {
/* index code */
if (log_update) {
@ -3365,13 +3372,6 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
(*clause_has_blobsp || *clause_has_dbtermp) &&
!clinfo.alloc_found)
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
#if defined(THREADS) || defined(YAPOR)
else
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
!clinfo.alloc_found)
code_p = a_e(_unlock_lu, code_p, pass_no);
#endif
code_p = a_cut(&clinfo, code_p, pass_no, cip);
break;
case allocate_op:
@ -3465,25 +3465,12 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
(*clause_has_blobsp || *clause_has_dbtermp) &&
!clinfo.alloc_found)
code_p = a_cle(_alloc_for_logical_pred, code_p, pass_no, cip);
#if defined(THREADS) || defined(YAPOR)
else
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
!clinfo.alloc_found)
code_p = a_e(_unlock_lu, code_p, pass_no);
#endif
code_p = a_pl(_procceed, cip->CurrentPred, code_p, pass_no);
break;
case call_op:
code_p = a_p(_call, &clinfo, code_p, pass_no, cip);
break;
case execute_op:
#if defined(THREADS) || defined(YAPOR)
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
!clinfo.alloc_found)
code_p = a_e(_unlock_lu, code_p, pass_no);
#endif
code_p = a_p(_execute, &clinfo, code_p, pass_no, cip);
break;
case safe_call_op:

View File

@ -1616,6 +1616,7 @@ prune(choiceptr cp USES_REGS)
setregs(); \
SREG = Yap_REGS.S_; \
if (!d0) FAIL(); \
PP = NULL;\
if (d0 == 2) goto C; \
JMPNext(); \
ENDD(d0);
@ -1625,6 +1626,7 @@ prune(choiceptr cp USES_REGS)
saveregs(); \
d0 = F ( PASS_REGS1 );\
setregs(); \
PP = NULL;\
if (!d0) FAIL(); \
if (d0 == 2) goto C; \
JMPNext(); \