cut should know about environment size.

This commit is contained in:
ubu32 2011-02-14 06:57:16 -08:00
parent 09f4810b76
commit 1717b113b3
7 changed files with 31 additions and 20 deletions

View File

@ -2212,7 +2212,7 @@ Yap_absmi(int inp)
\************************************************************************/
/* cut */
Op(cut, e);
Op(cut, s);
#ifdef COROUTINING
if (FALSE) {
CACHE_Y_AS_ENV(YREG);
@ -2221,7 +2221,7 @@ Yap_absmi(int inp)
}
do_cut:
#endif
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, e),Osbpp),l);
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, s),Osbpp),l);
{
choiceptr d0;
/* assume cut is always in stack */
@ -2230,6 +2230,9 @@ Yap_absmi(int inp)
{
if (SHOULD_CUT_UP_TO(B,d0))
{
ASP = (CELL *) (((char *) YREG) + PREG->u.s.s);
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
while (POP_CHOICE_POINT(d0))
{
POP_EXECUTE();
@ -2260,7 +2263,7 @@ Yap_absmi(int inp)
/* cut_t */
/* cut_t does the same as cut */
Op(cut_t, e);
Op(cut_t, s);
#ifdef COROUTINING
if (FALSE) {
CACHE_Y_AS_ENV(YREG);
@ -2269,7 +2272,7 @@ Yap_absmi(int inp)
}
do_cut_t:
#endif
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, e),Osbpp),l);
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, s),Osbpp),l);
{
choiceptr d0;
@ -2277,6 +2280,9 @@ Yap_absmi(int inp)
d0 = (choiceptr)YREG[E_CB];
#ifdef CUT_C
{
ASP = (CELL *) (((char *) YREG) + PREG->u.s.s);
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
if (SHOULD_CUT_UP_TO(B,d0))
{
while (POP_CHOICE_POINT(d0))
@ -2323,7 +2329,7 @@ Yap_absmi(int inp)
ENDOp();
/* cut_e */
Op(cut_e, e);
Op(cut_e, s);
#ifdef COROUTINING
if (FALSE) {
CACHE_Y_AS_ENV(YREG);
@ -2332,7 +2338,7 @@ Yap_absmi(int inp)
}
do_cut_e:
#endif
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, e),Osbpp),l);
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, s),Osbpp),l);
{
choiceptr d0;
/* we assume dealloc leaves in S the previous env */
@ -2341,6 +2347,9 @@ Yap_absmi(int inp)
{
if (SHOULD_CUT_UP_TO(B,d0))
{
ASP = (CELL *) (((char *) YREG) + PREG->u.s.s);
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
ASP = (CELL *)PROTECT_FROZEN_B(B);
while (POP_CHOICE_POINT(d0))
{
POP_EXECUTE();

View File

@ -2027,11 +2027,11 @@ a_cut(clause_info *clinfo, yamop *code_p, int pass_no, struct intermediates *cip
{
code_p = check_alloc(clinfo, code_p, pass_no, cip);
if (clinfo->dealloc_found) {
return a_e(_cut_e, code_p, pass_no);
return a_n(_cut_e, -Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2, code_p, pass_no);
} else if (clinfo->alloc_found == 1) {
return a_e(_cut, code_p, pass_no);
return a_n(_cut, -Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2, code_p, pass_no);
} else {
return a_e(_cut_t, code_p, pass_no);
return a_n(_cut_t, -Signed(RealEnvSize) - CELLSIZE * cip->cpc->rnd2, code_p, pass_no);
}
}

View File

@ -1296,7 +1296,7 @@ c_bifun(basic_preds Op, Term t1, Term t2, Term t3, Term Goal, Term mod, compiler
} else {
/* generate code for a temp and then unify temp with previous variable */
Yap_emit(f_0_op, 0, (unsigned int)Op, &cglobs->cint);
/* I have to dit here, before I do the unification */
/* I have to do it here, before I do the unification */
if (Op == _functor) {
Yap_emit(empty_call_op, Zero, (unsigned int)Op, &cglobs->cint);
Yap_emit(restore_tmps_and_skip_op, Zero, Zero, &cglobs->cint);

View File

@ -32,9 +32,9 @@
OPCODE(retry_and_mark ,Otapl),
OPCODE(trust_fail ,e),
OPCODE(op_fail ,e),
OPCODE(cut ,e),
OPCODE(cut_t ,e),
OPCODE(cut_e ,e),
OPCODE(cut ,s),
OPCODE(cut_t ,s),
OPCODE(cut_e ,s),
OPCODE(save_b_x ,x),
OPCODE(save_b_y ,y),
OPCODE(commit_b_x ,xp),

View File

@ -40,7 +40,9 @@ struct cut_c_str{
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.f; \
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->u.OtapFs.p; \
YAP_Execute(pred,func); \
Yap_StartSlots(); \
YAP_ExecuteOnCut(pred,func); \
Yap_CloseSlots(); \
cut_c_pop();

View File

@ -217,9 +217,6 @@ restore_opcodes(yamop *pc, yamop *max)
case _Nstop:
case _allocate:
case _copy_idb_term:
case _cut:
case _cut_e:
case _cut_t:
case _expand_index:
case _index_blob:
case _index_dbref:
@ -484,6 +481,9 @@ restore_opcodes(yamop *pc, yamop *max)
pc = NEXTOP(pc,pp);
break;
/* instructions type s */
case _cut:
case _cut_e:
case _cut_t:
case _pop_n:
case _write_n_voids:
pc->u.s.s = ConstantAdjust(pc->u.s.s);

View File

@ -166,9 +166,6 @@
case _unify_idb_term:
return found_idb_clause(pc, startp, endp);
case _allocate:
case _cut:
case _cut_e:
case _cut_t:
case _index_blob:
case _index_dbref:
case _index_long:
@ -375,6 +372,9 @@
pc = NEXTOP(pc,pp);
break;
/* instructions type s */
case _cut:
case _cut_e:
case _cut_t:
case _pop_n:
case _write_n_voids:
pc = NEXTOP(pc,s);