write_depth/3

overflow handlings and garbage collection
Several ipdates to CLPBN
dif/2 could be broken in the presence of attributed variables.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1474 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2005-12-05 17:16:12 +00:00
parent 868f236185
commit 5c2e06ad50
23 changed files with 494 additions and 308 deletions

View File

@@ -10,8 +10,13 @@
* *
* File: absmi.c *
* comments: Portable abstract machine interpreter *
* Last rev: $Date: 2005-11-26 02:57:25 $,$Author: vsc $ *
* Last rev: $Date: 2005-12-05 17:16:10 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.187 2005/11/26 02:57:25 vsc
* improvements to debugger
* overflow fixes
* reading attvars from DB was broken.
*
* Revision 1.186 2005/11/23 03:01:32 vsc
* fix several bugs in save/restore.b
*
@@ -10545,6 +10550,7 @@ Yap_absmi(int inp)
GONext();
}
{
Int opresult;
#ifdef COROUTINING
/*
* We may wake up goals during our attempt to unify the
@@ -10568,24 +10574,21 @@ Yap_absmi(int inp)
B = (choiceptr) H;
SET_BB(B);
save_hb();
if (Yap_IUnify(d0, d1)) {
/* restore B, no need to restore HB */
PREG = PREG->u.l.l;
B = pt1;
opresult = Yap_IUnify(d0, d1);
#ifdef COROUTINING
/* now restore Woken Goals to its old value */
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
if (OldWokenGoals == TermNil) {
Yap_undo_signal(YAP_WAKEUP_SIGNAL);
}
#endif
GONext();
/* now restore Woken Goals to its old value */
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
if (OldWokenGoals == TermNil) {
Yap_undo_signal(YAP_WAKEUP_SIGNAL);
}
/* restore B, and later HB */
PREG = NEXTOP(PREG, l);
#endif
/* restore B */
B = pt1;
SET_BB(PROTECT_FROZEN_B(pt1));
ENDCHO(pt1);
#ifdef COROUTINING
H = HBREG;
#endif
HBREG = B->cp_h;
/* untrail all bindings made by Yap_IUnify */
while (TR != pt0) {
BEGD(d1);
@@ -10616,14 +10619,14 @@ Yap_absmi(int inp)
}
ENDD(d1);
}
HBREG = B->cp_h;
#ifdef COROUTINING
/* now restore Woken Goals to its old value */
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
if (OldWokenGoals == TermNil) {
Yap_undo_signal(YAP_WAKEUP_SIGNAL);
if (opresult) {
/* restore B, no need to restore HB */
PREG = PREG->u.l.l;
GONext();
}
#endif
/* restore B, and later HB */
PREG = NEXTOP(PREG, l);
ENDCHO(pt1);
}
GONext();

View File

