fix garbage collector not to try to garbage collect when we ask for large
chunks of stack in a single go. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1684 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
f69ba78f02
commit
0f714371e5
17
C/absmi.c
17
C/absmi.c
@ -10,8 +10,11 @@
|
||||
* *
|
||||
* File: absmi.c *
|
||||
* comments: Portable abstract machine interpreter *
|
||||
* Last rev: $Date: 2006-05-24 02:35:39 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-08-07 18:51:44 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.202 2006/05/24 02:35:39 vsc
|
||||
* make chr work and other minor fixes.
|
||||
*
|
||||
* Revision 1.201 2006/04/27 14:11:57 rslopes
|
||||
* *** empty log message ***
|
||||
*
|
||||
@ -11433,7 +11436,7 @@ Yap_absmi(int inp)
|
||||
if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) {
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,xxx),sla))) {
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xxx),sla))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
setregs();
|
||||
JMPNext();
|
||||
@ -11546,7 +11549,7 @@ Yap_absmi(int inp)
|
||||
if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) {
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,xcx),sla))) {
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,xcx),sla))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
setregs();
|
||||
JMPNext();
|
||||
@ -11763,7 +11766,7 @@ Yap_absmi(int inp)
|
||||
if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) {
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,yxx),sla))) {
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxx),sla))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
setregs();
|
||||
JMPNext();
|
||||
@ -11898,7 +11901,7 @@ Yap_absmi(int inp)
|
||||
if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) {
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,ycx),sla))) {
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,ycx),sla))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
setregs();
|
||||
JMPNext();
|
||||
@ -12042,7 +12045,7 @@ Yap_absmi(int inp)
|
||||
if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) {
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(0, YREG, NEXTOP(NEXTOP(PREG,yxc),sla))) {
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 0, YREG, NEXTOP(NEXTOP(PREG,yxc),sla))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
setregs();
|
||||
JMPNext();
|
||||
@ -12432,7 +12435,7 @@ Yap_absmi(int inp)
|
||||
if (pt1+d1 > ENV || pt1+d1 > (CELL *)B) {
|
||||
/* make sure we have something to show for our trouble */
|
||||
saveregs();
|
||||
if (!Yap_gc(3, YREG, NEXTOP(NEXTOP(PREG,e),sla))) {
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 3, YREG, NEXTOP(NEXTOP(PREG,e),sla))) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
setregs();
|
||||
JMPNext();
|
||||
|
10
C/arrays.c
10
C/arrays.c
@ -157,7 +157,7 @@ GetTermFromArray(DBTerm *ref)
|
||||
}
|
||||
} else {
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 3, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return TermNil;
|
||||
}
|
||||
@ -721,7 +721,7 @@ p_create_array(void)
|
||||
|
||||
farray = Yap_MkFunctor(AtomArray, size);
|
||||
if (H+1+size > ASP-1024) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
} else {
|
||||
@ -759,7 +759,7 @@ p_create_array(void)
|
||||
if (EndOfPAEntr(pp)) {
|
||||
if (H+1+size > ASP-1024) {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
} else
|
||||
@ -781,7 +781,7 @@ p_create_array(void)
|
||||
ae->StrOfAE);
|
||||
} else {
|
||||
if (H+1+size > ASP-1024) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((1+size)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
} else
|
||||
@ -2189,7 +2189,7 @@ p_static_array_to_term(void)
|
||||
CELL *base;
|
||||
|
||||
while (H+1+dim > ASP-1024) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((1+dim)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
} else {
|
||||
|
@ -214,6 +214,7 @@ BuildAttTerm(Functor mfun, UInt ar)
|
||||
UInt i;
|
||||
|
||||
if (H+(1024+ar) > ASP) {
|
||||
Yap_Error_Size=ar*sizeof(CELL);
|
||||
return 0L;
|
||||
}
|
||||
H[0] = (CELL)mfun;
|
||||
@ -418,6 +419,7 @@ AllAttVars(attvar_record *attv) {
|
||||
|
||||
if (ASP - H < 1024) {
|
||||
H = h0;
|
||||
Yap_Error_Size = (ASP-H)*sizeof(CELL);
|
||||
return 0L;
|
||||
}
|
||||
if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) {
|
||||
@ -471,7 +473,7 @@ p_put_att(void) {
|
||||
mfun= Yap_MkFunctor(modname,ar);
|
||||
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||
while (!(tatts = BuildAttTerm(mfun,ar))) {
|
||||
if (!Yap_gc(5, ENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -549,7 +551,7 @@ p_rm_att(void) {
|
||||
mfun= Yap_MkFunctor(modname,ar);
|
||||
if (IsVarTerm(tatts = SearchAttsForModule(attv->Atts,mfun))) {
|
||||
while (!(tatts = BuildAttTerm(mfun,ar))) {
|
||||
if (!Yap_gc(4, ENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 4, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -882,7 +884,7 @@ p_all_attvars(void)
|
||||
|
||||
base = (attvar_record *)Yap_GlobalBase+IntegerOfTerm(Yap_ReadTimedVar(AttsMutableList));
|
||||
if (!(out = AllAttVars(base))) {
|
||||
if (!Yap_gc(1, ENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
|
15
C/cdmgr.c
15
C/cdmgr.c
@ -11,8 +11,11 @@
|
||||
* File: cdmgr.c *
|
||||
* comments: Code manager *
|
||||
* *
|
||||
* Last rev: $Date: 2006-05-24 02:35:39 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-08-07 18:51:44 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.189 2006/05/24 02:35:39 vsc
|
||||
* make chr work and other minor fixes.
|
||||
*
|
||||
* Revision 1.188 2006/05/18 16:33:04 vsc
|
||||
* fix info reported by memory manager under DL_MALLOC and SYSTEM_MALLOC
|
||||
*
|
||||
@ -4778,7 +4781,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
|
||||
}
|
||||
} else {
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gc(7, YENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 7, YENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -4790,7 +4793,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
|
||||
ARG6 = th;
|
||||
ARG7 = tb;
|
||||
ARG8 = tr;
|
||||
if (!Yap_gc(8, ENV, CP)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 8, ENV, CP)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -4894,13 +4897,13 @@ fetch_next_lu_clause0(PredEntry *pe, yamop *i_code, Term th, Term tb, yamop *cp_
|
||||
}
|
||||
} else {
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gc(4, YENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 4, YENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!Yap_gc(5, ENV, CP)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 5, ENV, CP)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -5049,7 +5052,7 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
|
||||
ARG6 = th;
|
||||
ARG7 = tb;
|
||||
ARG8 = tr;
|
||||
if (!Yap_gc(8, ENV, CP)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 8, ENV, CP)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ recover_from_record_error(int nargs)
|
||||
{
|
||||
switch(Yap_Error_TYPE) {
|
||||
case OUT_OF_STACK_ERROR:
|
||||
if (!Yap_gc(nargs, ENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, nargs, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -11,8 +11,11 @@
|
||||
* File: gprof.c *
|
||||
* comments: Interrupt Driven Profiler *
|
||||
* *
|
||||
* Last rev: $Date: 2006-04-27 20:58:59 $,$Author: rslopes $ *
|
||||
* Last rev: $Date: 2006-08-07 18:51:44 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.5 2006/04/27 20:58:59 rslopes
|
||||
* fix do profiler offline.
|
||||
*
|
||||
* Revision 1.4 2006/02/01 13:28:56 vsc
|
||||
* bignum support fixes
|
||||
*
|
||||
@ -102,6 +105,8 @@ RBTreeCreate(void) {
|
||||
return temp;
|
||||
}
|
||||
|
||||
/* This is code originally written by Emin Martinian */
|
||||
|
||||
/***********************************************************************/
|
||||
/* FUNCTION: LeftRotate */
|
||||
/**/
|
||||
|
@ -560,6 +560,8 @@ RBTreeCreate(void) {
|
||||
return temp;
|
||||
}
|
||||
|
||||
/* This is code originally written by Emin Martinian */
|
||||
|
||||
/***********************************************************************/
|
||||
/* FUNCTION: LeftRotate */
|
||||
/**/
|
||||
@ -3863,6 +3865,7 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
|
||||
GcCalls++;
|
||||
if (gc_on && !(Yap_PrologMode & InErrorMode) &&
|
||||
/* make sure there is a point in collecting the heap */
|
||||
(ASP-H0)*sizeof(CELL) > gc_lim &&
|
||||
H-H0 > (LCL0-ASP)/2) {
|
||||
effectiveness = do_gc(predarity, current_env, nextop);
|
||||
if (effectiveness < 0)
|
||||
|
@ -711,7 +711,7 @@ p_functor(void) /* functor(?,?,?) */
|
||||
*pt1++ = d0;
|
||||
d0 = AbsAppl(H);
|
||||
if (pt1+d1 > ENV - CreepFlag) {
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gcl((1+d1)*sizeof(CELL), 3, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
|
@ -2678,7 +2678,7 @@ p_peek_mem_write_stream (void)
|
||||
if (H + 1024 >= ASP) {
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
H = HI;
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-HI)*sizeof(CELL), 3, ENV, P)) {
|
||||
UNLOCK(Stream[sno].streamlock);
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
@ -3182,7 +3182,7 @@ static Int
|
||||
}
|
||||
} else if (Yap_Error_TYPE == OUT_OF_STACK_ERROR) {
|
||||
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||
if (!Yap_gc(nargs, ENV, CP)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, nargs, ENV, CP)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ p_stream_to_codes(void)
|
||||
RESET_VARIABLE(h0);
|
||||
ARG4 = AbsPair(HBASE);
|
||||
ARG5 = (CELL)h0;
|
||||
if (!Yap_gc(5, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-HBASE)*sizeof(CELL), 5, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, ARG1, "read_stream_to_codes/3");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -683,6 +683,7 @@ Yap_tokenizer(int inp_stream)
|
||||
int (*QuotedNxtch) (int) = Stream[inp_stream].stream_getc;
|
||||
|
||||
Yap_ErrorMessage = NULL;
|
||||
Yap_Error_Size = 0;
|
||||
Yap_VarTable = NULL;
|
||||
Yap_AnonVarTable = NULL;
|
||||
Yap_eot_before_eof = FALSE;
|
||||
@ -801,6 +802,7 @@ Yap_tokenizer(int inp_stream)
|
||||
UNLOCK(Stream[inp_stream].streamlock);
|
||||
Yap_ErrorMessage = "Stack Overflow";
|
||||
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
|
||||
Yap_Error_Size = 0L;
|
||||
if (p)
|
||||
p->Tok = Ord(kind = eot_tok);
|
||||
/* serious error now */
|
||||
|
2
C/sort.c
2
C/sort.c
@ -58,7 +58,7 @@ build_new_list(CELL *pt, Term t)
|
||||
}
|
||||
pt += 2;
|
||||
if (pt > ASP - 4096) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
|
11
C/stdpreds.c
11
C/stdpreds.c
@ -11,8 +11,11 @@
|
||||
* File: stdpreds.c *
|
||||
* comments: General-purpose C implemented system predicates *
|
||||
* *
|
||||
* Last rev: $Date: 2006-06-05 19:36:00 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-08-07 18:51:44 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.105 2006/06/05 19:36:00 vsc
|
||||
* hacks
|
||||
*
|
||||
* Revision 1.104 2006/05/19 14:31:32 vsc
|
||||
* get rid of IntArrays and FloatArray code.
|
||||
* include holes when calculating memory usage.
|
||||
@ -1681,9 +1684,9 @@ p_univ(void)
|
||||
if (H > ASP - 1024) {
|
||||
/* restore space */
|
||||
H = Ar;
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
twork = TailOfTerm(Deref(ARG2));
|
||||
goto build_compound;
|
||||
@ -1756,7 +1759,7 @@ p_univ(void)
|
||||
#endif
|
||||
{
|
||||
while (H+arity*2 > ASP-1024) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((arity*2)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ CopyTerm(Term inp, UInt arity) {
|
||||
XREGS[arity+1] = t;
|
||||
H = Hi-1;
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!Yap_gc(arity+1, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), arity+1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -350,7 +350,7 @@ CopyTerm(Term inp, UInt arity) {
|
||||
H = Hi;
|
||||
XREGS[arity+1] = t;
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!Yap_gc(arity+1, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), arity+1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -387,7 +387,7 @@ CopyTerm(Term inp, UInt arity) {
|
||||
H = HB0;
|
||||
XREGS[arity+1] = t;
|
||||
if (res == -1) {
|
||||
if (!Yap_gc(arity+1, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL),arity+1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
@ -631,7 +631,7 @@ CopyTermNoDelays(Term inp) {
|
||||
if (res) {
|
||||
H = Hi;
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
@ -664,7 +664,7 @@ CopyTermNoDelays(Term inp) {
|
||||
if (res) {
|
||||
H = HB0;
|
||||
if (res == -1) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
}
|
||||
@ -809,6 +809,7 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter
|
||||
clean_tr(TR0);
|
||||
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
|
||||
H = InitialH;
|
||||
Yap_Error_Size = (ASP-H)*sizeof(CELL);
|
||||
return 0L;
|
||||
|
||||
}
|
||||
@ -840,7 +841,7 @@ p_variables_in_term(void) /* variables in term t */
|
||||
ArityOfFunctor(f), ARG2);
|
||||
}
|
||||
if (out == 0L) {
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gcl(Yap_Error_Size, 3, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_variables");
|
||||
return FALSE;
|
||||
}
|
||||
@ -871,7 +872,7 @@ p_term_variables(void) /* variables in term t */
|
||||
ArityOfFunctor(f), TermNil);
|
||||
}
|
||||
if (out == 0L) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_variables");
|
||||
return FALSE;
|
||||
}
|
||||
@ -902,7 +903,7 @@ p_term_variables3(void) /* variables in term t */
|
||||
ArityOfFunctor(f), ARG3);
|
||||
}
|
||||
if (out == 0L) {
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), 3, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_variables");
|
||||
return FALSE;
|
||||
}
|
||||
@ -1681,7 +1682,7 @@ p_variant(void) /* variant terms t1 and t2 */
|
||||
}
|
||||
error:
|
||||
if (out == -1) {
|
||||
if (!Yap_gc(2, ENV, P)) {
|
||||
if (!Yap_gcl((ASP-H)*sizeof(CELL), 2, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in variant");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
<h2>Yap-5.1.2:</h2>
|
||||
<ul>
|
||||
<li> FIXED: do not call garbage collector if the space we need is more
|
||||
than what is available (obs from Nicos Angelopoulos).</li>
|
||||
<li> FIXED: recordaifnot(a,_,_) was broken (obs from Jesse Davis).</li>
|
||||
<li> SPEEDUP: some speedups to garbage collector (obs from Nicos Angelopoulos).</li>
|
||||
<li> NEW: a first cut at readutil.yap (request from Stefan Weinbrenner).</li>
|
||||
|
@ -42,7 +42,7 @@ read_file_to_codes(File, Codes) :-
|
||||
|
||||
read_file_to_terms(File, Codes, _) :-
|
||||
open(File, read, Stream),
|
||||
read_stream_to_terms(Stream, Codes, []),
|
||||
prolog_read_stream_to_terms(Stream, Codes, []),
|
||||
close(Stream).
|
||||
|
||||
read_file_to_terms(File, Codes) :-
|
||||
@ -51,7 +51,13 @@ read_file_to_terms(File, Codes) :-
|
||||
close(Stream).
|
||||
|
||||
|
||||
|
||||
|
||||
prolog_read_stream_to_terms(Stream, Terms, Terms0) :-
|
||||
read(Stream, Term),
|
||||
(Term == end_of_file ->
|
||||
Terms = Terms0
|
||||
;
|
||||
Terms = [Term|TermsI],
|
||||
prolog_read_stream_to_terms(Stream, TermsI, Terms0)
|
||||
).
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user