fix bad instruction format

This commit is contained in:
Vítor Santos Costa 2013-11-01 08:26:06 +00:00
parent 4b64eafc3d
commit 6f9b8bfca8
9 changed files with 95 additions and 29 deletions

View File

@ -7975,11 +7975,6 @@ Yap_absmi(int inp)
JMPNext(); JMPNext();
} }
} }
if (!LOCAL_DebugOn) {
PREG = pe->cs.p_code.TrueCodeOfPred;
UNLOCKPE(24,pe);
JMPNext();
}
UNLOCKPE(25,pe); UNLOCKPE(25,pe);
d0 = pe->ArityOfPE; d0 = pe->ArityOfPE;
@ -12641,23 +12636,23 @@ Yap_absmi(int inp)
ENDD(d0); ENDD(d0);
ENDOp(); ENDOp();
Op(p_func2s_y_cv, yxn); Op(p_func2s_y_cv, yxc);
/* A1 is a variable */ /* A1 is a variable */
restart_func2s_y_cv: restart_func2s_y_cv:
#ifdef LOW_LEVEL_TRACER #ifdef LOW_LEVEL_TRACER
if (Yap_do_low_level_trace) { if (Yap_do_low_level_trace) {
RESET_VARIABLE(H); RESET_VARIABLE(H);
H[1] = PREG->u.yxn.c; H[1] = PREG->u.yxc.c;
H[2] = XREG(PREG->u.yxn.xi); H[2] = XREG(PREG->u.yxc.xi);
low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(FunctorFunctor,0)),H); low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(FunctorFunctor,0)),H);
} }
#endif /* LOW_LEVEL_TRACE */ #endif /* LOW_LEVEL_TRACE */
/* We have to build the structure */ /* We have to build the structure */
BEGD(d0); BEGD(d0);
d0 = PREG->u.yxn.c; d0 = PREG->u.yxc.c;
/* we do, let's get the third argument */ /* we do, let's get the third argument */
BEGD(d1); BEGD(d1);
d1 = XREG(PREG->u.yxn.xi); d1 = XREG(PREG->u.yxc.xi);
deref_head(d1, func2s_y_unk_cv); deref_head(d1, func2s_y_unk_cv);
func2s_y_nvar_cv: func2s_y_nvar_cv:
/* Uuuff, the second and third argument are bound */ /* Uuuff, the second and third argument are bound */
@ -12683,8 +12678,8 @@ Yap_absmi(int inp)
/* else if arity is 0 just pass d0 through */ /* else if arity is 0 just pass d0 through */
/* Ding, ding, we made it */ /* Ding, ding, we made it */
BEGP(pt1); BEGP(pt1);
pt1 = YREG + PREG->u.yxn.y; pt1 = YREG + PREG->u.yxc.y;
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, yxn),Osbpp),l); PREG = NEXTOP(NEXTOP(NEXTOP(PREG, yxc),Osbpp),l);
INITIALIZE_PERMVAR(pt1,d0); INITIALIZE_PERMVAR(pt1,d0);
ENDP(pt1); ENDP(pt1);
GONext(); GONext();
@ -12709,7 +12704,7 @@ Yap_absmi(int inp)
if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) { if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) {
/* make sure we have something to show for our trouble */ /* make sure we have something to show for our trouble */
saveregs(); saveregs();
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxn),Osbpp))) { if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxc),Osbpp))) {
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage); Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
setregs(); setregs();
JMPNext(); JMPNext();
@ -12728,15 +12723,15 @@ Yap_absmi(int inp)
/* else if arity is 0 just pass d0 through */ /* else if arity is 0 just pass d0 through */
/* Ding, ding, we made it */ /* Ding, ding, we made it */
BEGP(pt1); BEGP(pt1);
pt1 = YREG + PREG->u.yxn.y; pt1 = YREG + PREG->u.yxc.y;
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, yxn),Osbpp),l); PREG = NEXTOP(NEXTOP(NEXTOP(PREG, yxc),Osbpp),l);
INITIALIZE_PERMVAR(pt1,d0); INITIALIZE_PERMVAR(pt1,d0);
ENDP(pt1); ENDP(pt1);
GONext(); GONext();
} else if (d1 == 0) { } else if (d1 == 0) {
BEGP(pt1); BEGP(pt1);
pt1 = YREG + PREG->u.yxn.y; pt1 = YREG + PREG->u.yxc.y;
PREG = NEXTOP(NEXTOP(NEXTOP(PREG, yxn),Osbpp),l); PREG = NEXTOP(NEXTOP(NEXTOP(PREG, yxc),Osbpp),l);
INITIALIZE_PERMVAR(pt1,d0); INITIALIZE_PERMVAR(pt1,d0);
ENDP(pt1); ENDP(pt1);
GONext(); GONext();

View File

@ -359,7 +359,6 @@ typedef enum
HALT_AFTER_CONSULT_FLAG = 15, HALT_AFTER_CONSULT_FLAG = 15,
FAST_BOOT_FLAG = 16, FAST_BOOT_FLAG = 16,
STACK_DUMP_ON_ERROR_FLAG = 17, STACK_DUMP_ON_ERROR_FLAG = 17,
GENERATE_DEBUG_INFO_FLAG = 18,
INDEXING_MODE_FLAG = 19, INDEXING_MODE_FLAG = 19,
TABLING_MODE_FLAG = 20, TABLING_MODE_FLAG = 20,
VARS_CAN_HAVE_QUOTE_FLAG = 21, VARS_CAN_HAVE_QUOTE_FLAG = 21,

View File

@ -322,7 +322,7 @@
OPCODE(p_func2s_cv ,xxc), OPCODE(p_func2s_cv ,xxc),
OPCODE(p_func2s_vc ,xxn), OPCODE(p_func2s_vc ,xxn),
OPCODE(p_func2s_y_vv ,yxx), OPCODE(p_func2s_y_vv ,yxx),
OPCODE(p_func2s_y_cv ,yxn), OPCODE(p_func2s_y_cv ,yxc),
OPCODE(p_func2s_y_vc ,yxn), OPCODE(p_func2s_y_vc ,yxn),
OPCODE(p_func2f_xx ,xxx), OPCODE(p_func2f_xx ,xxx),
OPCODE(p_func2f_xy ,xxy), OPCODE(p_func2f_xy ,xxy),

View File

@ -254,6 +254,7 @@ typedef enum {
The meaning and type of the symbols in a abstract machine instruction is: The meaning and type of the symbols in a abstract machine instruction is:
A: Atom
b: arity (Int) b: arity (Int)
b: bitmap (CELL *) b: bitmap (CELL *)
c: constant, is a Term c: constant, is a Term
@ -864,6 +865,12 @@ typedef struct yami {
Int c; Int c;
CELL next; CELL next;
} yxn; } yxn;
struct {
yslot y;
wamreg xi;
Term c;
CELL next;
} yxc;
} u; } u;
} yamop; } yamop;

