fix non-tabling version

fix compilation with THREADS


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@952 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-12-18 17:23:22 +00:00
parent 221665bab8
commit e7ab7b4c8a
8 changed files with 26 additions and 29 deletions

View File

@ -1129,7 +1129,7 @@ Yap_absmi(int inp)
/* clear the entry from the trail */
TR = --(B->cp_tr);
/* actually get rid of the code */
if (cl->ref_count == 0 && cl->ClFlags & ErasedMask) {
if (cl->ClRefCount == 0 && cl->ClFlags & ErasedMask) {
UNLOCK(cl->ClLock);
/* I am the last one using this clause, hence I don't need a lock
to dispose of it
@ -1208,7 +1208,6 @@ Yap_absmi(int inp)
setregs();
#if defined(YAPOR) || defined(THREADS)
LOCK(cl->ClLock);
/* always add an extra reference */
INC_CLREF_COUNT(cl);
@ -1253,7 +1252,6 @@ Yap_absmi(int inp)
/* say that an environment is using this clause */
/* we have our own copy for the clause */
#if defined(YAPOR) || defined(THREADS)
LOCK(cl->ClLock);
/* always add an extra reference */
INC_CLREF_COUNT(cl);
@ -1619,7 +1617,7 @@ Yap_absmi(int inp)
int erase;
LOCK(cl->ClLock);
DEC_CLREF_COUNT(cl);
erase = (cl->ClFlags & ErasedMask) && (cl->ref_count == 0);
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
UNLOCK(cl->ClLock);
if (erase) {
saveregs();
@ -1628,12 +1626,13 @@ Yap_absmi(int inp)
hence we don't need to have a lock it */
Yap_ErLogUpdCl(cl);
setregs();
}
} else {
DynamicClause *cl = ClauseFlagsToDynamicClause(pt1);
int erase;
LOCK(cl->ClLock);
DEC_CLREF_COUNT(cl);
erase = (cl->ClFlags & ErasedMask) && (cl->ref_count == 0);
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
UNLOCK(cl->ClLock);
if (erase) {
saveregs();
@ -6359,17 +6358,10 @@ Yap_absmi(int inp)
we do not lock access to the predicate,
we must take extra care here
*/
/*
Ideally, this code should only be executed by
dynamic procedures in YAPOR. Unfortunately, it also seems
to be executed when
running a procedure from within the file that defines it.
*/
/* THIS SHOULD BE AN ERROR !!!!! */
if (PredFromDefCode(PREG)->OpcodeOfPred != INDEX_OPCODE) {
/* someone was here before we were */
Yap_Error(SYSTEM_ERROR,TermNil,"Bad locking");
PREG = FAILCODE;
PREG = PredFromDefCode(PREG)->CodeOfPred;
WRITE_UNLOCK(PredFromDefCode(PREG)->PRWLock);
JMPNext();
}

View File

@ -2067,8 +2067,8 @@ do_pass(void)
cl_u->luc.ClExt = NULL;
cl_u->luc.ClPrev = cl_u->luc.ClNext = NULL;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(cl_u.luc->ClLock);
INIT_CLREF_COUNT(cl_u.luc);
INIT_LOCK(cl_u->luc.ClLock);
INIT_CLREF_COUNT(&(cl_u->luc));
#endif
}
code_p = cl_u->luc.ClCode;
@ -2080,8 +2080,8 @@ do_pass(void)
}
cl_u->ic.ClRefCount = 0;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(cl_u.ic->ClLock);
INIT_CLREF_COUNT(cl_u.ic);
INIT_LOCK(cl_u->ic.ClLock);
INIT_CLREF_COUNT(&(cl_u->ic));
#endif
}
code_p = cl_u->ic.ClCode;

View File

