clause should not do write locking
expand_index should not care whether read_locks are held. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@996 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
6031b7f049
commit
d3f49b75df
33
C/absmi.c
33
C/absmi.c
@ -1105,9 +1105,6 @@ Yap_absmi(int inp)
|
|||||||
saveregs();
|
saveregs();
|
||||||
{
|
{
|
||||||
yamop *ipc;
|
yamop *ipc;
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
PredEntry *ap = PP;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* update ASP before calling IPred */
|
/* update ASP before calling IPred */
|
||||||
ASP = YREG+E_CB;
|
ASP = YREG+E_CB;
|
||||||
@ -1115,19 +1112,20 @@ Yap_absmi(int inp)
|
|||||||
ASP = (CELL *) B;
|
ASP = (CELL *) B;
|
||||||
}
|
}
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
READ_UNLOCK(ap->PRWLock);
|
LOCK(pe->PELock);
|
||||||
PP = NULL;
|
if (*PREG_ADDR != PREG) {
|
||||||
|
PREG = *PREG_ADDR;
|
||||||
|
UNLOCK(pe->PELock);
|
||||||
|
JMPNext();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
ipc = Yap_CleanUpIndex(PREG->u.Ill.I);
|
ipc = Yap_CleanUpIndex(PREG->u.Ill.I);
|
||||||
|
READ_UNLOCK(pe->PRWLock);
|
||||||
/* restart index */
|
/* restart index */
|
||||||
setregs();
|
setregs();
|
||||||
PREG = ipc;
|
PREG = ipc;
|
||||||
if (PREG == NULL) FAIL();
|
if (PREG == NULL) FAIL();
|
||||||
CACHED_A1() = ARG1;
|
CACHED_A1() = ARG1;
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
PP = ap;
|
|
||||||
READ_LOCK(ap->PRWLock);
|
|
||||||
#endif
|
|
||||||
JMPNext();
|
JMPNext();
|
||||||
}
|
}
|
||||||
ENDBOp();
|
ENDBOp();
|
||||||
@ -6361,28 +6359,17 @@ Yap_absmi(int inp)
|
|||||||
}
|
}
|
||||||
saveregs();
|
saveregs();
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
if (PP != pe) {
|
|
||||||
READ_LOCK(pe->PRWLock);
|
|
||||||
}
|
|
||||||
LOCK(pe->PELock);
|
LOCK(pe->PELock);
|
||||||
if (*PREG_ADDR != (yamop *)&(pe->cs.p_code.ExpandCode)) {
|
if (*PREG_ADDR != PREG)) {
|
||||||
pt0 = *PREG_ADDR;
|
PREG = *PREG_ADDR;
|
||||||
UNLOCK(pe->PELock);
|
UNLOCK(pe->PELock);
|
||||||
if (PP != pe) {
|
|
||||||
READ_UNLOCK(pe->PRWLock);
|
|
||||||
}
|
|
||||||
JMPNext();
|
JMPNext();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
pt0 = Yap_ExpandIndex(pe);
|
pt0 = Yap_ExpandIndex(pe);
|
||||||
/* restart index */
|
/* restart index */
|
||||||
setregs();
|
|
||||||
UNLOCK(pe->PELock);
|
UNLOCK(pe->PELock);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
setregs();
|
||||||
if (PP != pe) {
|
|
||||||
READ_UNLOCK(pe->PRWLock);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
PREG = pt0;
|
PREG = pt0;
|
||||||
JMPNext();
|
JMPNext();
|
||||||
}
|
}
|
||||||
|
59
C/cdmgr.c
59
C/cdmgr.c
@ -3051,10 +3051,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
|
|||||||
|
|
||||||
cl = Yap_FollowIndexingCode(pe, i_code, th, tb, tr, NEXTOP(PredLogUpdClause->CodeOfPred,ld), cp_ptr);
|
cl = Yap_FollowIndexingCode(pe, i_code, th, tb, tr, NEXTOP(PredLogUpdClause->CodeOfPred,ld), cp_ptr);
|
||||||
if (cl == NULL) {
|
if (cl == NULL) {
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
READ_UNLOCK(pe->PRWLock);
|
||||||
WPP = NULL;
|
|
||||||
#endif
|
|
||||||
WRITE_UNLOCK(pe->PRWLock);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
rtn = MkDBRefTerm((DBRef)cl);
|
rtn = MkDBRefTerm((DBRef)cl);
|
||||||
@ -3069,10 +3066,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
|
|||||||
TRAIL_CLREF(cl); /* So that fail will erase it */
|
TRAIL_CLREF(cl); /* So that fail will erase it */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
READ_UNLOCK(pe->PRWLock);
|
||||||
WPP = NULL;
|
|
||||||
#endif
|
|
||||||
WRITE_UNLOCK(pe->PRWLock);
|
|
||||||
if (cl->ClFlags & FactMask) {
|
if (cl->ClFlags & FactMask) {
|
||||||
if (!Yap_unify(tb, MkAtomTerm(AtomTrue)) ||
|
if (!Yap_unify(tb, MkAtomTerm(AtomTrue)) ||
|
||||||
!Yap_unify(tr, rtn))
|
!Yap_unify(tr, rtn))
|
||||||
@ -3128,10 +3122,7 @@ p_log_update_clause(void)
|
|||||||
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
||||||
if (pe == NULL || EndOfPAEntr(pe))
|
if (pe == NULL || EndOfPAEntr(pe))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WRITE_LOCK(pe->PRWLock);
|
READ_LOCK(pe->PRWLock);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
WPP = pe;
|
|
||||||
#endif
|
|
||||||
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
||||||
IPred(pe);
|
IPred(pe);
|
||||||
}
|
}
|
||||||
@ -3144,10 +3135,7 @@ p_continue_log_update_clause(void)
|
|||||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||||
|
|
||||||
WRITE_LOCK(pe->PRWLock);
|
READ_LOCK(pe->PRWLock);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
WPP = pe;
|
|
||||||
#endif
|
|
||||||
return fetch_next_lu_clause(pe, ipc, Deref(ARG3), ARG4, ARG5, B->cp_ap, FALSE);
|
return fetch_next_lu_clause(pe, ipc, Deref(ARG3), ARG4, ARG5, B->cp_ap, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3157,10 +3145,7 @@ fetch_next_lu_clause0(PredEntry *pe, yamop *i_code, Term th, Term tb, yamop *cp_
|
|||||||
LogUpdClause *cl;
|
LogUpdClause *cl;
|
||||||
|
|
||||||
cl = Yap_FollowIndexingCode(pe, i_code, th, tb, TermNil, NEXTOP(PredLogUpdClause0->CodeOfPred,ld), cp_ptr);
|
cl = Yap_FollowIndexingCode(pe, i_code, th, tb, TermNil, NEXTOP(PredLogUpdClause0->CodeOfPred,ld), cp_ptr);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
READ_UNLOCK(pe->PRWLock);
|
||||||
WPP = NULL;
|
|
||||||
#endif
|
|
||||||
WRITE_UNLOCK(pe->PRWLock);
|
|
||||||
if (cl == NULL) {
|
if (cl == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -3217,10 +3202,7 @@ p_log_update_clause0(void)
|
|||||||
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
||||||
if (pe == NULL || EndOfPAEntr(pe))
|
if (pe == NULL || EndOfPAEntr(pe))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WRITE_LOCK(pe->PRWLock);
|
READ_LOCK(pe->PRWLock);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
WPP = pe;
|
|
||||||
#endif
|
|
||||||
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
||||||
IPred(pe);
|
IPred(pe);
|
||||||
}
|
}
|
||||||
@ -3233,10 +3215,7 @@ p_continue_log_update_clause0(void)
|
|||||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||||
|
|
||||||
WRITE_LOCK(pe->PRWLock);
|
READ_LOCK(pe->PRWLock);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
WPP = pe;
|
|
||||||
#endif
|
|
||||||
return fetch_next_lu_clause0(pe, ipc, Deref(ARG3), ARG4, B->cp_ap, FALSE);
|
return fetch_next_lu_clause0(pe, ipc, Deref(ARG3), ARG4, B->cp_ap, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3247,7 +3226,6 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
|
|||||||
Term rtn;
|
Term rtn;
|
||||||
|
|
||||||
cl = (StaticClause *)Yap_FollowIndexingCode(pe, i_code, th, tb, tr, NEXTOP(PredStaticClause->CodeOfPred,ld), cp_ptr);
|
cl = (StaticClause *)Yap_FollowIndexingCode(pe, i_code, th, tb, tr, NEXTOP(PredStaticClause->CodeOfPred,ld), cp_ptr);
|
||||||
WRITE_UNLOCK(pe->PRWLock);
|
|
||||||
if (cl == NULL)
|
if (cl == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
rtn = MkDBRefTerm((DBRef)cl);
|
rtn = MkDBRefTerm((DBRef)cl);
|
||||||
@ -3305,7 +3283,6 @@ p_static_clause(void)
|
|||||||
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
||||||
if (pe == NULL || EndOfPAEntr(pe))
|
if (pe == NULL || EndOfPAEntr(pe))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WRITE_LOCK(pe->PRWLock);
|
|
||||||
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
||||||
IPred(pe);
|
IPred(pe);
|
||||||
}
|
}
|
||||||
@ -3327,14 +3304,21 @@ p_nth_clause(void)
|
|||||||
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
pe = get_pred(t1, Deref(ARG2), "clause/3");
|
||||||
if (pe == NULL || EndOfPAEntr(pe))
|
if (pe == NULL || EndOfPAEntr(pe))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
||||||
WRITE_LOCK(pe->PRWLock);
|
WRITE_LOCK(pe->PRWLock);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
||||||
WPP = pe;
|
IPred(pe);
|
||||||
#endif
|
}
|
||||||
if (!(pe->PredFlags & (SourcePredFlag|LogUpdatePredFlag))) {
|
|
||||||
WRITE_UNLOCK(pe->PRWLock);
|
WRITE_UNLOCK(pe->PRWLock);
|
||||||
|
}
|
||||||
|
READ_LOCK(pe->PRWLock);
|
||||||
|
if (!(pe->PredFlags & (SourcePredFlag|LogUpdatePredFlag))) {
|
||||||
|
READ_UNLOCK(pe->PRWLock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
if (pe->PredFlags & SourcePredFlag) {
|
||||||
|
READ_UNLOCK(pe->PRWLock);
|
||||||
|
}
|
||||||
/* in case we have to index or to expand code */
|
/* in case we have to index or to expand code */
|
||||||
if (pe->ModuleOfPred != IDB_MODULE) {
|
if (pe->ModuleOfPred != IDB_MODULE) {
|
||||||
UInt i;
|
UInt i;
|
||||||
@ -3345,10 +3329,10 @@ p_nth_clause(void)
|
|||||||
} else {
|
} else {
|
||||||
XREGS[2] = MkVarTerm();
|
XREGS[2] = MkVarTerm();
|
||||||
}
|
}
|
||||||
if(pe->OpcodeOfPred == INDEX_OPCODE) {
|
|
||||||
IPred(pe);
|
|
||||||
}
|
|
||||||
cl = Yap_NthClause(pe, ncls);
|
cl = Yap_NthClause(pe, ncls);
|
||||||
|
if (pe->PredFlags & LogUpdatePredFlag) {
|
||||||
|
READ_UNLOCK(pe->PRWLock);
|
||||||
|
}
|
||||||
if (cl == NULL)
|
if (cl == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (cl->ClFlags & LogUpdatePredFlag) {
|
if (cl->ClFlags & LogUpdatePredFlag) {
|
||||||
@ -3373,7 +3357,6 @@ p_continue_static_clause(void)
|
|||||||
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
PredEntry *pe = (PredEntry *)IntegerOfTerm(Deref(ARG1));
|
||||||
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
yamop *ipc = (yamop *)IntegerOfTerm(ARG2);
|
||||||
|
|
||||||
WRITE_LOCK(pe->PRWLock);
|
|
||||||
return fetch_next_static_clause(pe, ipc, Deref(ARG3), ARG4, ARG5, B->cp_ap, FALSE);
|
return fetch_next_static_clause(pe, ipc, Deref(ARG3), ARG4, ARG5, B->cp_ap, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
C/index.c
44
C/index.c
@ -6382,6 +6382,14 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam
|
|||||||
ipc = NEXTOP(ipc,l);
|
ipc = NEXTOP(ipc,l);
|
||||||
break;
|
break;
|
||||||
case _stale_lu_index:
|
case _stale_lu_index:
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
LOCK(ap->PELock);
|
||||||
|
if (*jbl != ipc) {
|
||||||
|
ipc = *jbl;
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
yamop *nipc = clean_up_index(ipc->u.Ill.I, jlbl, ap);
|
yamop *nipc = clean_up_index(ipc->u.Ill.I, jlbl, ap);
|
||||||
if (nipc == NULL) {
|
if (nipc == NULL) {
|
||||||
@ -6391,6 +6399,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam
|
|||||||
H[2] = tr;
|
H[2] = tr;
|
||||||
H += 3;
|
H += 3;
|
||||||
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -6399,6 +6408,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam
|
|||||||
tb = H[1];
|
tb = H[1];
|
||||||
tr = H[2];
|
tr = H[2];
|
||||||
} else {
|
} else {
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
ipc = nipc;
|
ipc = nipc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -6574,7 +6584,16 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _expand_index:
|
case _expand_index:
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
LOCK(ap->PELock);
|
||||||
|
if (*jbl != ipc) {
|
||||||
|
ipc = *jbl;
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
ipc = ExpandIndex(ap);
|
ipc = ExpandIndex(ap);
|
||||||
|
UNLOCK(pe->PELock);
|
||||||
break;
|
break;
|
||||||
case _op_fail:
|
case _op_fail:
|
||||||
/*
|
/*
|
||||||
@ -6629,12 +6648,6 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam
|
|||||||
abolish_incomplete_subgoals(B);
|
abolish_incomplete_subgoals(B);
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
}
|
}
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
|
||||||
if (PP == ap) {
|
|
||||||
PP = NULL;
|
|
||||||
READ_UNLOCK(ap->PRWLock);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6736,15 +6749,25 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
|||||||
case _trust_logical_pred:
|
case _trust_logical_pred:
|
||||||
ipc = NEXTOP(ipc,l);
|
ipc = NEXTOP(ipc,l);
|
||||||
case _stale_lu_index:
|
case _stale_lu_index:
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
LOCK(ap->PELock);
|
||||||
|
if (*jbl != ipc) {
|
||||||
|
ipc = *jbl;
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
yamop *nipc = clean_up_index(ipc->u.Ill.I, jlbl, ap);
|
yamop *nipc = clean_up_index(ipc->u.Ill.I, jlbl, ap);
|
||||||
if (nipc == NULL) {
|
if (nipc == NULL) {
|
||||||
/* not enough space */
|
/* not enough space */
|
||||||
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) {
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
ipc = nipc;
|
ipc = nipc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -6789,7 +6812,16 @@ Yap_NthClause(PredEntry *ap, Int ncls)
|
|||||||
ipc = ipc->u.clll.l3;
|
ipc = ipc->u.clll.l3;
|
||||||
break;
|
break;
|
||||||
case _expand_index:
|
case _expand_index:
|
||||||
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
|
LOCK(ap->PELock);
|
||||||
|
if (*jbl != (yamop *)&(ap->cs.p_code.ExpandCode)) {
|
||||||
|
ipc = *jbl;
|
||||||
|
UNLOCK(pe->PELock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
ipc = ExpandIndex(ap);
|
ipc = ExpandIndex(ap);
|
||||||
|
UNLOCK(ap->PELock);
|
||||||
break;
|
break;
|
||||||
case _op_fail:
|
case _op_fail:
|
||||||
ipc = alt;
|
ipc = alt;
|
||||||
|
Reference in New Issue
Block a user