@@ -11,8 +11,11 @@
* File: computils.c *
* comments: some useful routines for YAP's compiler *
* *
* Last rev: $Date: 2005-09-08 22:06:44 $ *
* Last rev: $Date: 2005-12-05 17:16:10 $ *
* $Log: not supported by cvs2svn $
* Revision 1.28 2005/09/08 22:06:44 rslopes
* BEAM for YAP update...
*
* Revision 1.27 2005/07/06 15:10:04 vsc
* improvements to compiler: merged instructions and fixes for ->
*
@@ -287,10 +290,10 @@ static void
write_address(CELL address)
{
if (address < (CELL)AtomBase) {
Yap_DebugPutc(Yap_c_error_stream,'L');
Yap_plwrite (MkIntTerm (address), Yap_DebugPutc, 0);
Yap_DebugErrorPutc('L');
Yap_DebugPlWrite (MkIntTerm (address));
} else if (address == (CELL) FAILCODE) {
Yap_plwrite (MkAtomTerm (AtomFail), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm (AtomFail));
} else {
char buf[32], *p = buf;
@@ -300,10 +303,10 @@ write_address(CELL address)
snprintf(buf,"%p",(void *)address);
#endif
p[31] = '\0'; /* so that I don't have to worry */
Yap_DebugPutc(Yap_c_error_stream,'0');
Yap_DebugPutc(Yap_c_error_stream,'x');
Yap_DebugErrorPutc('0');
Yap_DebugErrorPutc('x');
while (*p != '\0') {
Yap_DebugPutc(Yap_c_error_stream,*p++);
Yap_DebugErrorPutc(*p++);
}
}
}
@@ -313,16 +316,16 @@ write_functor(Functor f)
{
if (IsExtensionFunctor(f)) {
if (f == FunctorDBRef) {
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("DBRef")), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkAtomTerm(Yap_LookupAtom("DBRef")));
} else if (f == FunctorLongInt) {
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("LongInt")), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkAtomTerm(Yap_LookupAtom("LongInt")));
} else if (f == FunctorDouble) {
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("Double")), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkAtomTerm(Yap_LookupAtom("Double")));
}
} else {
Yap_plwrite(MkAtomTerm(NameOfFunctor (f)), Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,'/');
Yap_plwrite(MkIntTerm(ArityOfFunctor (f)), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkAtomTerm(NameOfFunctor (f)));
Yap_DebugErrorPutc ('/');
Yap_DebugPlWrite(MkIntTerm(ArityOfFunctor (f)));
}
}
@@ -341,15 +344,15 @@ ShowOp (char *f, struct PSEUDO *cpc)
{
#ifdef BEAM
case '1':
Yap_plwrite(MkIntTerm(rn), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkIntTerm(rn));
break;
case '4':
Yap_plwrite(MkIntTerm(arg), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkIntTerm(arg));
break;
#endif
case 'a':
case 'n':
Yap_plwrite ((Term) arg, Yap_DebugPutc, 0);
Yap_DebugPlWrite ((Term) arg);
break;
case 'b':
/* write a variable bitmap for a call */
@@ -357,7 +360,7 @@ ShowOp (char *f, struct PSEUDO *cpc)
int max = arg/(8*sizeof(CELL)), i;
CELL *ptr = cptr;
for (i = 0; i <= max; i++) {
Yap_plwrite(MkIntegerTerm((Int)(*ptr++)), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkIntegerTerm((Int)(*ptr++)));
}
}
break;
@@ -369,20 +372,20 @@ ShowOp (char *f, struct PSEUDO *cpc)
char s[32];
bip_name(rn,s);
Yap_plwrite (MkAtomTerm(Yap_LookupAtom(s)), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm(Yap_LookupAtom(s)));
}
break;
case 'd':
Yap_plwrite (MkIntTerm (rn), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkIntTerm (rn));
break;
case 'z':
Yap_plwrite (MkIntTerm (cpc->rnd3), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkIntTerm (cpc->rnd3));
break;
case 'v':
{
Ventry *v = (Ventry *) arg;
Yap_DebugPutc (Yap_c_error_stream,v->KindOfVE == PermVar ? 'Y' : 'X');
Yap_plwrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs), Yap_DebugPutc, 0);
Yap_DebugErrorPutc (v->KindOfVE == PermVar ? 'Y' : 'X');
Yap_DebugPlWrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs));
}
break;
case 'N':
@@ -392,13 +395,13 @@ ShowOp (char *f, struct PSEUDO *cpc)
cpc = cpc->nextInst;
arg = cpc->rnd1;
v = (Ventry *) arg;
Yap_DebugPutc (Yap_c_error_stream,v->KindOfVE == PermVar ? 'Y' : 'X');
Yap_plwrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs), Yap_DebugPutc, 0);
Yap_DebugErrorPutc (v->KindOfVE == PermVar ? 'Y' : 'X');
Yap_DebugPlWrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs));
}
case 'm':
Yap_plwrite (MkAtomTerm ((Atom) arg), Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,'/');
Yap_plwrite (MkIntTerm (rn), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm ((Atom) arg));
Yap_DebugErrorPutc ('/');
Yap_DebugPlWrite (MkIntTerm (rn));
break;
case 'p':
{
@@ -411,14 +414,14 @@ ShowOp (char *f, struct PSEUDO *cpc)
mod = p->ModuleOfPred;
else
mod = TermProlog;
Yap_plwrite (mod, Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,':');
Yap_DebugPlWrite (mod);
Yap_DebugErrorPutc (':');
if (arity == 0)
Yap_plwrite (MkAtomTerm ((Atom)f), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm ((Atom)f));
else
Yap_plwrite (MkAtomTerm (NameOfFunctor (f)), Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,'/');
Yap_plwrite (MkIntTerm (arity), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f)));
Yap_DebugErrorPutc ('/');
Yap_DebugPlWrite (MkIntTerm (arity));
}
break;
case 'P':
@@ -429,22 +432,22 @@ ShowOp (char *f, struct PSEUDO *cpc)
Term mod = TermProlog;
if (p->ModuleOfPred) mod = p->ModuleOfPred;
Yap_plwrite (mod, Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,':');
Yap_DebugPlWrite (mod);
Yap_DebugErrorPutc (':');
if (arity == 0)
Yap_plwrite (MkAtomTerm ((Atom)f), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm ((Atom)f));
else
Yap_plwrite (MkAtomTerm (NameOfFunctor (f)), Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,'/');
Yap_plwrite (MkIntTerm (arity), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f)));
Yap_DebugErrorPutc ('/');
Yap_DebugPlWrite (MkIntTerm (arity));
}
break;
case 'f':
write_functor((Functor)arg);
break;
case 'r':
Yap_DebugPutc (Yap_c_error_stream,'A');
Yap_plwrite (MkIntTerm (rn), Yap_DebugPutc, 0);
Yap_DebugErrorPutc ('A');
Yap_DebugPlWrite (MkIntTerm (rn));
break;
case 'h':
{
@@ -463,47 +466,47 @@ ShowOp (char *f, struct PSEUDO *cpc)
Functor fun = (Functor)*cptr++;
if (IsExtensionFunctor(fun)) {
if (fun == FunctorDBRef) {
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("DBRef")), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkAtomTerm(Yap_LookupAtom("DBRef")));
} else if (fun == FunctorLongInt) {
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("LongInt")), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkAtomTerm(Yap_LookupAtom("LongInt")));
} else if (fun == FunctorDouble) {
Yap_plwrite(MkAtomTerm(Yap_LookupAtom("Double")), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkAtomTerm(Yap_LookupAtom("Double")));
}
} else {
Yap_plwrite (MkAtomTerm(NameOfFunctor(fun)), Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,'/');
Yap_plwrite (MkIntTerm(ArityOfFunctor(fun)), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkAtomTerm(NameOfFunctor(fun)));
Yap_DebugErrorPutc ('/');
Yap_DebugPlWrite (MkIntTerm(ArityOfFunctor(fun)));
}
}
break;
case 'O':
Yap_plwrite(AbsAppl(cptr), Yap_DebugPutc, 0);
Yap_DebugPlWrite(AbsAppl(cptr));
break;
case 'x':
Yap_plwrite (MkIntTerm (rn >> 1), Yap_DebugPutc, 0);
Yap_DebugPutc (Yap_c_error_stream,'\t');
Yap_plwrite (MkIntTerm (rn & 1), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkIntTerm (rn >> 1));
Yap_DebugErrorPutc ('\t');
Yap_DebugPlWrite (MkIntTerm (rn & 1));
break;
case 'o':
Yap_plwrite ((Term) * cptr++, Yap_DebugPutc, 0);
Yap_DebugPlWrite ((Term) * cptr++);
case 'c':
{
int i;
CELL *ptr = (CELL *)cptr[0];
for (i = 0; i < arg; ++i) {
CELL my_arg;
Yap_DebugPutc(Yap_c_error_stream,'\t');
Yap_DebugErrorPutc('\t');
if (*ptr) {
Yap_plwrite ((Term) *ptr++, Yap_DebugPutc, 0);
Yap_DebugPlWrite ((Term) *ptr++);
} else {
Yap_plwrite (MkIntTerm (0), Yap_DebugPutc, 0);
Yap_DebugPlWrite (MkIntTerm (0));
ptr++;
}
Yap_DebugPutc (Yap_c_error_stream,'\t');
Yap_DebugErrorPutc ('\t');
my_arg = *ptr++;
write_address (my_arg);
if (i+1 < arg)
Yap_DebugPutc (Yap_c_error_stream,'\n');
Yap_DebugErrorPutc ('\n');
}
}
break;
@@ -513,28 +516,28 @@ ShowOp (char *f, struct PSEUDO *cpc)
CELL *ptr = (CELL *)cptr[0];
for (i = 0; i < arg; ++i) {
CELL my_arg = ptr[0], lbl = ptr[1];
Yap_DebugPutc(Yap_c_error_stream,'\t');
Yap_DebugErrorPutc('\t');
if (my_arg) {
write_functor((Functor)my_arg);
} else {
Yap_plwrite(MkIntTerm (0), Yap_DebugPutc, 0);
Yap_DebugPlWrite(MkIntTerm (0));
}
Yap_DebugPutc(Yap_c_error_stream,'\t');
Yap_DebugErrorPutc('\t');
write_address(lbl);
ptr += 2;
if (i+1 < arg)
Yap_DebugPutc(Yap_c_error_stream,'\n');
Yap_DebugErrorPutc('\n');
}
}
break;
default:
Yap_DebugPutc (Yap_c_error_stream,'%');
Yap_DebugPutc (Yap_c_error_stream,ch);
Yap_DebugErrorPutc ('%');
Yap_DebugErrorPutc (ch);
}
else
Yap_DebugPutc (Yap_c_error_stream,ch);
Yap_DebugErrorPutc (ch);
}
Yap_DebugPutc (Yap_c_error_stream,'\n');
Yap_DebugErrorPutc ('\n');
}
static char *opformat[] =
@@ -729,7 +732,7 @@ Yap_ShowCode (struct intermediates *cint)
}
cpc = cpc->nextInst;
}
Yap_DebugPutc (Yap_c_error_stream,'\n');
Yap_DebugErrorPutc ('\n');
H = oldH;
}

View File

@@ -1793,7 +1793,6 @@ Yap_InitYaamRegs(void)
RESET_VARIABLE((CELL *)Yap_GlobalBase);
DelayedVars = Yap_NewTimedVar(MkIntTerm(0));
WokenGoals = Yap_NewTimedVar(TermNil);
MutableList = Yap_NewTimedVar(TermNil);
AttsMutableList = Yap_NewTimedVar(MkIntTerm(0));
#endif
GcGeneration = Yap_NewTimedVar(MkIntTerm(0));

View File

@@ -159,8 +159,6 @@ SetHeapRegs(void)
#ifdef COROUTINING
if (DelayedVars)
DelayedVars = AbsAppl(PtoGloAdjust(RepAppl(DelayedVars)));
if (MutableList)
MutableList = AbsAppl(PtoGloAdjust(RepAppl(MutableList)));
if (AttsMutableList)
AttsMutableList = AbsAppl(PtoGloAdjust(RepAppl(AttsMutableList)));
if (WokenGoals)
@@ -214,8 +212,6 @@ SetStackRegs(void)
#ifdef COROUTINING
if (DelayedVars)
DelayedVars = AbsAppl(PtoGloAdjust(RepAppl(DelayedVars)));
if (MutableList)
MutableList = AbsAppl(PtoGloAdjust(RepAppl(MutableList)));
if (AttsMutableList)
AttsMutableList = AbsAppl(PtoGloAdjust(RepAppl(AttsMutableList)));
if (WokenGoals)

