make sure we have enough room before we enter a clause.

This commit is contained in:
Vítor Santos Costa
2010-08-02 18:20:03 +01:00
parent 3d6e223dae
commit ffc094e25f
7 changed files with 43 additions and 28 deletions

View File

@@ -1675,18 +1675,21 @@ Yap_absmi(int inp)
*****************************************************************/
/* ensure_space */
BOp(ensure_space, ip);
BOp(ensure_space, Osbpi);
{
Int sz = PREG->u.ip.i;
fprintf(stderr,"ensuring %ld\n", sz);
PREG = NEXTOP(PREG,ip);
Int sz = PREG->u.Osbpi.i;
PREG = NEXTOP(PREG,Osbpi);
if (Unsigned(H) + sz > Unsigned(YREG)-CreepFlag) {
YENV[E_CP] = (CELL) CPREG;
YENV[E_E] = (CELL) ENV;
#ifdef DEPTH_LIMIT
YENV[E_DEPTH] = DEPTH;
#endif /* DEPTH_LIMIT */
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);
if (!Yap_gcl(sz, 0, YENV, PREG)) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
setregs();
FAIL();

View File

@@ -1098,13 +1098,15 @@ a_blob(CELL rnd1, op_numbers opcode, int *clause_has_blobsp, yamop *code_p, int
static yamop *
a_ensure_space(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip, clause_info *clinfo)
{
if (cip->cpc->rnd1 > 4096 && FALSE) {
if (cip->cpc->rnd1 > 4096) {
if (pass_no) {
code_p->opc = emit_op(opcode);
code_p->u.ip.i = sizeof(CELL) * cip->cpc->rnd1;
code_p->u.ip.p = clinfo->CurrentPred;
code_p->u.Osbpi.i = sizeof(CELL) * cip->cpc->rnd1;
code_p->u.Osbpi.p = clinfo->CurrentPred;
code_p->u.Osbpi.bmap = NULL;
code_p->u.Osbpi.s = emit_count(-Signed(RealEnvSize));
}
GONEXT(ip);
GONEXT(Osbpi);
}
return code_p;
}