more fixes

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@827 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-05-19 13:04:09 +00:00
parent 77b1c99030
commit bd383b7e3f
21 changed files with 150 additions and 105 deletions

View File

@ -290,7 +290,7 @@ Yap_absmi(int inp)
#if PUSH_REGS
restore_absmi_regs(old_regs);
#endif
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, 0)) {
saveregs();
Yap_Error(SYSTEM_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
setregs();
@ -10208,7 +10208,7 @@ Yap_absmi(int inp)
#ifdef LOW_LEVEL_TRACER
if (Yap_do_low_level_trace) {
RESET_VARIABLE(H);
H[1] = PREG->u.ycx.c;
H[1] = XREG(PREG->u.ycx.c);
H[2] = XREG(PREG->u.ycx.xi);
low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(Yap_MkFunctor(Yap_LookupAtom("functor"),3),0)),H);
}

View File

@ -2337,8 +2337,9 @@ do_pass(void)
}
if (!pass_no) {
if (CellPtr(label_offset+cpc->rnd1) > ASP-256) {
Yap_Error_Size = 256+((char *)(label_offset+cpc->rnd1) - (char *)H);
save_machine_regs();
longjmp(Yap_CompilerBotch,3);
longjmp(Yap_CompilerBotch, 3);
}
if ( (char *)(label_offset+cpc->rnd1) > freep)
@ -2537,7 +2538,7 @@ Yap_assemble(int mode)
size = (CELL)code_p;
}
while ((code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) {
if (!Yap_growheap(TRUE)) {
if (!Yap_growheap(TRUE, size)) {
Yap_Error_TYPE = SYSTEM_ERROR;
return NULL;
}

View File

@ -441,7 +441,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
}
while ((p->ValueOfVE.floats = (Float *) Yap_AllocAtomSpace(asize) ) == NULL) {
YAPLeaveCriticalSection();
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, asize)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return;
}
@ -455,7 +455,7 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
{
if (EndOfPAEntr(p)) {
while ((p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p))) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, sizeof(*p))) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return NULL;
}

View File

@ -591,7 +591,7 @@ YAP_AllocSpaceFromYap(unsigned int size)
BACKUP_MACHINE_REGS();
if ((ptr = Yap_AllocCodeSpace(size)) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(NULL);
}

View File

@ -763,7 +763,7 @@ static void expand_consult(void)
ConsultCapacity += InitialConsultCapacity;
/* I assume it always works ;-) */
while ((new_cl = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*ConsultCapacity)) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, sizeof(consult_obj)*ConsultCapacity)) {
Yap_Error(SYSTEM_ERROR,TermNil,Yap_ErrorMessage);
return;
}

View File

