diff --git a/C/agc.c b/C/agc.c index 77fe0149b..2ab2dd5dd 100644 --- a/C/agc.c +++ b/C/agc.c @@ -32,7 +32,7 @@ static char SccsId[] = "@(#)agc.c 1.3 3/15/90"; #define errout Yap_stderr #endif -STATIC_PROTO(void RestoreEntries, (PropEntry *)); +STATIC_PROTO(void RestoreEntries, (PropEntry *, int)); STATIC_PROTO(void CleanCode, (PredEntry *)); static int agc_calls; @@ -192,7 +192,7 @@ mark_hash_entry(AtomHashEntry *HashPtr) else fprintf(errout, "Restoring %s\n", at->StrOfAE); #endif - RestoreEntries(RepProp(at->PropsOfAE)); + RestoreEntries(RepProp(at->PropsOfAE), FALSE); atm = at->NextOfAE; at = RepAtom(CleanAtomMarkedBit(atm)); } while (!EndOfPAEntr(at)); diff --git a/C/save.c b/C/save.c index 2d7505061..a476829f6 100644 --- a/C/save.c +++ b/C/save.c @@ -113,7 +113,7 @@ STATIC_PROTO(void RestoreDB, (DBEntry *)); STATIC_PROTO(void CleanClauses, (yamop *, yamop *,PredEntry *)); STATIC_PROTO(void rehash, (CELL *, int, int)); STATIC_PROTO(void CleanCode, (PredEntry *)); -STATIC_PROTO(void RestoreEntries, (PropEntry *)); +STATIC_PROTO(void RestoreEntries, (PropEntry *, int)); STATIC_PROTO(void RestoreFreeSpace, (void)); STATIC_PROTO(void restore_heap, (void)); #ifdef DEBUG_RESTORE3 @@ -1275,7 +1275,7 @@ RestoreAtomList(Atom atm) fprintf(errout, "Restoring %s\n", at->StrOfAE); #endif at->PropsOfAE = PropAdjust(at->PropsOfAE); - RestoreEntries(RepProp(at->PropsOfAE)); + RestoreEntries(RepProp(at->PropsOfAE), FALSE); atm = at->NextOfAE; at->NextOfAE = atm = AtomAdjust(atm); at = RepAtom(atm); diff --git a/H/rheap.h b/H/rheap.h index bd9525a79..abf180b5e 100644 --- a/H/rheap.h +++ b/H/rheap.h @@ -11,8 +11,11 @@ * File: rheap.h * * comments: walk through heap code * * * -* Last rev: $Date: 2008-04-01 15:31:43 $,$Author: vsc $ * +* Last rev: $Date: 2008-04-03 11:34:47 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.91 2008/04/01 15:31:43 vsc +* more saved state fixes +* * Revision 1.90 2008/04/01 14:09:43 vsc * improve restore * @@ -243,13 +246,25 @@ AdjustDBTerm(Term trm, Term *p_base) return AtomTermAdjust(trm); if (IsPairTerm(trm)) { Term *p; + Term out; p = PtoHeapCellAdjust(RepPair(trm)); + out = AbsPair(p); + loop: if (p >= p_base) { p[0] = AdjustDBTerm(p[0], p); - p[1] = AdjustDBTerm(p[1], p); + if (IsPairTerm(p[1])) { + /* avoid term recursion with very deep lists */ + Term *newp = PtoHeapCellAdjust(RepPair(p[1])); + p[1] = AbsPair(newp); + p_base = p; + p = newp; + goto loop; + } else { + p[1] = AdjustDBTerm(p[1], p); + } } - return AbsPair(p); + return out; } if (IsApplTerm(trm)) { Term *p; @@ -600,7 +615,7 @@ restore_codes(void) for (i = 0; i < Yap_heap_regs->int_keys_size; i++) { if (Yap_heap_regs->IntKeys[i] != NIL) { Prop p0 = Yap_heap_regs->IntKeys[i] = PropAdjust(Yap_heap_regs->IntKeys[i]); - RestoreEntries(RepProp(p0)); + RestoreEntries(RepProp(p0), TRUE); } } } @@ -632,7 +647,7 @@ restore_codes(void) for (i = 0; i < Yap_heap_regs->int_bb_keys_size; i++) { if (Yap_heap_regs->IntBBKeys[i] != NIL) { Prop p0 = Yap_heap_regs->IntBBKeys[i] = PropAdjust(Yap_heap_regs->IntBBKeys[i]); - RestoreEntries(RepProp(p0)); + RestoreEntries(RepProp(p0), TRUE); } } } @@ -1004,7 +1019,7 @@ CleanClauses(yamop *First, yamop *Last, PredEntry *pp) /* Restores a DB structure, as it was saved in the heap */ static void -RestoreBB(BlackBoardEntry *pp) +RestoreBB(BlackBoardEntry *pp, int int_key) { Term t = pp->Element; if (t) { @@ -1018,7 +1033,9 @@ RestoreBB(BlackBoardEntry *pp) } } } - pp->KeyOfBB = AtomAdjust(pp->KeyOfBB); + if (!int_key) { + pp->KeyOfBB = AtomAdjust(pp->KeyOfBB); + } } static void @@ -1247,7 +1264,7 @@ CleanCode(PredEntry *pp) * if we find code or data bases */ static void -RestoreEntries(PropEntry *pp) +RestoreEntries(PropEntry *pp, int int_key) { while (!EndOfPAEntr(pp)) { switch(pp->KindOfPE) { @@ -1339,7 +1356,7 @@ RestoreEntries(PropEntry *pp) BlackBoardEntry *bb = (BlackBoardEntry *) pp; bb->NextOfPE = PropAdjust(bb->NextOfPE); - RestoreBB(bb); + RestoreBB(bb, int_key); } break; case GlobalProperty: