make sure we have enough room before we enter a clause.
This commit is contained in:
parent
3d6e223dae
commit
ffc094e25f
15
C/absmi.c
15
C/absmi.c
@ -1675,18 +1675,21 @@ Yap_absmi(int inp)
|
|||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
|
|
||||||
/* ensure_space */
|
/* ensure_space */
|
||||||
BOp(ensure_space, ip);
|
BOp(ensure_space, Osbpi);
|
||||||
{
|
{
|
||||||
Int sz = PREG->u.ip.i;
|
Int sz = PREG->u.Osbpi.i;
|
||||||
fprintf(stderr,"ensuring %ld\n", sz);
|
PREG = NEXTOP(PREG,Osbpi);
|
||||||
PREG = NEXTOP(PREG,ip);
|
|
||||||
if (Unsigned(H) + sz > Unsigned(YREG)-CreepFlag) {
|
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;
|
ASP = YREG+E_CB;
|
||||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||||
saveregs();
|
saveregs();
|
||||||
if (!Yap_gcl(sz, 0, ENV, NEXTOP(PREG,ip))) {
|
if (!Yap_gcl(sz, 0, YENV, PREG)) {
|
||||||
PREG = NEXTOP(PREG,ip);
|
|
||||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||||
setregs();
|
setregs();
|
||||||
FAIL();
|
FAIL();
|
||||||
|
10
C/amasm.c
10
C/amasm.c
@ -1098,13 +1098,15 @@ a_blob(CELL rnd1, op_numbers opcode, int *clause_has_blobsp, yamop *code_p, int
|
|||||||
static yamop *
|
static yamop *
|
||||||
a_ensure_space(op_numbers opcode, yamop *code_p, int pass_no, struct intermediates *cip, clause_info *clinfo)
|
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) {
|
if (pass_no) {
|
||||||
code_p->opc = emit_op(opcode);
|
code_p->opc = emit_op(opcode);
|
||||||
code_p->u.ip.i = sizeof(CELL) * cip->cpc->rnd1;
|
code_p->u.Osbpi.i = sizeof(CELL) * cip->cpc->rnd1;
|
||||||
code_p->u.ip.p = clinfo->CurrentPred;
|
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;
|
return code_p;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
OPCODE(alloc_for_logical_pred ,L),
|
OPCODE(alloc_for_logical_pred ,L),
|
||||||
OPCODE(copy_idb_term ,e),
|
OPCODE(copy_idb_term ,e),
|
||||||
OPCODE(unify_idb_term ,e),
|
OPCODE(unify_idb_term ,e),
|
||||||
OPCODE(ensure_space ,ip),
|
OPCODE(ensure_space ,Osbpi),
|
||||||
OPCODE(spy_or_trymark ,Otapl),
|
OPCODE(spy_or_trymark ,Otapl),
|
||||||
OPCODE(try_and_mark ,Otapl),
|
OPCODE(try_and_mark ,Otapl),
|
||||||
OPCODE(count_retry_and_mark ,Otapl),
|
OPCODE(count_retry_and_mark ,Otapl),
|
||||||
|
10
H/amidefs.h
10
H/amidefs.h
@ -654,6 +654,16 @@ typedef struct yami {
|
|||||||
struct {
|
struct {
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
unsigned int or_arg;
|
unsigned int or_arg;
|
||||||
|
#endif
|
||||||
|
COUNT s;
|
||||||
|
CELL *bmap;
|
||||||
|
struct pred_entry *p;
|
||||||
|
Int i;
|
||||||
|
CELL next;
|
||||||
|
} Osbpi;
|
||||||
|
struct {
|
||||||
|
#ifdef YAPOR
|
||||||
|
unsigned int or_arg;
|
||||||
#endif
|
#endif
|
||||||
COUNT s;
|
COUNT s;
|
||||||
CELL *bmap;
|
CELL *bmap;
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
case _alloc_for_logical_pred:
|
case _alloc_for_logical_pred:
|
||||||
cl = NEXTOP(cl,L);
|
cl = NEXTOP(cl,L);
|
||||||
break;
|
break;
|
||||||
|
case _ensure_space:
|
||||||
|
cl = NEXTOP(cl,Osbpi);
|
||||||
|
break;
|
||||||
case _native_me:
|
case _native_me:
|
||||||
cl = NEXTOP(cl,aFlp);
|
cl = NEXTOP(cl,aFlp);
|
||||||
break;
|
break;
|
||||||
@ -289,9 +292,6 @@
|
|||||||
case _write_longint:
|
case _write_longint:
|
||||||
cl = NEXTOP(cl,i);
|
cl = NEXTOP(cl,i);
|
||||||
break;
|
break;
|
||||||
case _ensure_space:
|
|
||||||
cl = NEXTOP(cl,ip);
|
|
||||||
break;
|
|
||||||
case _unify_l_list:
|
case _unify_l_list:
|
||||||
cl = NEXTOP(cl,o);
|
cl = NEXTOP(cl,o);
|
||||||
break;
|
break;
|
||||||
|
20
H/rclause.h
20
H/rclause.h
@ -44,10 +44,16 @@ restore_opcodes(yamop *pc, yamop *max)
|
|||||||
case _p_execute:
|
case _p_execute:
|
||||||
OrArgAdjust(pc->u.Osbmp.or_arg);
|
OrArgAdjust(pc->u.Osbmp.or_arg);
|
||||||
pc->u.Osbmp.s = ConstantAdjust(pc->u.Osbmp.s);
|
pc->u.Osbmp.s = ConstantAdjust(pc->u.Osbmp.s);
|
||||||
pc->u.Osbmp.bmap = CellPtoHeapAdjust(pc->u.Osbmp.bmap);
|
pc->u.Osbmp.mod = CellPtoHeapAdjust(pc->u.Osbmp.mod);
|
||||||
pc->u.Osbmp.mod = ModuleAdjust(pc->u.Osbmp.mod);
|
pc->u.Osbmp.p0 = ModuleAdjust(pc->u.Osbmp.p0);
|
||||||
pc->u.Osbmp.p0 = PtoPredAdjust(pc->u.Osbmp.p0);
|
/* instructions type Osbpi */
|
||||||
pc = NEXTOP(pc,Osbmp);
|
case _ensure_space:
|
||||||
|
OrArgAdjust(pc->u.Osbpi.or_arg);
|
||||||
|
pc->u.Osbpi.s = ConstantAdjust(pc->u.Osbpi.s);
|
||||||
|
pc->u.Osbpi.bmap = CellPtoHeapAdjust(pc->u.Osbpi.bmap);
|
||||||
|
pc->u.Osbpi.p = PtoPredAdjust(pc->u.Osbpi.p);
|
||||||
|
IntegerInCodeAdjust(pc->u.Osbpi.i);
|
||||||
|
pc = NEXTOP(pc,Osbpi);
|
||||||
break;
|
break;
|
||||||
/* instructions type Osbpp */
|
/* instructions type Osbpp */
|
||||||
case _call:
|
case _call:
|
||||||
@ -240,12 +246,6 @@ restore_opcodes(yamop *pc, yamop *max)
|
|||||||
IntegerInCodeAdjust(pc->u.i.i);
|
IntegerInCodeAdjust(pc->u.i.i);
|
||||||
pc = NEXTOP(pc,i);
|
pc = NEXTOP(pc,i);
|
||||||
break;
|
break;
|
||||||
/* instructions type ip */
|
|
||||||
case _ensure_space:
|
|
||||||
IntegerInCodeAdjust(pc->u.ip.i);
|
|
||||||
pc->u.ip.p = PtoPredAdjust(pc->u.ip.p);
|
|
||||||
pc = NEXTOP(pc,ip);
|
|
||||||
break;
|
|
||||||
/* instructions type l */
|
/* instructions type l */
|
||||||
case _Ystop:
|
case _Ystop:
|
||||||
case _jump:
|
case _jump:
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
case _p_execute:
|
case _p_execute:
|
||||||
pc = NEXTOP(pc,Osbmp);
|
pc = NEXTOP(pc,Osbmp);
|
||||||
break;
|
break;
|
||||||
|
/* instructions type Osbpi */
|
||||||
|
case _ensure_space:
|
||||||
|
pc = NEXTOP(pc,Osbpi);
|
||||||
|
break;
|
||||||
/* instructions type Osbpp */
|
/* instructions type Osbpp */
|
||||||
case _call_cpred:
|
case _call_cpred:
|
||||||
pp = pc->u.Osbpp.p;
|
pp = pc->u.Osbpp.p;
|
||||||
@ -184,10 +188,6 @@
|
|||||||
case _write_longint:
|
case _write_longint:
|
||||||
pc = NEXTOP(pc,i);
|
pc = NEXTOP(pc,i);
|
||||||
break;
|
break;
|
||||||
/* instructions type ip */
|
|
||||||
case _ensure_space:
|
|
||||||
pc = NEXTOP(pc,ip);
|
|
||||||
break;
|
|
||||||
/* instructions type l */
|
/* instructions type l */
|
||||||
case _Ystop:
|
case _Ystop:
|
||||||
return found_ystop(pc, clause_code, startp, endp, pp);
|
return found_ystop(pc, clause_code, startp, endp, pp);
|
||||||
|
Reference in New Issue
Block a user