View File

@@ -401,10 +401,9 @@ push_registers(Int num_regs, yamop *nextop)
TR++;
#ifdef COROUTINING
TrailTerm(TR) = WokenGoals;
TrailTerm(TR+1) = MutableList;
TrailTerm(TR+2) = AttsMutableList;
TrailTerm(TR+3) = DelayedVars;
TR += 4;
TrailTerm(TR+1) = AttsMutableList;
TrailTerm(TR+2) = DelayedVars;
TR += 3;
#endif
for (i = 1; i <= num_regs; i++)
TrailTerm(TR++) = (CELL) XREGS[i];
@@ -465,7 +464,6 @@ pop_registers(Int num_regs, yamop *nextop)
#ifdef COROUTINING
#ifdef MULTI_ASSIGNMENT_VARIABLES
WokenGoals = TrailTerm(ptr++);
MutableList = TrailTerm(ptr++);
AttsMutableList = TrailTerm(ptr++);
DelayedVars = TrailTerm(ptr++);
#endif

View File

@@ -982,8 +982,9 @@ InitCodes(void)
Yap_heap_regs->consultlow + Yap_heap_regs->consultcapacity;
Yap_heap_regs->compiler_compile_mode = 0; /* fast will be for native code */
Yap_heap_regs->compiler_optimizer_on = TRUE;
Yap_heap_regs->maxdepth = 0;
Yap_heap_regs->maxlist = 0;
Yap_heap_regs->maxdepth = 0;
Yap_heap_regs->maxlist = 0;
Yap_heap_regs->maxwriteargs = 0;
Yap_heap_regs->atprompt = 0;
#ifdef COROUTINING

View File

@@ -369,94 +369,107 @@ static Int
p_dif(void)
{ /* ? \= ? */
#if SHADOW_HB
register CELL *HBREG = HB;
register CELL *HBREG = HB;
#endif
BEGD(d0);
BEGD(d0);
BEGD(d1);
d0 = ARG1;
deref_head(d0, dif_unk1);
dif_nvar1:
/* first argument is bound */
d1 = ARG2;
deref_head(d1, dif_nvar1_unk2);
dif_nvar1_nvar2:
/* both arguments are bound */
if (d0 == d1) {
return FALSE;
}
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) {
return TRUE;
} else {
#ifdef COROUTINING
/*
* We may wake up goals during our attempt to unify the
* two terms. If we are adding to the tail of a list of
* woken goals that should be ok, but otherwise we need
* to restore WokenGoals to its previous value.
*/
CELL OldWokenGoals = Yap_ReadTimedVar(WokenGoals);
#endif
register tr_fr_ptr pt0;
/* store the old value of TR for clearing bindings */
pt0 = TR;
BEGCHO(pt1);
pt1 = B;
/* make B and HB point to H to guarantee all bindings will
* be trailed
*/
HBREG = H;
B = (choiceptr) H;
SET_BB(B);
save_hb();
d0 = Yap_IUnify(d0, d1);
#ifdef COROUTINING
/* now restore Woken Goals to its old value */
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
if (OldWokenGoals == TermNil) {
Yap_undo_signal(YAP_WAKEUP_SIGNAL);
}
#endif
/* restore B */
B = pt1;
SET_BB(PROTECT_FROZEN_B(pt1));
#ifdef COROUTINING
H = HBREG;
#endif
HBREG = B->cp_h;
/* untrail all bindings made by Yap_IUnify */
while (TR != pt0) {
BEGD(d1);
d0 = ARG1;
deref_head(d0, dif_unk1);
dif_nvar1:
/* first argument is bound */
d1 = ARG2;
deref_head(d1, dif_nvar1_unk2);
dif_nvar1_nvar2:
/* both arguments are bound */
if (d0 == d1) {
return(FALSE);
}
if (IsAtomOrIntTerm(d0) || IsAtomOrIntTerm(d1)) {
return(TRUE);
}
{
#ifdef COROUTINING
/*
* We may wake up goals during our attempt to unify the
* two terms. If we are adding to the tail of a list of
* woken goals that should be ok, but otherwise we need
* to restore WokenGoals to its previous value.
*/
CELL OldWokenGoals = Yap_ReadTimedVar(WokenGoals);
d1 = TrailTerm(--TR);
if (IsVarTerm(d1)) {
#if defined(SBA) && defined(YAPOR)
/* clean up the trail when we backtrack */
if (Unsigned((Int)(d1)-(Int)(H_FZ)) >
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) {
RESET_VARIABLE(STACK_TO_SBA(d1));
} else
#endif
/* We will have to look inside compound terms */
BEGP(pt0);
/* store the old value of TR for clearing bindings */
pt0 = (CELL *)TR;
BEGCHO(pt1);
pt1 = B;
/* make B and HB point to H to guarantee all bindings will
* be trailed
*/
HBREG = H;
B = (choiceptr) H;
save_hb();
if (Yap_IUnify(d0, d1)) {
/* restore B, no need to restore HB */
B = pt1;
#ifdef COROUTINING
/* now restore Woken Goals to its old value */
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
if (OldWokenGoals == TermNil) {
Yap_undo_signal(YAP_WAKEUP_SIGNAL);
}
#endif
return FALSE;
}
B = pt1;
/* restore B, and later HB */
ENDCHO(pt1);
BEGP(pt1);
/* untrail all bindings made by Yap_IUnify */
while (TR != (tr_fr_ptr)pt0) {
pt1 = (CELL *) TrailTerm(--TR);
RESET_VARIABLE(pt1);
}
HBREG = B->cp_h;
ENDP(pt1);
/* normal variable */
RESET_VARIABLE(d1);
#ifdef MULTI_ASSIGNMENT_VARIABLES
} else /* if (IsApplTerm(d1)) */ {
CELL *pt = RepAppl(d1);
/* AbsAppl means */
/* multi-assignment variable */
/* so the next cell is the old value */
#ifdef FROZEN_STACKS
pt[0] = TrailVal(--TR);
#else
pt[0] = TrailTerm(--TR);
TR--;
#endif /* FROZEN_STACKS */
#endif /* MULTI_ASSIGNMENT_VARIABLES */
}
#ifdef COROUTINING
/* now restore Woken Goals to its old value */
Yap_UpdateTimedVar(WokenGoals, OldWokenGoals);
if (OldWokenGoals == TermNil) {
Yap_undo_signal(YAP_WAKEUP_SIGNAL);
}
#endif
return TRUE;
ENDP(pt0);
BEGP(pt0);
deref_body(d0, pt0, dif_unk1, dif_nvar1);
ENDP(pt0);
/* first argument is unbound */
return(FALSE);
BEGP(pt0);
deref_body(d1, pt0, dif_nvar1_unk2, dif_nvar1_nvar2);
ENDP(pt0);
/* second argument is unbound */
return FALSE;
ENDD(d1);
ENDD(d0);
}
return !d0;
ENDP(pt0);
}
BEGP(pt0);
deref_body(d0, pt0, dif_unk1, dif_nvar1);
ENDP(pt0);
/* first argument is unbound */
return FALSE;
BEGP(pt0);
deref_body(d1, pt0, dif_nvar1_unk2, dif_nvar1_nvar2);
ENDP(pt0);
/* second argument is unbound */
return FALSE;
ENDD(d1);
ENDD(d0);
}
static Int

