From 198fc03baef642eb9a5fc84c1b6afb0f347d7e37 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Thu, 23 Aug 2012 21:01:32 +0100 Subject: [PATCH] xirestore: predicates need timestamps inorder to find out which clauses are alive. --- C/qlyr.c | 5 ++++- C/qlyw.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/C/qlyr.c b/C/qlyr.c index 5f339a031..5ce26501a 100644 --- a/C/qlyr.c +++ b/C/qlyr.c @@ -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; diff --git a/C/qlyw.c b/C/qlyw.c index ae435c4aa..c7a872d80 100644 --- a/C/qlyw.c +++ b/C/qlyw.c @@ -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); }