xirestore: predicates need timestamps inorder to find out which clauses are alive.

This commit is contained in:
Vitor Santos Costa 2012-08-23 21:01:32 +01:00
parent 1be424fe57
commit 198fc03bae
2 changed files with 6 additions and 3 deletions

View File

@ -800,6 +800,9 @@ ReadHash(IOSTREAM *stream)
UInt sz = read_uint(stream);
UInt nrefs = read_uint(stream);
LogUpdClause *ncl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(sz);
if (!ncl) {
QLYR_ERROR(OUT_OF_CODE_SPACE);
}
ncl->Id = FunctorDBRef;
ncl->ClRefCount = nrefs;
InsertDBRef((DBRef)ocl,(DBRef)ncl);
@ -812,7 +815,6 @@ static void
read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
CACHE_REGS
if (pp->PredFlags & LogUpdatePredFlag) {
pp->TimeStampOfPred = 0L;
/* first, clean up whatever was there */
if (pp->cs.p_code.NOfClauses) {
LogUpdClause *cl;
@ -927,6 +929,7 @@ read_pred(IOSTREAM *stream, Term mod) {
ap->src.OwnerFile = AtomAdjust(ap->src.OwnerFile);
}
}
ap->TimeStampOfPred = read_uint(stream);
/* multifile predicates cannot reside in module 0 */
if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE)
ap->ModuleOfPred = TermProlog;

View File

@ -634,8 +634,7 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) {
LogUpdClause *cl = ClauseCodeToLogUpdClause(FirstC);
while (cl != NULL) {
if (pp->TimeStampOfPred >= cl->ClTimeStart &&
pp->TimeStampOfPred <= cl->ClTimeEnd) {
if (IN_BETWEEN(cl->ClTimeStart, pp->TimeStampOfPred, cl->ClTimeEnd)) {
UInt size = cl->ClSize;
CHECK(save_tag(stream, QLY_START_LU_CLAUSE));
CHECK(save_uint(stream, (UInt)cl));
@ -690,6 +689,7 @@ save_pred(IOSTREAM *stream, PredEntry *ap) {
CHECK(save_uint(stream, ap->PredFlags));
CHECK(save_uint(stream, ap->cs.p_code.NOfClauses));
CHECK(save_uint(stream, ap->src.IndxId));
CHECK(save_uint(stream, ap->TimeStampOfPred));
return save_clauses(stream, ap);
}