From 7cc9d2f8829a5d550d7348ac38f735271ccf0a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Sun, 28 Feb 2016 19:30:46 +0000 Subject: [PATCH] fix case where rheap thought a fact could actually stre its src --- C/agc.c | 4 ++-- C/save.c | 6 +++--- H/rheap.h | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/C/agc.c b/C/agc.c index 00aa01596..f2709764e 100755 --- a/C/agc.c +++ b/C/agc.c @@ -34,7 +34,7 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90"; static void RestoreEntries(PropEntry *, int USES_REGS); static void CleanCode(PredEntry * USES_REGS); -static void RestoreDBTerm(DBTerm *dbr, int attachments USES_REGS); +static void RestoreDBTerm(DBTerm *dbr, bool src, int attachments USES_REGS); #define AtomMarkedBit 1 @@ -196,7 +196,7 @@ AdjustTermFlag(flag_term *tarr, UInt i) { CACHE_REGS if (IsVarTerm(tarr[i].at)) { - RestoreDBTerm( tarr[i].DBT, 0 PASS_REGS ); + RestoreDBTerm( tarr[i].DBT, false, 0 PASS_REGS ); } else if (IsAtomTerm( tarr[i].at ) ) tarr[i].at = AtomTermAdjust(tarr[i].at); } diff --git a/C/save.c b/C/save.c index b20e9f3ad..09e62606e 100755 --- a/C/save.c +++ b/C/save.c @@ -114,8 +114,8 @@ static int CopyStacks( CACHE_TYPE1 ); static int get_coded(int, OPCODE [] CACHE_TYPE); static void restore_codes(void); static void RestoreDB(DBEntry * CACHE_TYPE); -static void RestoreDBTerm(DBTerm *, int CACHE_TYPE); -static void CleanClauses(yamop *, yamop *,PredEntry * CACHE_TYPE); +static void RestoreDBTerm(DBTerm *, bool, int CACHE_TYPE); +static void CleanClauses(yamop *First, yamop *Last, PredEntry *pp USES_REGS); static void rehash(CELL *, int, int CACHE_TYPE); static void CleanCode(PredEntry * CACHE_TYPE); static void RestoreEntries(PropEntry *, int CACHE_TYPE); @@ -1069,7 +1069,7 @@ restore_regs(int flag USES_REGS) S = PtoGloAdjust(S); if (EX) { EX = DBTermAdjust(EX); - RestoreDBTerm(EX, TRUE PASS_REGS); + RestoreDBTerm(EX, false, TRUE PASS_REGS); } LOCAL_WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_WokenGoals))); } diff --git a/H/rheap.h b/H/rheap.h index e67f7ec33..ee9049513 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -498,7 +498,7 @@ static Term AdjustDBTerm__(Term trm, Term *p_base, Term *p_lim, return trm; } -static void RestoreDBTerm(DBTerm *dbr, int attachments USES_REGS) { +static void RestoreDBTerm(DBTerm *dbr, bool src, int attachments USES_REGS) { if (attachments) { #ifdef COROUTINING if (attachments == 1 && dbr->ag.attachments) @@ -540,9 +540,9 @@ static void RestoreStaticClause(StaticClause *cl USES_REGS) * clause for this predicate or not */ { - if (cl->ClFlags & SrcMask) { + if (cl->ClFlags & SrcMask && !(cl->ClFlags & FactMask)) { cl->usc.ClSource = DBTermAdjust(cl->usc.ClSource); - RestoreDBTerm(cl->usc.ClSource, 2 PASS_REGS); + RestoreDBTerm(cl->usc.ClSource, true, 2 PASS_REGS); } if (cl->ClNext) { cl->ClNext = PtoStCAdjust(cl->ClNext); @@ -611,7 +611,7 @@ static void RestoreLUClause(LogUpdClause *cl, PredEntry *pp USES_REGS) } if (!(cl->ClFlags & FactMask)) { cl->lusl.ClSource = DBTermAdjust(cl->lusl.ClSource); - RestoreDBTerm(cl->lusl.ClSource, 2 PASS_REGS); + RestoreDBTerm(cl->lusl.ClSource, true, 2 PASS_REGS); } if (cl->ClPrev) { cl->ClPrev = PtoLUCAdjust(cl->ClPrev); @@ -635,7 +635,7 @@ static void RestoreDBTermEntry(struct dbterm_list *dbl USES_REGS) { dbl->next_dbl = PtoDBTLAdjust(dbl->next_dbl); dbl->p = PredEntryAdjust(dbl->p); while (dbt) { - RestoreDBTerm(dbt, 0 PASS_REGS); + RestoreDBTerm(dbt, false, 0 PASS_REGS); dbt = dbt->ag.NextDBT; } } @@ -943,7 +943,7 @@ static void RestoreYapRecords__(USES_REGS1) { ptr->next_rec = DBRecordAdjust(ptr->next_rec); ptr->prev_rec = DBRecordAdjust(ptr->prev_rec); ptr->dbrecord = DBTermAdjust(ptr->dbrecord); - RestoreDBTerm(ptr->dbrecord, 0 PASS_REGS); + RestoreDBTerm(ptr->dbrecord, false,0 PASS_REGS); ptr = ptr->next_rec; } } @@ -952,7 +952,7 @@ static void RestoreBallTerm(int wid) { CACHE_REGS if (LOCAL_BallTerm) { LOCAL_BallTerm = DBTermAdjust(LOCAL_BallTerm); - RestoreDBTerm(LOCAL_BallTerm, 1 PASS_REGS); + RestoreDBTerm(LOCAL_BallTerm, false,1 PASS_REGS); } } @@ -984,7 +984,7 @@ static void RestoreDBEntry(DBRef dbr USES_REGS) { else fprintf(stderr, " a var\n"); #endif - RestoreDBTerm(&(dbr->DBT), 1 PASS_REGS); + RestoreDBTerm(&(dbr->DBT), true, 1 PASS_REGS); if (dbr->Parent) { dbr->Parent = (DBProp)AddrAdjust((ADDR)(dbr->Parent)); } @@ -1191,7 +1191,7 @@ static void restore_static_array(StaticArrayEntry *ae USES_REGS) { } else { DBTerm *db = (DBTerm *)RepAppl(reg); db = DBTermAdjust(db); - RestoreDBTerm(db, 1 PASS_REGS); + RestoreDBTerm(db, false, 1 PASS_REGS); base->tstore = AbsAppl((CELL *)db); } } @@ -1209,7 +1209,7 @@ static void restore_static_array(StaticArrayEntry *ae USES_REGS) { base++; } else { *base++ = reg = DBTermAdjust(reg); - RestoreDBTerm(reg, 1 PASS_REGS); + RestoreDBTerm(reg, false, 1 PASS_REGS); } } }