View File

@@ -608,6 +608,19 @@ Yap_DebugPutc(int sno, int ch)
(void) putc(ch, Yap_logfile);
return (putc(ch, Yap_stderr));
}
void
Yap_DebugPlWrite(Term t)
{
Yap_plwrite(t, Yap_DebugPutc, 0);
}
void
Yap_DebugErrorPutc(int c)
{
Yap_DebugPutc (Yap_c_error_stream, c);
}
#endif
/* static */
@@ -4589,27 +4602,45 @@ p_write_depth (void)
{ /* write_depth(Old,New) */
Term t1 = Deref (ARG1);
Term t2 = Deref (ARG2);
if (!IsVarTerm (t1) && !IsIntTerm (t1))
return (FALSE);
if (!IsVarTerm (t2) && !IsIntTerm (t2))
return (FALSE);
Term t3 = Deref (ARG3);
if (!IsVarTerm (t1) && !IsIntegerTerm (t1)) {
Yap_Error(TYPE_ERROR_INTEGER,t1,"write_depth/3");
return FALSE;
}
if (!IsVarTerm (t2) && !IsIntegerTerm (t2)) {
Yap_Error(TYPE_ERROR_INTEGER,t2,"write_depth/3");
return FALSE;
}
if (!IsVarTerm (t3) && !IsIntegerTerm (t3)) {
Yap_Error(TYPE_ERROR_INTEGER,t3,"write_depth/3");
return FALSE;
}
if (IsVarTerm (t1))
{
Term t = MkIntTerm (max_depth);
if (!Yap_unify_constant(ARG1, t))
return (FALSE);
Term t = MkIntegerTerm (max_depth);
if (!Yap_unify_constant(t1, t))
return FALSE;
}
else
max_depth = IntOfTerm (t1);
if (IsVarTerm (ARG2))
max_depth = IntegerOfTerm (t1);
if (IsVarTerm (t2))
{
Term t = MkIntTerm (max_list);
if (!Yap_unify_constant (ARG2, t))
return (FALSE);
Term t = MkIntegerTerm (max_list);
if (!Yap_unify_constant (t2, t))
return FALSE;
}
else
max_list = IntOfTerm (t2);
return (TRUE);
max_list = IntegerOfTerm (t2);
if (IsVarTerm (t3))
{
Term t = MkIntegerTerm (max_write_args);
if (!Yap_unify_constant (t3, t))
return FALSE;
}
else
max_write_args = IntegerOfTerm (t3);
return TRUE;
}
static Int
@@ -5022,7 +5053,7 @@ Yap_InitIOPreds(void)
Yap_InitCPred ("$is_same_tty", 2, p_is_same_tty, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("prompt", 2, p_prompt, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("always_prompt_user", 0, p_always_prompt_user, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("write_depth", 2, p_write_depth, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("write_depth", 3, p_write_depth, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$change_type_of_char", 2, p_change_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$type_of_char", 2, p_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("char_conversion", 2, p_char_conversion, SyncPredFlag);

View File

@@ -125,6 +125,15 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
sc = Yap_heap_regs;
vsc_count++;
{
Term WGs = Yap_ReadTimedVar(WokenGoals);
fprintf(stderr,"%d %p %lld: ",port, H, vsc_count);
Yap_DebugPlWrite(WGs);
Yap_DebugErrorPutc ('\n');
}
if (vsc_count < 100) {
return;
}
#ifdef COMMENTED
// if (vsc_count == 218280)
// vsc_xstop = 1;

View File

@@ -50,7 +50,7 @@ typedef struct write_globs {
wrf writech;
int Quote_illegal, Ignore_ops, Handle_vars, Use_portray;
int keep_terms;
UInt MaxDepth, MaxList;
UInt MaxDepth, MaxList, MaxArgs;
} wglbs;
STATIC_PROTO(void wrputn, (Int, wrf));
@@ -698,6 +698,12 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb)
wrputc('{', wglb->writech);
lastw = separator;
for (op = 1; op <= Arity; ++op) {
if (op == wglb->MaxArgs) {
wrputc('.', wglb->writech);
wrputc('.', wglb->writech);
wrputc('.', wglb->writech);
break;
}
if (wglb->keep_terms) {
/* garbage collection may be called */
sl = Yap_InitSlot(t);
@@ -722,6 +728,12 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb)
for (op = 1; op <= Arity; ++op) {
long sl = 0;
if (op == wglb->MaxArgs) {
wrputc('.', wglb->writech);
wrputc('.', wglb->writech);
wrputc('.', wglb->writech);
break;
}
if (wglb->keep_terms) {
/* garbage collection may be called */
sl = Yap_InitSlot(t);
@@ -758,6 +770,7 @@ Yap_plwrite(Term t, int (*mywrite) (int, int), int flags)
wglb.Use_portray = flags & Use_portray_f;
wglb.MaxDepth = max_depth;
wglb.MaxList = max_list;
wglb.MaxArgs = max_write_args;
/* notice: we must have ASP well set when using portray, otherwise
we cannot make recursive Prolog calls */
wglb.keep_terms = (flags & (Use_portray_f|To_heap_f));