improve restore

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2184 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2008-04-01 14:09:43 +00:00
parent 80689e734d
commit f37bc03304
4 changed files with 35 additions and 17 deletions

View File

@ -1435,7 +1435,7 @@ growstack(long size)
fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000); fprintf(Yap_stderr, "%% took %g sec\n", (double)growth_time/1000);
fprintf(Yap_stderr, "%% Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000); fprintf(Yap_stderr, "%% Total of %g sec expanding stacks \n", (double)total_stack_overflow_time/1000);
} }
return(TRUE); return TRUE;
} }
/* Used by parser when we're short of stack space */ /* Used by parser when we're short of stack space */

View File

@ -622,13 +622,18 @@ Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def,
pe->ModuleOfPred = CurrentModule; pe->ModuleOfPred = CurrentModule;
if (def != NULL) { if (def != NULL) {
yamop *p_code = ((StaticClause *)NULL)->ClCode; yamop *p_code = ((StaticClause *)NULL)->ClCode;
StaticClause *cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),p),l)); StaticClause *cl;
if (!cl) { if (pe->CodeOfPred == (yamop *)(&(pe->OpcodeOfPred))) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitAsmPred"); cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),p),l));
return; if (!cl) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitAsmPred");
return;
}
Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),p),l);
} else {
cl = ClauseCodeToStaticClause(pe->CodeOfPred);
} }
Yap_ClauseSpace += (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),p),l);
cl->ClFlags = StaticMask; cl->ClFlags = StaticMask;
cl->ClNext = NULL; cl->ClNext = NULL;
cl->ClSize = (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),e),e); cl->ClSize = (CELL)NEXTOP(NEXTOP(NEXTOP(((yamop *)p_code),sla),e),e);

View File

@ -1286,15 +1286,21 @@ RestoreAtomList(Atom atm)
static void static void
RestoreHashPreds(void) RestoreHashPreds(void)
{ {
UInt new_size = PredHashTableSize; UInt size = PredHashTableSize;
PredEntry **oldp = (PredEntry **)AddrAdjust((ADDR)PredHash); int malloced = FALSE;
PredEntry **np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry **)*new_size); PredEntry **np;
UInt i; UInt i;
PredEntry **oldp = PredHash = (PredEntry **)AddrAdjust((ADDR)PredHash);
np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry **)*size);
if (!np) { if (!np) {
Yap_Error(FATAL_ERROR,TermNil,"Could not allocate space for pred table"); if (!(np = (PredEntry **) malloc(sizeof(PredEntry **)*size))) {
Yap_Error(FATAL_ERROR,TermNil,"Could not allocate space for pred table");
return;
}
malloced = TRUE;
} }
for (i = 0; i < new_size; i++) { for (i = 0; i < size; i++) {
np[i] = NULL; np[i] = NULL;
} }
for (i = 0; i < PredHashTableSize; i++) { for (i = 0; i < PredHashTableSize; i++) {
@ -1310,15 +1316,19 @@ RestoreHashPreds(void)
p->NextOfPE = PropAdjust(p->NextOfPE); p->NextOfPE = PropAdjust(p->NextOfPE);
nextp = p->NextOfPE; nextp = p->NextOfPE;
CleanCode(p); CleanCode(p);
hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, new_size); hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, size);
p->NextOfPE = AbsPredProp(np[hsh]); p->NextOfPE = AbsPredProp(np[hsh]);
np[hsh] = p; np[hsh] = p;
p = RepPredProp(nextp); p = RepPredProp(nextp);
} }
} }
PredHashTableSize = new_size; for (i = 0; i < size; i++) {
PredHash = np; PredHash[i] = np[i];
Yap_FreeAtomSpace((ADDR)oldp); }
if (malloced)
free((ADDR)np);
else
Yap_FreeAtomSpace((ADDR)np);
} }

View File

@ -11,8 +11,11 @@
* File: rheap.h * * File: rheap.h *
* comments: walk through heap code * * comments: walk through heap code *
* * * *
* Last rev: $Date: 2008-04-01 09:41:05 $,$Author: vsc $ * * Last rev: $Date: 2008-04-01 14:09:43 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.89 2008/04/01 09:41:05 vsc
* more fixes to restore
*
* Revision 1.88 2008/04/01 08:42:46 vsc * Revision 1.88 2008/04/01 08:42:46 vsc
* fix restore and small VISTA thingies * fix restore and small VISTA thingies
* *
@ -435,7 +438,7 @@ restore_codes(void)
{ {
Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop); Yap_heap_regs->heap_top = AddrAdjust(OldHeapTop);
if (Yap_heap_regs->heap_lim) { if (Yap_heap_regs->heap_lim) {
Yap_heap_regs->heap_lim = AddrAdjust(Yap_heap_regs->heap_lim); Yap_heap_regs->heap_lim = GlobalAddrAdjust(Yap_heap_regs->heap_lim);
} }
#ifdef YAPOR #ifdef YAPOR
Yap_heap_regs->seq_def = TRUE; Yap_heap_regs->seq_def = TRUE;