@ -3049,10 +3049,10 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
return FALSE;
}
rtn = MkDBRefTerm((DBRef)cl);
#if defined(OR) || defined(THREADS)
#if defined(YAPOR) || defined(THREADS)
LOCK(cl->ClLock);
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_DBREF_COUNT(cl);
INC_CLREF_COUNT(cl);
UNLOCK(cl->ClLock);
#else
if (!(cl->ClFlags & InUseMask)) {
@ -3325,7 +3325,7 @@ p_nth_clause(void)
#if defined(YAPOR) || defined(THREADS)
LOCK(cl->ClLock);
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_DBREF_COUNT(cl);
INC_CLREF_COUNT(cl);
UNLOCK(cl->ClLock);
#else
if (!(cl->ClFlags & InUseMask)) {

View File

@ -2606,7 +2606,7 @@ new_lu_entry(Term t)
WRITE_LOCK(RepAtom(at)->ARWLock);
p0 = Yap_NewPredPropByAtom(at,2);
} else {
WRITE_LOCK(f->FRWLock);
WRITE_LOCK(FunctorList->FRWLock);
p0 = Yap_NewPredPropByFunctor(FunctorList,2);
}
pe = RepPredProp(p0);
@ -3729,7 +3729,7 @@ find_next_clause(DBRef ref0)
LOCK(cl->ClLock);
TRAIL_CLREF(cl);
INC_DBREF_COUNT(cl);
INC_CLREF_COUNT(cl);
UNLOCK(cl->ClLock);
}
#else

View File

@ -156,7 +156,7 @@ CallClause(PredEntry *pen, Int position)
LOCK(cl->ClLock);
TRAIL_CLREF(cl);
INC_DBREF_COUNT(cl);
INC_CLREF_COUNT(cl);
UNLOCK(cl->ClLock);
}
#else

View File

@ -1949,7 +1949,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
indx->ClFlags &= ~InUseMask;
erase = (indx->ClFlags & ErasedMask)
#if defined(YAPOR) || defined(THREADS)
&& (indx->ref_count == 0)
&& (indx->ClRefCount == 0)
#endif
;
if (erase) {
@ -1964,7 +1964,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
cl->ClFlags &= ~InUseMask;
erase = (cl->ClFlags & ErasedMask)
#if defined(YAPOR) || defined(THREADS)
&& (cl->ref_count == 0)
&& (cl->ClRefCount == 0)
#endif
;
if (erase) {
@ -1980,7 +1980,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
cl->ClFlags &= ~InUseMask;
erase = (cl->ClFlags & ErasedMask)
#if defined(YAPOR) || defined(THREADS)
&& (cl->ref_count == 0)
&& (cl->ClRefCount == 0)
#endif
;
if (erase) {

View File

@ -2351,10 +2351,13 @@ emit_optry(int var_group, int first, int clauses, int clleft, PredEntry *ap)
return trust_op;
}
} else if (clleft == 0) {
#ifdef TABLING
if (ap->PredFlags & TabledPredFlag && !first) {
/* we never actually get to remove the last choice-point in this case */
return retry_op;
} else {
} else
#endif
{
/* last group */
return try_op;
}
@ -2862,6 +2865,7 @@ emit_protection_choicepoint(int first, int clleft, UInt nxtlbl, PredEntry *ap)
/* !first */
if (clleft) {
Yap_emit(retryme_op, nxtlbl, (clleft << 1));
#ifdef TABLING
} else if ((ap->PredFlags & TabledPredFlag)) {
/*
we cannot get rid of the choice-point for tabled predicates, all
@ -2870,6 +2874,7 @@ emit_protection_choicepoint(int first, int clleft, UInt nxtlbl, PredEntry *ap)
*/
Yap_emit(retryme_op, (CELL)TRUSTFAILCODE, 0);
} else {
#endif
Yap_emit(trustme_op, 0, 0);
}
}
@ -6203,7 +6208,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam
/* clear the entry from the trail */
TR = --(B->cp_tr);
/* actually get rid of the code */
if (cl->ref_count == 0 && cl->ClFlags & ErasedMask) {
if (cl->ClRefCount == 0 && cl->ClFlags & ErasedMask) {
UNLOCK(cl->ClLock);
/* I am the last one using this clause, hence I don't need a lock
to dispose of it

View File

@ -1105,7 +1105,7 @@ Yap_InitStacks(int Heap,
#endif /* PUSH_REGS */
#ifdef THREADS
regp->worker_id_ = 0;
Yap_regp->worker_id_ = 0;
#endif
/* Init signal handling and time */
/* also init memory page size, required by later functions */