@ -136,8 +136,9 @@ pop_code(unsigned int level)
return;
if (cpc->op == pop_op)
++(cpc->rnd1);
else
else {
Yap_emit(pop_op, One, Zero);
}
}
static void
@ -462,7 +463,7 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level)
dest[2] = src[2];
#endif
/* note that we don't need to copy size info, unless we wanted
to garbage collect clauses ;-) */
to garbage collect clauses ;-) */
icpc = cpc;
if (BlobsStart == NULL)
BlobsStart = CodeStart;
@ -556,8 +557,9 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level)
}
c_arg(2, TailOfTerm(t), 2, level);
--level;
if (argno != (Int)arity)
if (argno != (Int)arity) {
pop_code(level);
}
} else if (IsRefTerm(t)) {
READ_LOCK(CurrentPred->PRWLock);
if (!(CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
@ -595,8 +597,9 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level)
++level;
c_args(t, level);
--level;
if (argno != (Int)arity)
if (argno != (Int)arity) {
pop_code(level);
}
}
}
@ -2682,6 +2685,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
/* first, initialise Yap_CompilerBotch to handle all cases of interruptions */
Yap_ErrorMessage = NULL;
Yap_Error_Size = 0;
if ((botch_why = setjmp(Yap_CompilerBotch)) == 3) {
/* out of local stack, just duplicate the stack */
restore_machine_regs();
@ -2689,7 +2693,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
{
Int osize = 2*sizeof(CELL)*(ASP-H);
ARG1 = my_clause;
if (!Yap_gc(2, ENV, P)) {
if (!Yap_gcl(Yap_Error_Size, 2, ENV, P)) {
Yap_Error_TYPE = OUT_OF_STACK_ERROR;
Yap_Error_Term = my_clause;
}
@ -2723,7 +2727,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
reset_vars();
return (0);
}
SaveH = H;
HB = H;
or_found = 0;
Yap_ErrorMessage = NULL;
/* initialize variables for code generation */
@ -2731,7 +2735,8 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
BlobsStart = icpc = NULL;
freep = freep0 = (char *) (H + maxvnum);
if (ASP <= CellPtr (freep) + 256) {
vtable = NIL;
vtable = NULL;
Yap_Error_Size = (256+maxvnum)*sizeof(CELL);
save_machine_regs();
longjmp(Yap_CompilerBotch,3);
}
@ -2746,7 +2751,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
* 2000 added to H in case we need to construct call(G) when G is a
* variable used as a goal
*/
vtable = NIL;
vtable = NULL;
labelno = 0L;
if (IsVarTerm(my_clause)) {
@ -2802,7 +2807,8 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
BlobsStart = NULL;
}
reset_vars();
H = SaveH;
H = HB;
HB = B->cp_h;
if (Yap_ErrorMessage)
return (0);
#ifdef DEBUG
@ -2859,7 +2865,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
if (acode == NIL) {
/* make sure we have enough space */
reset_vars();
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
save_machine_regs();
my_clause = Deref(ARG1);
longjmp(Yap_CompilerBotch, 2);

View File

@ -65,6 +65,7 @@ AllocCMem (int size)
#endif
freep += size;
if (ASP <= CellPtr (freep) + 256) {
Yap_Error_Size = 256+((char *)freep - (char *)H);
save_machine_regs();
longjmp(Yap_CompilerBotch,3);
}
@ -82,24 +83,21 @@ Yap_is_a_test_pred (Term arg, SMALLUNSGN mod)
{
if (IsVarTerm (arg))
return (FALSE);
else if (IsAtomTerm (arg))
{
else if (IsAtomTerm (arg)) {
Atom At = AtomOfTerm (arg);
PredEntry *pe = RepPredProp(PredPropByAtom(At, mod));
if (EndOfPAEntr(pe))
return (FALSE);
return (pe->PredFlags & TestPredFlag);
}
else if (IsApplTerm (arg))
{
Functor f = FunctorOfTerm (arg);
} else if (IsApplTerm (arg)) {
Functor f = FunctorOfTerm (arg);
PredEntry *pe = RepPredProp(PredPropByFunc(f, mod));
if (EndOfPAEntr(pe))
return (FALSE);
return (pe->PredFlags & TestPredFlag);
}
else
} else {
return (FALSE);
}
}
void
@ -110,14 +108,13 @@ Yap_emit (compiler_vm_op o, Int r1, CELL r2)
p->op = o;
p->rnd1 = r1;
p->rnd2 = r2;
p->nextInst = NIL;
if (cpc == NIL)
p->nextInst = NULL;
if (cpc == NIL) {
cpc = CodeStart = p;
else
{
cpc->nextInst = p;
cpc = p;
}
} else {
cpc->nextInst = p;
cpc = p;
}
}
void

View File

@ -940,6 +940,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
return(CodeMax);
error:
Yap_Error_Size = 1024+((char *)AuxSp-(char *)HeapTop);
DBErrorFlag = OVF_ERROR_IN_DB;
*vars_foundp = vars_found;
#ifdef RATIONAL_TREES
@ -1391,6 +1392,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
CodeAbs++; /* We have one more cell */
CodeAbs += CellPtr(lr) - CellPtr(LinkAr);
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
Yap_Error_Size = (UInt)DBLength(CodeAbs);
DBErrorFlag = OVF_ERROR_IN_DB;
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
@ -1417,6 +1419,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
if (tofref != TmpRefBase) {
CodeAbs += TmpRefBase - tofref + 1;
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
Yap_Error_Size = (UInt)DBLength(CodeAbs);
DBErrorFlag = OVF_ERROR_IN_DB;
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
@ -1437,6 +1440,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
#endif
pp = AllocDBSpace(DBLength(CodeAbs));
if (pp == NIL) {
Yap_Error_Size = (UInt)DBLength(CodeAbs);
DBErrorFlag = OVF_ERROR_IN_DB;
DBErrorNumber = SYSTEM_ERROR;
DBErrorTerm = TermNil;
@ -1735,6 +1739,7 @@ p_rcda(void)
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record(MkFirst, t1, t2, Unsigned(0)));
switch(DBErrorFlag) {
case NO_ERROR_IN_DB:
@ -1749,7 +1754,7 @@ p_rcda(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -1774,6 +1779,7 @@ p_rcdap(void)
if (!IsVarTerm(Deref(ARG3)))
return FALSE;
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, Unsigned(0)));
switch(DBErrorFlag) {
case NO_ERROR_IN_DB:
@ -1788,7 +1794,7 @@ p_rcdap(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return FALSE;
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return FALSE;
} else {
@ -1823,6 +1829,7 @@ p_rcda_at(void)
return(FALSE);
}
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record_at(MkFirst, DBRefOfTerm(t1), t2, Unsigned(0)));
switch(DBErrorFlag) {
case NO_ERROR_IN_DB:
@ -1837,7 +1844,7 @@ p_rcda_at(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -1862,6 +1869,7 @@ p_rcdz(void)
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record(MkLast, t1, t2, Unsigned(0)));
switch(DBErrorFlag) {
case NO_ERROR_IN_DB:
@ -1876,7 +1884,7 @@ p_rcdz(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -1901,6 +1909,7 @@ p_rcdzp(void)
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record(MkLast | MkCode, t1, t2, Unsigned(0)));
switch(DBErrorFlag) {
case NO_ERROR_IN_DB:
@ -1915,7 +1924,7 @@ p_rcdzp(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -1949,6 +1958,7 @@ p_rcdz_at(void)
return(FALSE);
}
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record_at(MkLast, DBRefOfTerm(t1), t2, Unsigned(0)));
switch(DBErrorFlag) {
case NO_ERROR_IN_DB:
@ -1963,7 +1973,7 @@ p_rcdz_at(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recordz_at/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -1993,6 +2003,7 @@ p_rcdstatp(void)
return (FALSE);
mk_first = ((IntOfTerm(t3) % 4) == 2);
restart_record:
Yap_Error_Size = 0;
if (mk_first)
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, MkIntTerm(0)));
else
@ -2010,7 +2021,7 @@ p_rcdstatp(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in record_stat_source/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -2037,6 +2048,7 @@ p_drcdap(void)
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
return (FALSE);
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record(MkFirst | MkCode | WithRef,
t1, t2, t4));
switch(DBErrorFlag) {
@ -2052,7 +2064,7 @@ p_drcdap(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -2080,6 +2092,7 @@ p_drcdzp(void)
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
return (FALSE);
restart_record:
Yap_Error_Size = 0;
TRef = MkDBRefTerm(record(MkLast | MkCode | WithRef,
t1, t2, t4));
switch(DBErrorFlag) {
@ -2095,7 +2108,7 @@ p_drcdzp(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -2120,6 +2133,7 @@ p_rcdaifnot(void)
DBRef db_ref;
restart_record:
Yap_Error_Size = 0;
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
found_one = NIL;
@ -2140,7 +2154,7 @@ p_rcdaifnot(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -2162,6 +2176,7 @@ p_rcdzifnot(void)
DBRef db_ref;
restart_record:
Yap_Error_Size = 0;
if (!IsVarTerm(Deref(ARG3)))
return (FALSE);
found_one = NIL;
@ -2182,7 +2197,7 @@ p_rcdzifnot(void)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else
@ -2544,7 +2559,7 @@ nth_recorded_log(LogUpdDBProp AtProp, Int Count)
} else {
if (AtProp->Index == NULL) {
while((AtProp->Index = new_lu_index(AtProp)) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE,DBLength((AtProp->NOfEntries+1)*sizeof(DBRef *)))) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
READ_UNLOCK(AtProp->DBRWLock);
return NULL;
@ -2732,7 +2747,7 @@ i_log_upd_recorded(LogUpdDBProp AtProp)
} else {
if (AtProp->Index == NULL) {
while((AtProp->Index = new_lu_index(AtProp)) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE,DBLength((AtProp->NOfEntries+1)*sizeof(DBRef *)))) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return FALSE;
}
@ -4262,6 +4277,7 @@ StoreTermInDB(int arg, int nargs)
{
DBRef x;
Term t = Deref(XREGS[arg]);
Yap_Error_Size = 0;
while ((x = CreateDBStruct(t, (DBProp)NIL,
InQueue)) == NULL) {
@ -4283,7 +4299,7 @@ StoreTermInDB(int arg, int nargs)
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
return(FALSE);
case OVF_ERROR_IN_DB:
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
} else {
@ -4311,7 +4327,7 @@ p_init_queue(void)
Term t;
while ((dbq = (db_queue *)AllocDBSpace(sizeof(db_queue))) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, sizeof(db_queue))) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}

View File

@ -644,12 +644,15 @@ fix_tabling_info(void)
#endif /* TABLING */
int
Yap_growheap(int fix_code)
Yap_growheap(int fix_code, UInt in_size)
{
unsigned long size = sizeof(CELL) * 16 * 1024L;
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
unsigned long sz = size << shift_factor;
if (sz < in_size) {
sz = in_size;
}
#if defined(YAPOR) || defined(THREADS)
if (NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
@ -661,6 +664,9 @@ Yap_growheap(int fix_code)
while(sz >= sizeof(CELL) * 16 * 1024L && !static_growheap(sz, fix_code)) {
size = size/2;
sz = size << shift_factor;
if (sz < in_size) {
return FALSE;
}
}
/* we must fix an instruction chain */
if (fix_code) {

View File

@ -3050,7 +3050,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
}
if (HeapTop >= Yap_GlobalBase - MinHeapGap) {
*--ASP = (CELL)current_env;
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, MinHeapGap)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
@ -3155,13 +3155,13 @@ p_inform_gc(void)
}
int
Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
static int
call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
{
Int gc_margin = 128;
Term Tgc_margin;
Int effectiveness = 0;
int gc_on = FALSE;
UInt gc_margin = 128;
Term Tgc_margin;
Int effectiveness = 0;
int gc_on = FALSE;
#if defined(YAPOR) || defined(THREADS)
if (NOfThreads != 1) {
@ -3171,39 +3171,34 @@ Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
#endif
if (Yap_GetValue(AtomGc) != TermNil)
gc_on = TRUE;
if (IsIntTerm(Tgc_margin = Yap_GetValue(AtomGcMargin))) {
gc_margin = IntOfTerm(Tgc_margin);
if (IsIntegerTerm(Tgc_margin = Yap_GetValue(AtomGcMargin)) &&
gc_margin > 0) {
gc_margin = (UInt)IntegerOfTerm(Tgc_margin);
} else {
/* only go exponential for the first 8 calls */
if (gc_calls < 8)
gc_margin <<= gc_calls;
else
else {
/* next grow linearly */
gc_margin <<= 8;
gc_margin *= gc_calls;
}
}
if (gc_margin < 0 || gc_margin > 4000) {
gc_margin = (LCL0 - H0) >> 9;
}
gc_margin = gc_margin << 8;
if (gc_margin < gc_lim)
gc_margin = gc_lim;
if (gc_on) {
effectiveness = do_gc(predarity, current_env, nextop);
}
if (effectiveness > 90) {
while (gc_margin < H-H0)
gc_margin <<= 1;
if (effectiveness > 90) {
while (gc_margin < H-H0)
gc_margin <<= 1;
}
} else {
effectiveness = 0;
}
/* expand the stack if effectiveness is less than 20 % */
if (ASP - H < gc_margin || !gc_on || effectiveness < 20) {
Int gap = CalculateStackGap();
if (ASP-H > gc_margin)
gc_margin = (ASP-H)+gap;
else
gc_margin = 8 * (gc_margin - (ASP - H));
gc_margin = ((gc_margin >> 16) + 1) << 16;
if (gc_margin < gap)
gc_margin = gap;
while (gc_margin >= gap && !Yap_growstack(gc_margin))
gc_margin = gc_margin/2;
check_global();
return(gc_margin >= gap);
if (ASP - H < gc_margin ||
effectiveness < 20) {
return (Yap_growstack(gc_margin));
}
/*
* debug for(save_total=1; save_total<=N; ++save_total)
@ -3212,6 +3207,18 @@ Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
return ( TRUE );
}
int
Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
{
return call_gc(128, predarity, current_env, nextop);
}
int
Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
{
return call_gc(gc_lim, predarity, current_env, nextop);
}
static Int
p_gc(void)

View File

@ -1031,6 +1031,7 @@ add_info(ClauseDef *clause, UInt regno)
case _get_x_var:
if (regcopy_in(myregs, nofregs, cl->u.xx.xr)) {
nofregs = add_regcopy(myregs, nofregs, cl->u.xx.xl);
cl = NEXTOP(cl,xx);
break;
}
case _put_x_var:
@ -2686,10 +2687,15 @@ compile_index(PredEntry *ap)
int NClauses = ap->cs.p_code.NOfClauses;
ClauseDef *cls = (ClauseDef *)H;
CELL *top = (CELL *) TR;
/* only global variable I use directly */
labelno = 1;
if (cls+NClauses > (ClauseDef *)(ASP-4096)) {
Yap_Error_Size = NClauses*sizeof(ClauseDef);
/* reserve double the space for compiler */
if (cls+2*NClauses > (ClauseDef *)(ASP-4096)) {
/* tell how much space we need */
Yap_Error_Size += NClauses*sizeof(ClauseDef);
/* grow stack */
longjmp(Yap_CompilerBotch,3);
}
@ -2710,10 +2716,10 @@ Yap_PredIsIndexable(PredEntry *ap)
{
yamop *indx_out;
Yap_Error_Size = 0;
if (setjmp(Yap_CompilerBotch) == 3) {
/* just duplicate the stack */
restore_machine_regs();
Yap_gc(ap->ArityOfPE, ENV, CP);
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
}
restart_index:
Yap_ErrorMessage = NULL;
@ -2729,7 +2735,7 @@ Yap_PredIsIndexable(PredEntry *ap)
CurrentPred = ap;
IPredArity = ap->ArityOfPE;
if ((indx_out = Yap_assemble(ASSEMBLING_INDEX)) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return NULL;
}

View File

@ -84,6 +84,7 @@ ADDR Yap_HeapBase,
char *Yap_ErrorMessage; /* used to pass error messages */
Term Yap_Error_Term; /* used to pass error terms */
yap_error_number Yap_Error_TYPE; /* used to pass the error */
UInt Yap_Error_Size; /* used to pass a size associated with an error */
/********* readline support *****/
#if HAVE_LIBREADLINE

View File

@ -2004,7 +2004,7 @@ p_open_mem_read_stream (void) /* $open_mem_read_stream(+List,-Stream) */
}
}
while ((nbuf = (char *)Yap_AllocAtomSpace((sl+1)*sizeof(char))) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, (sl+1)*sizeof(char))) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
@ -2058,7 +2058,7 @@ p_open_mem_write_stream (void) /* $open_mem_write_stream(-Stream) */
extern int Yap_page_size;
while ((nbuf = (char *)Yap_AllocAtomSpace(Yap_page_size*sizeof(char))) == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, Yap_page_size*sizeof(char))) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
@ -4833,7 +4833,7 @@ p_char_conversion(void)
return(TRUE);
CharConversionTable2 = Yap_AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char));
while (CharConversionTable2 == NULL) {
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, NUMBER_OF_CHARS*sizeof(char))) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}

View File

@ -650,7 +650,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
if (Yap_ErrorMessage)
return(FAIL_RESTORE);
while (Yap_HeapBase != NULL && hp_size > Unsigned(AuxTop) - Unsigned(Yap_HeapBase)) {
if(!Yap_growheap(FALSE)) {
if(!Yap_growheap(FALSE, hp_size)) {
return(FAIL_RESTORE);
}
}

View File

@ -853,7 +853,7 @@ p_atom_concat(void)
sz = strlen(atom_str);
if (cptr+sz >= top-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, sz+1024)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}

View File

@ -316,7 +316,7 @@ CopyTerm(Term inp) {
t = Deref(ARG1);
goto restart_attached;
} else { /* handle overflow */
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, 0)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
@ -352,7 +352,7 @@ CopyTerm(Term inp) {
t = Deref(ARG1);
goto restart_list;
} else { /* handle overflow */
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, 0)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
@ -387,7 +387,7 @@ CopyTerm(Term inp) {
t = Deref(ARG1);
goto restart_appl;
} else { /* handle overflow */
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, 0)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
@ -625,7 +625,7 @@ CopyTermNoDelays(Term inp) {
t = Deref(ARG1);
goto restart_list;
} else { /* handle overflow */
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, 0)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}
@ -657,7 +657,7 @@ CopyTermNoDelays(Term inp) {
t = Deref(ARG1);
goto restart_appl;
} else { /* handle overflow */
if (!Yap_growheap(FALSE)) {
if (!Yap_growheap(FALSE, 0)) {
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
return(FALSE);
}

View File

@ -10,7 +10,7 @@
* File: Yap.proto *
* mods: *
* comments: Function declarations for YAP *
* version: $Id: Yapproto.h,v 1.33 2003-03-20 15:10:17 vsc Exp $ *
* version: $Id: Yapproto.h,v 1.34 2003-05-19 13:04:08 vsc Exp $ *
*************************************************************************/
/* prototype file for Yap */
@ -154,7 +154,7 @@ void STD_PROTO(Yap_trust_last,(void));
/* grow.c */
Int STD_PROTO(Yap_total_stack_shift_time,(void));
void STD_PROTO(Yap_InitGrowPreds, (void));
int STD_PROTO(Yap_growheap, (int));
int STD_PROTO(Yap_growheap, (int, UInt));
int STD_PROTO(Yap_growstack, (long));
int STD_PROTO(Yap_growtrail, (long));
int STD_PROTO(Yap_growglobal, (CELL **));
@ -164,6 +164,7 @@ Int STD_PROTO(Yap_total_gc_time,(void));
void STD_PROTO(Yap_init_gc,(void));
int STD_PROTO(Yap_is_gc_verbose, (void));
int STD_PROTO(Yap_gc, (Int, CELL *, yamop *));
int STD_PROTO(Yap_gcl, (UInt, Int, CELL *, yamop *));
/* init.c */
#ifdef DEBUG

View File

@ -90,7 +90,7 @@ TEXI2PDF=texi2pdf
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
CWD=$(PWD)
#
VERSION=Yap-4.5.0
VERSION=Yap-4.5.1
#
TAG_HEADERS= Tags_32bits.h Tags_32Ops.h Tags_32LowTag.h\

4
README
View File

@ -1,10 +1,10 @@
README for Yap 4.3
README for Yap 4.5
This directory contains a release of the Yap 4.2 Prolog system,
This directory contains a release of the Yap 4.t Prolog system,
originally developed at the Universidade do Porto by Luis Damas and
Vitor Santos Costa, with contributions from the Edinburgh Prolog
library, the C-Prolog manual authors, Ricardo Rocha, and many

View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 *
* mods: *
* comments: main header file for YAP *
* version: $Id: Yap.h.m4,v 1.44 2003-04-30 17:44:18 vsc Exp $ *
* version: $Id: Yap.h.m4,v 1.45 2003-05-19 13:04:09 vsc Exp $ *
*************************************************************************/
#include "config.h"
@ -485,6 +485,7 @@ typedef enum {
extern char *Yap_ErrorMessage; /* used to pass error messages */
extern Term Yap_Error_Term; /* used to pass error terms */
extern yap_error_number Yap_Error_TYPE; /* used to pass the error */
extern UInt Yap_Error_Size; /* used to pass the error */
typedef enum {
YAP_INT_BOUNDED_FLAG = 0,

View File

@ -133,11 +133,14 @@ yap_flag(gc,on) :- !, '$set_value'('$gc',true).
yap_flag(gc,off) :- !, '$set_value'('$gc',[]).
yap_flag(gc_margin,N) :-
var(N) ->
'$get_value'('$gc_margin',N)
;
integer(N) ->
'$set_value'('$gc_margin',N).
( var(N) ->
'$get_value'('$gc_margin',N)
;
integer(N), N >0 ->
'$set_value'('$gc_margin',N)
;
'$do_error'(domain_error(flag_value,gc_margin+X),yap_flag(gc_margin,X))
).
yap_flag(gc_trace,V) :-
var(V), !,
'$get_value'('$gc_trace',N1),