View File

@ -1317,6 +1317,13 @@
} }
cl = NEXTOP(cl,yx); cl = NEXTOP(cl,yx);
break; break;
case _p_func2s_y_cv:
if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.yxc.y))) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,yxc);
break;
case _p_and_y_vc: case _p_and_y_vc:
if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.yxn.y))) { if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.yxn.y))) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
@ -1345,13 +1352,6 @@
} }
cl = NEXTOP(cl,yxn); cl = NEXTOP(cl,yxn);
break; break;
case _p_func2s_y_cv:
if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.yxn.y))) {
clause->Tag = (CELL)NULL;
return;
}
cl = NEXTOP(cl,yxn);
break;
case _p_func2s_y_vc: case _p_func2s_y_vc:
if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.yxn.y))) { if (!(nofregs = delete_regcopy(myregs, nofregs, cl->u.yxn.y))) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;

View File

@ -106,6 +106,11 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
pc->u.OtaLl.n = PtoOpAdjust(pc->u.OtaLl.n); pc->u.OtaLl.n = PtoOpAdjust(pc->u.OtaLl.n);
pc = pc->u.OtaLl.n; pc = pc->u.OtaLl.n;
break; break;
pc->u.OtaLl.s = AtomAdjust(pc->u.OtaLl.s);
pc->u.OtaLl.d = PtoLUClauseAdjust(pc->u.OtaLl.d);
pc->u.OtaLl.n = PtoOpAdjust(pc->u.OtaLl.n);
pc = pc->u.OtaLl.n;
break;
/* instructions type OtapFs */ /* instructions type OtapFs */
#ifdef CUT_C #ifdef CUT_C
case _cut_c: case _cut_c:
@ -750,12 +755,18 @@ restore_opcodes(yamop *pc, yamop *max USES_REGS)
pc->u.yx.x = XAdjust(pc->u.yx.x); pc->u.yx.x = XAdjust(pc->u.yx.x);
pc = NEXTOP(pc,yx); pc = NEXTOP(pc,yx);
break; break;
/* instructions type yxc */
case _p_func2s_y_cv:
pc->u.yxc.y = YAdjust(pc->u.yxc.y);
pc->u.yxc.xi = XAdjust(pc->u.yxc.xi);
pc->u.yxc.c = ConstantTermAdjust(pc->u.yxc.c);
pc = NEXTOP(pc,yxc);
break;
/* instructions type yxn */ /* instructions type yxn */
case _p_and_y_vc: case _p_and_y_vc:
case _p_arg_y_cv: case _p_arg_y_cv:
case _p_div_y_cv: case _p_div_y_cv:
case _p_div_y_vc: case _p_div_y_vc:
case _p_func2s_y_cv:
case _p_func2s_y_vc: case _p_func2s_y_vc:
case _p_minus_y_cv: case _p_minus_y_cv:
case _p_or_y_vc: case _p_or_y_vc:

View File

@ -70,6 +70,9 @@
CHECK(save_Arity(stream, pc->u.Osbpa.i)); CHECK(save_Arity(stream, pc->u.Osbpa.i));
pc = NEXTOP(pc,Osbpa); pc = NEXTOP(pc,Osbpa);
break; break;
CHECK(save_Atom(stream, pc->u.Osbpa.i));
pc = NEXTOP(pc,Osbpa);
break;
/* instructions type Osbpp */ /* instructions type Osbpp */
case _call: case _call:
case _call_cpred: case _call_cpred:
@ -116,6 +119,11 @@
CHECK(save_PtoOp(stream, pc->u.OtaLl.n)); CHECK(save_PtoOp(stream, pc->u.OtaLl.n));
pc = NEXTOP(pc,OtaLl); pc = NEXTOP(pc,OtaLl);
break; break;
CHECK(save_Atom(stream, pc->u.OtaLl.s));
CHECK(save_PtoLUClause(stream, pc->u.OtaLl.d));
CHECK(save_PtoOp(stream, pc->u.OtaLl.n));
pc = NEXTOP(pc,OtaLl);
break;
/* instructions type OtapFs */ /* instructions type OtapFs */
#ifdef CUT_C #ifdef CUT_C
case _cut_c: case _cut_c:
@ -139,6 +147,12 @@
CHECK(save_Constant(stream, pc->u.OtapFs.extra)); CHECK(save_Constant(stream, pc->u.OtapFs.extra));
pc = NEXTOP(pc,OtapFs); pc = NEXTOP(pc,OtapFs);
break; break;
CHECK(save_Atom(stream, pc->u.OtapFs.s));
CHECK(save_PtoPred(stream, pc->u.OtapFs.p));
CHECK(save_ExternalFunction(stream, pc->u.OtapFs.f));
CHECK(save_Constant(stream, pc->u.OtapFs.extra));
pc = NEXTOP(pc,OtapFs);
break;
/* instructions type Otapl */ /* instructions type Otapl */
case _count_retry_and_mark: case _count_retry_and_mark:
case _count_retry_me: case _count_retry_me:
@ -166,6 +180,11 @@
CHECK(save_PtoOp(stream, pc->u.Otapl.d)); CHECK(save_PtoOp(stream, pc->u.Otapl.d));
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
CHECK(save_Atom(stream, pc->u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d));
pc = NEXTOP(pc,Otapl);
break;
/* instructions type aFlp */ /* instructions type aFlp */
case _native_me: case _native_me:
CHECK(save_Arity(stream, pc->u.aFlp.n)); CHECK(save_Arity(stream, pc->u.aFlp.n));
@ -174,6 +193,12 @@
CHECK(save_PtoPred(stream, pc->u.aFlp.p)); CHECK(save_PtoPred(stream, pc->u.aFlp.p));
pc = NEXTOP(pc,aFlp); pc = NEXTOP(pc,aFlp);
break; break;
CHECK(save_Atom(stream, pc->u.aFlp.n));
CHECK(save_ExternalFunction(stream, pc->u.aFlp.native));
CHECK(save_PtoOp(stream, pc->u.aFlp.native_next));
CHECK(save_PtoPred(stream, pc->u.aFlp.p));
pc = NEXTOP(pc,aFlp);
break;
/* instructions type c */ /* instructions type c */
case _write_atom: case _write_atom:
CHECK(save_ConstantTerm(stream, pc->u.c.c)); CHECK(save_ConstantTerm(stream, pc->u.c.c));
@ -271,6 +296,9 @@
CHECK(save_Arity(stream, pc->u.fa.a)); CHECK(save_Arity(stream, pc->u.fa.a));
pc = NEXTOP(pc,fa); pc = NEXTOP(pc,fa);
break; break;
CHECK(save_Atom(stream, pc->u.fa.a));
pc = NEXTOP(pc,fa);
break;
/* instructions type i */ /* instructions type i */
case _write_longint: case _write_longint:
CHECK(save_IntegerInCode(stream, pc->u.i.i)); CHECK(save_IntegerInCode(stream, pc->u.i.i));
@ -368,6 +396,9 @@
CHECK(save_Arity(stream, pc->u.ofa.a)); CHECK(save_Arity(stream, pc->u.ofa.a));
pc = NEXTOP(pc,ofa); pc = NEXTOP(pc,ofa);
break; break;
CHECK(save_Atom(stream, pc->u.ofa.a));
pc = NEXTOP(pc,ofa);
break;
/* instructions type oi */ /* instructions type oi */
case _unify_l_longint: case _unify_l_longint:
case _unify_l_longint_write: case _unify_l_longint_write:
@ -608,6 +639,9 @@
CHECK(save_Arity(stream, pc->u.xfa.a)); CHECK(save_Arity(stream, pc->u.xfa.a));
pc = NEXTOP(pc,xfa); pc = NEXTOP(pc,xfa);
break; break;
CHECK(save_Atom(stream, pc->u.xfa.a));
pc = NEXTOP(pc,xfa);
break;
/* instructions type xi */ /* instructions type xi */
case _get_longint: case _get_longint:
case _put_longint: case _put_longint:
@ -766,12 +800,18 @@
CHECK(save_X(stream, pc->u.yx.x)); CHECK(save_X(stream, pc->u.yx.x));
pc = NEXTOP(pc,yx); pc = NEXTOP(pc,yx);
break; break;
/* instructions type yxc */
case _p_func2s_y_cv:
CHECK(save_Y(stream, pc->u.yxc.y));
CHECK(save_X(stream, pc->u.yxc.xi));
CHECK(save_ConstantTerm(stream, pc->u.yxc.c));
pc = NEXTOP(pc,yxc);
break;
/* instructions type yxn */ /* instructions type yxn */
case _p_and_y_vc: case _p_and_y_vc:
case _p_arg_y_cv: case _p_arg_y_cv:
case _p_div_y_cv: case _p_div_y_cv:
case _p_div_y_vc: case _p_div_y_vc:
case _p_func2s_y_cv:
case _p_func2s_y_vc: case _p_func2s_y_vc:
case _p_minus_y_cv: case _p_minus_y_cv:
case _p_or_y_vc: case _p_or_y_vc:
@ -835,6 +875,11 @@
CHECK(save_PtoOp(stream, pc->u.Otapl.d)); CHECK(save_PtoOp(stream, pc->u.Otapl.d));
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
CHECK(save_Atom(stream, pc->u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d));
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */ /* instructions type e */
case _getwork_first_time: case _getwork_first_time:
if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) return 1; if (op == _Nstop || op == _copy_idb_term || op == _unify_idb_term) return 1;
@ -868,6 +913,11 @@
CHECK(save_PtoOp(stream, pc->u.Otapl.d)); CHECK(save_PtoOp(stream, pc->u.Otapl.d));
pc = NEXTOP(pc,Otapl); pc = NEXTOP(pc,Otapl);
break; break;
CHECK(save_Atom(stream, pc->u.Otapl.s));
CHECK(save_PtoPred(stream, pc->u.Otapl.p));
CHECK(save_PtoOp(stream, pc->u.Otapl.d));
pc = NEXTOP(pc,Otapl);
break;
/* instructions type e */ /* instructions type e */
#ifdef TABLING_INNER_CUTS #ifdef TABLING_INNER_CUTS
case _clause_with_cut: case _clause_with_cut:

View File

@ -565,12 +565,15 @@
case _put_y_var: case _put_y_var:
pc = NEXTOP(pc,yx); pc = NEXTOP(pc,yx);
break; break;
/* instructions type yxc */
case _p_func2s_y_cv:
pc = NEXTOP(pc,yxc);
break;
/* instructions type yxn */ /* instructions type yxn */
case _p_and_y_vc: case _p_and_y_vc:
case _p_arg_y_cv: case _p_arg_y_cv:
case _p_div_y_cv: case _p_div_y_cv:
case _p_div_y_vc: case _p_div_y_vc:
case _p_func2s_y_cv:
case _p_func2s_y_vc: case _p_func2s_y_vc:
case _p_minus_y_cv: case _p_minus_y_cv:
case _p_or_y_vc: case _p_or_y_vc:

View File

@ -242,6 +242,7 @@ rewritable_field(0't).
get_op(0'a,"Arity"). get_op(0'a,"Arity").
get_op(0'a,"Atom").
get_op(0'b,"CellPtoHeap"). get_op(0'b,"CellPtoHeap").
get_op(0'c,"ConstantTerm"). get_op(0'c,"ConstantTerm").
get_op(0'd,"DoubleInCode"). get_op(0'd,"DoubleInCode").