fix several bugs in save/restore.b
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1467 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
66
C/save.c
66
C/save.c
@@ -415,6 +415,7 @@ save_regs(int mode)
|
||||
#endif /* SBA || TABLING */
|
||||
}
|
||||
putout(CurrentModule);
|
||||
putcellptr(AuxSp);
|
||||
if (mode == DO_EVERYTHING) {
|
||||
#ifdef COROUTINING
|
||||
putout(WokenGoals);
|
||||
@@ -1001,6 +1002,9 @@ static void
|
||||
restore_regs(int flag)
|
||||
{
|
||||
restore_heap_regs();
|
||||
if (CurrentModule) {
|
||||
CurrentModule = AtomTermAdjust(CurrentModule);;
|
||||
}
|
||||
if (flag == DO_EVERYTHING) {
|
||||
CP = PtoOpAdjust(CP);
|
||||
ENV = PtoLocAdjust(ENV);
|
||||
@@ -1199,62 +1203,20 @@ RestoreIOStructures(void)
|
||||
Yap_InitStdStreams();
|
||||
}
|
||||
|
||||
#if USE_DL_MALLOC
|
||||
static struct malloc_chunk *
|
||||
RestoreFreeChunk(struct malloc_chunk *ptr)
|
||||
{
|
||||
if (ptr->fd) {
|
||||
ptr->fd = ChunkPtrAdjust(ptr->fd);
|
||||
}
|
||||
if (ptr->bk) {
|
||||
ptr->bk = ChunkPtrAdjust(ptr->bk);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
RestoreFreeSpace(void)
|
||||
{
|
||||
#if USE_DL_MALLOC
|
||||
int i;
|
||||
|
||||
Yap_av = (struct malloc_state *)AddrAdjust((ADDR)Yap_av);
|
||||
for (i = 0; i < NFASTBINS; i++) {
|
||||
if (Yap_av->fastbins[i]) {
|
||||
struct malloc_chunk *ptr;
|
||||
|
||||
Yap_av->fastbins[i] = ptr = ChunkPtrAdjust(Yap_av->fastbins[i]);
|
||||
while (ptr) {
|
||||
ptr = RestoreFreeChunk(ptr)->fd;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Yap_av->top) {
|
||||
Yap_av->top = ChunkPtrAdjust(Yap_av->top);
|
||||
}
|
||||
if (Yap_av->last_remainder) {
|
||||
Yap_av->top = ChunkPtrAdjust(Yap_av->last_remainder);
|
||||
}
|
||||
for (i = 0; i < NBINS; i++) {
|
||||
|
||||
struct malloc_chunk *ptr;
|
||||
|
||||
if (Yap_av->bins[i*2]) {
|
||||
Yap_av->bins[i*2] = ptr = ChunkPtrAdjust(Yap_av->bins[i*2]);
|
||||
} else {
|
||||
ptr = NULL;
|
||||
}
|
||||
if (Yap_av->bins[i*2+1]) {
|
||||
Yap_av->bins[i*2+1] = ChunkPtrAdjust(Yap_av->bins[i*2+1]);
|
||||
}
|
||||
while (ptr && ptr != Yap_av->bins[i*2]) {
|
||||
ptr = RestoreFreeChunk(ptr)->fd;
|
||||
}
|
||||
}
|
||||
Yap_RestoreDLMalloc();
|
||||
if (AuxSp != NULL)
|
||||
AuxSp = PtoHeapCellAdjust(AuxSp);
|
||||
if (AuxTop != NULL)
|
||||
AuxTop = AddrAdjust(AuxTop);
|
||||
#else
|
||||
/* restores the list of free space, with its curious structure */
|
||||
register BlockHeader *bpt, *bsz;
|
||||
BlockHeader *bpt, *bsz;
|
||||
|
||||
if (FreeBlocks != NULL)
|
||||
FreeBlocks = BlockAdjust(FreeBlocks);
|
||||
bpt = FreeBlocks;
|
||||
@@ -1525,13 +1487,13 @@ RestoreHeap(OPCODE old_ops[])
|
||||
CurrentModule = PROLOG_MODULE;
|
||||
opcodes_moved = check_opcodes(old_ops);
|
||||
/* opcodes_moved has side-effects and should be tried first */
|
||||
if (heap_moved) {
|
||||
RestoreFreeSpace();
|
||||
}
|
||||
if (heap_moved || opcodes_moved) {
|
||||
restore_heap();
|
||||
}
|
||||
/* This must be done after restore_heap */
|
||||
if (heap_moved) {
|
||||
RestoreFreeSpace();
|
||||
}
|
||||
Yap_InitAbsmi();
|
||||
if (opcodes_moved) {
|
||||
Yap_InitCPreds();
|
||||
|
Reference in New Issue
Block a user