support for space reservation (goal: call gc before trying to insert very large terms).

This commit is contained in:
Vitor Santos Costa
2010-08-02 13:04:30 +01:00
parent 212758d25e
commit 3d6e223dae
13 changed files with 88 additions and 16 deletions

View File

@@ -1670,6 +1670,34 @@ Yap_absmi(int inp)
ENDBOp();
/*****************************************************************
* check for enough room *
*****************************************************************/
/* ensure_space */
BOp(ensure_space, ip);
{
Int sz = PREG->u.ip.i;
fprintf(stderr,"ensuring %ld\n", sz);
PREG = NEXTOP(PREG,ip);
if (Unsigned(H) + sz > Unsigned(YREG)-CreepFlag) {
ASP = YREG+E_CB;
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
saveregs();
if (!Yap_gcl(sz, 0, ENV, NEXTOP(PREG,ip))) {
PREG = NEXTOP(PREG,ip);
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
setregs();
FAIL();
} else {
setregs();
}
}
}
JMPNext();
ENDBOp();
/*****************************************************************
* try and retry of dynamic predicates *
*****************************************************************/