more fixes
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@827 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
77b1c99030
commit
bd383b7e3f
@ -290,7 +290,7 @@ Yap_absmi(int inp)
|
|||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
restore_absmi_regs(old_regs);
|
restore_absmi_regs(old_regs);
|
||||||
#endif
|
#endif
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, 0)) {
|
||||||
saveregs();
|
saveregs();
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage);
|
||||||
setregs();
|
setregs();
|
||||||
@ -10208,7 +10208,7 @@ Yap_absmi(int inp)
|
|||||||
#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.ycx.c;
|
H[1] = XREG(PREG->u.ycx.c);
|
||||||
H[2] = XREG(PREG->u.ycx.xi);
|
H[2] = XREG(PREG->u.ycx.xi);
|
||||||
low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(Yap_MkFunctor(Yap_LookupAtom("functor"),3),0)),H);
|
low_level_trace(enter_pred,RepPredProp(Yap_GetPredPropByFunc(Yap_MkFunctor(Yap_LookupAtom("functor"),3),0)),H);
|
||||||
}
|
}
|
||||||
|
@ -2337,8 +2337,9 @@ do_pass(void)
|
|||||||
}
|
}
|
||||||
if (!pass_no) {
|
if (!pass_no) {
|
||||||
if (CellPtr(label_offset+cpc->rnd1) > ASP-256) {
|
if (CellPtr(label_offset+cpc->rnd1) > ASP-256) {
|
||||||
|
Yap_Error_Size = 256+((char *)(label_offset+cpc->rnd1) - (char *)H);
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(Yap_CompilerBotch,3);
|
longjmp(Yap_CompilerBotch, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (char *)(label_offset+cpc->rnd1) > freep)
|
if ( (char *)(label_offset+cpc->rnd1) > freep)
|
||||||
@ -2537,7 +2538,7 @@ Yap_assemble(int mode)
|
|||||||
size = (CELL)code_p;
|
size = (CELL)code_p;
|
||||||
}
|
}
|
||||||
while ((code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) {
|
while ((code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) {
|
||||||
if (!Yap_growheap(TRUE)) {
|
if (!Yap_growheap(TRUE, size)) {
|
||||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
|
|||||||
}
|
}
|
||||||
while ((p->ValueOfVE.floats = (Float *) Yap_AllocAtomSpace(asize) ) == NULL) {
|
while ((p->ValueOfVE.floats = (Float *) Yap_AllocAtomSpace(asize) ) == NULL) {
|
||||||
YAPLeaveCriticalSection();
|
YAPLeaveCriticalSection();
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, asize)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -455,7 +455,7 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star
|
|||||||
{
|
{
|
||||||
if (EndOfPAEntr(p)) {
|
if (EndOfPAEntr(p)) {
|
||||||
while ((p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p))) == NULL) {
|
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);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -591,7 +591,7 @@ YAP_AllocSpaceFromYap(unsigned int size)
|
|||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
if ((ptr = Yap_AllocCodeSpace(size)) == NULL) {
|
if ((ptr = Yap_AllocCodeSpace(size)) == NULL) {
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -763,7 +763,7 @@ static void expand_consult(void)
|
|||||||
ConsultCapacity += InitialConsultCapacity;
|
ConsultCapacity += InitialConsultCapacity;
|
||||||
/* I assume it always works ;-) */
|
/* I assume it always works ;-) */
|
||||||
while ((new_cl = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*ConsultCapacity)) == NULL) {
|
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);
|
Yap_Error(SYSTEM_ERROR,TermNil,Yap_ErrorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
24
C/compiler.c
24
C/compiler.c
@ -136,8 +136,9 @@ pop_code(unsigned int level)
|
|||||||
return;
|
return;
|
||||||
if (cpc->op == pop_op)
|
if (cpc->op == pop_op)
|
||||||
++(cpc->rnd1);
|
++(cpc->rnd1);
|
||||||
else
|
else {
|
||||||
Yap_emit(pop_op, One, Zero);
|
Yap_emit(pop_op, One, Zero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -556,8 +557,9 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level)
|
|||||||
}
|
}
|
||||||
c_arg(2, TailOfTerm(t), 2, level);
|
c_arg(2, TailOfTerm(t), 2, level);
|
||||||
--level;
|
--level;
|
||||||
if (argno != (Int)arity)
|
if (argno != (Int)arity) {
|
||||||
pop_code(level);
|
pop_code(level);
|
||||||
|
}
|
||||||
} else if (IsRefTerm(t)) {
|
} else if (IsRefTerm(t)) {
|
||||||
READ_LOCK(CurrentPred->PRWLock);
|
READ_LOCK(CurrentPred->PRWLock);
|
||||||
if (!(CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
|
if (!(CurrentPred->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
|
||||||
@ -595,9 +597,10 @@ c_arg(Int argno, Term t, unsigned int arity, unsigned int level)
|
|||||||
++level;
|
++level;
|
||||||
c_args(t, level);
|
c_args(t, level);
|
||||||
--level;
|
--level;
|
||||||
if (argno != (Int)arity)
|
if (argno != (Int)arity) {
|
||||||
pop_code(level);
|
pop_code(level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2682,6 +2685,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
|
|||||||
|
|
||||||
/* first, initialise Yap_CompilerBotch to handle all cases of interruptions */
|
/* first, initialise Yap_CompilerBotch to handle all cases of interruptions */
|
||||||
Yap_ErrorMessage = NULL;
|
Yap_ErrorMessage = NULL;
|
||||||
|
Yap_Error_Size = 0;
|
||||||
if ((botch_why = setjmp(Yap_CompilerBotch)) == 3) {
|
if ((botch_why = setjmp(Yap_CompilerBotch)) == 3) {
|
||||||
/* out of local stack, just duplicate the stack */
|
/* out of local stack, just duplicate the stack */
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
@ -2689,7 +2693,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
|
|||||||
{
|
{
|
||||||
Int osize = 2*sizeof(CELL)*(ASP-H);
|
Int osize = 2*sizeof(CELL)*(ASP-H);
|
||||||
ARG1 = my_clause;
|
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_TYPE = OUT_OF_STACK_ERROR;
|
||||||
Yap_Error_Term = my_clause;
|
Yap_Error_Term = my_clause;
|
||||||
}
|
}
|
||||||
@ -2723,7 +2727,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
|
|||||||
reset_vars();
|
reset_vars();
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
SaveH = H;
|
HB = H;
|
||||||
or_found = 0;
|
or_found = 0;
|
||||||
Yap_ErrorMessage = NULL;
|
Yap_ErrorMessage = NULL;
|
||||||
/* initialize variables for code generation */
|
/* initialize variables for code generation */
|
||||||
@ -2731,7 +2735,8 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
|
|||||||
BlobsStart = icpc = NULL;
|
BlobsStart = icpc = NULL;
|
||||||
freep = freep0 = (char *) (H + maxvnum);
|
freep = freep0 = (char *) (H + maxvnum);
|
||||||
if (ASP <= CellPtr (freep) + 256) {
|
if (ASP <= CellPtr (freep) + 256) {
|
||||||
vtable = NIL;
|
vtable = NULL;
|
||||||
|
Yap_Error_Size = (256+maxvnum)*sizeof(CELL);
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(Yap_CompilerBotch,3);
|
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
|
* 2000 added to H in case we need to construct call(G) when G is a
|
||||||
* variable used as a goal
|
* variable used as a goal
|
||||||
*/
|
*/
|
||||||
vtable = NIL;
|
vtable = NULL;
|
||||||
labelno = 0L;
|
labelno = 0L;
|
||||||
|
|
||||||
if (IsVarTerm(my_clause)) {
|
if (IsVarTerm(my_clause)) {
|
||||||
@ -2802,7 +2807,8 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
|
|||||||
BlobsStart = NULL;
|
BlobsStart = NULL;
|
||||||
}
|
}
|
||||||
reset_vars();
|
reset_vars();
|
||||||
H = SaveH;
|
H = HB;
|
||||||
|
HB = B->cp_h;
|
||||||
if (Yap_ErrorMessage)
|
if (Yap_ErrorMessage)
|
||||||
return (0);
|
return (0);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -2859,7 +2865,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod)
|
|||||||
if (acode == NIL) {
|
if (acode == NIL) {
|
||||||
/* make sure we have enough space */
|
/* make sure we have enough space */
|
||||||
reset_vars();
|
reset_vars();
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
my_clause = Deref(ARG1);
|
my_clause = Deref(ARG1);
|
||||||
longjmp(Yap_CompilerBotch, 2);
|
longjmp(Yap_CompilerBotch, 2);
|
||||||
|
@ -65,6 +65,7 @@ AllocCMem (int size)
|
|||||||
#endif
|
#endif
|
||||||
freep += size;
|
freep += size;
|
||||||
if (ASP <= CellPtr (freep) + 256) {
|
if (ASP <= CellPtr (freep) + 256) {
|
||||||
|
Yap_Error_Size = 256+((char *)freep - (char *)H);
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
longjmp(Yap_CompilerBotch,3);
|
longjmp(Yap_CompilerBotch,3);
|
||||||
}
|
}
|
||||||
@ -82,24 +83,21 @@ Yap_is_a_test_pred (Term arg, SMALLUNSGN mod)
|
|||||||
{
|
{
|
||||||
if (IsVarTerm (arg))
|
if (IsVarTerm (arg))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
else if (IsAtomTerm (arg))
|
else if (IsAtomTerm (arg)) {
|
||||||
{
|
|
||||||
Atom At = AtomOfTerm (arg);
|
Atom At = AtomOfTerm (arg);
|
||||||
PredEntry *pe = RepPredProp(PredPropByAtom(At, mod));
|
PredEntry *pe = RepPredProp(PredPropByAtom(At, mod));
|
||||||
if (EndOfPAEntr(pe))
|
if (EndOfPAEntr(pe))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
return (pe->PredFlags & TestPredFlag);
|
return (pe->PredFlags & TestPredFlag);
|
||||||
}
|
} else if (IsApplTerm (arg)) {
|
||||||
else if (IsApplTerm (arg))
|
|
||||||
{
|
|
||||||
Functor f = FunctorOfTerm (arg);
|
Functor f = FunctorOfTerm (arg);
|
||||||
PredEntry *pe = RepPredProp(PredPropByFunc(f, mod));
|
PredEntry *pe = RepPredProp(PredPropByFunc(f, mod));
|
||||||
if (EndOfPAEntr(pe))
|
if (EndOfPAEntr(pe))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
return (pe->PredFlags & TestPredFlag);
|
return (pe->PredFlags & TestPredFlag);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -110,11 +108,10 @@ Yap_emit (compiler_vm_op o, Int r1, CELL r2)
|
|||||||
p->op = o;
|
p->op = o;
|
||||||
p->rnd1 = r1;
|
p->rnd1 = r1;
|
||||||
p->rnd2 = r2;
|
p->rnd2 = r2;
|
||||||
p->nextInst = NIL;
|
p->nextInst = NULL;
|
||||||
if (cpc == NIL)
|
if (cpc == NIL) {
|
||||||
cpc = CodeStart = p;
|
cpc = CodeStart = p;
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
cpc->nextInst = p;
|
cpc->nextInst = p;
|
||||||
cpc = p;
|
cpc = p;
|
||||||
}
|
}
|
||||||
|
46
C/dbase.c
46
C/dbase.c
@ -940,6 +940,7 @@ static CELL *MkDBTerm(register CELL *pt0, register CELL *pt0_end,
|
|||||||
return(CodeMax);
|
return(CodeMax);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
Yap_Error_Size = 1024+((char *)AuxSp-(char *)HeapTop);
|
||||||
DBErrorFlag = OVF_ERROR_IN_DB;
|
DBErrorFlag = OVF_ERROR_IN_DB;
|
||||||
*vars_foundp = vars_found;
|
*vars_foundp = vars_found;
|
||||||
#ifdef RATIONAL_TREES
|
#ifdef RATIONAL_TREES
|
||||||
@ -1391,6 +1392,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
|||||||
CodeAbs++; /* We have one more cell */
|
CodeAbs++; /* We have one more cell */
|
||||||
CodeAbs += CellPtr(lr) - CellPtr(LinkAr);
|
CodeAbs += CellPtr(lr) - CellPtr(LinkAr);
|
||||||
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
||||||
|
Yap_Error_Size = (UInt)DBLength(CodeAbs);
|
||||||
DBErrorFlag = OVF_ERROR_IN_DB;
|
DBErrorFlag = OVF_ERROR_IN_DB;
|
||||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -1417,6 +1419,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
|||||||
if (tofref != TmpRefBase) {
|
if (tofref != TmpRefBase) {
|
||||||
CodeAbs += TmpRefBase - tofref + 1;
|
CodeAbs += TmpRefBase - tofref + 1;
|
||||||
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
||||||
|
Yap_Error_Size = (UInt)DBLength(CodeAbs);
|
||||||
DBErrorFlag = OVF_ERROR_IN_DB;
|
DBErrorFlag = OVF_ERROR_IN_DB;
|
||||||
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
Yap_ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -1437,6 +1440,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
|||||||
#endif
|
#endif
|
||||||
pp = AllocDBSpace(DBLength(CodeAbs));
|
pp = AllocDBSpace(DBLength(CodeAbs));
|
||||||
if (pp == NIL) {
|
if (pp == NIL) {
|
||||||
|
Yap_Error_Size = (UInt)DBLength(CodeAbs);
|
||||||
DBErrorFlag = OVF_ERROR_IN_DB;
|
DBErrorFlag = OVF_ERROR_IN_DB;
|
||||||
DBErrorNumber = SYSTEM_ERROR;
|
DBErrorNumber = SYSTEM_ERROR;
|
||||||
DBErrorTerm = TermNil;
|
DBErrorTerm = TermNil;
|
||||||
@ -1735,6 +1739,7 @@ p_rcda(void)
|
|||||||
if (!IsVarTerm(Deref(ARG3)))
|
if (!IsVarTerm(Deref(ARG3)))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record(MkFirst, t1, t2, Unsigned(0)));
|
TRef = MkDBRefTerm(record(MkFirst, t1, t2, Unsigned(0)));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
case NO_ERROR_IN_DB:
|
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");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -1774,6 +1779,7 @@ p_rcdap(void)
|
|||||||
if (!IsVarTerm(Deref(ARG3)))
|
if (!IsVarTerm(Deref(ARG3)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, Unsigned(0)));
|
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, Unsigned(0)));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
case NO_ERROR_IN_DB:
|
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");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -1823,6 +1829,7 @@ p_rcda_at(void)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record_at(MkFirst, DBRefOfTerm(t1), t2, Unsigned(0)));
|
TRef = MkDBRefTerm(record_at(MkFirst, DBRefOfTerm(t1), t2, Unsigned(0)));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
case NO_ERROR_IN_DB:
|
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");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -1862,6 +1869,7 @@ p_rcdz(void)
|
|||||||
if (!IsVarTerm(Deref(ARG3)))
|
if (!IsVarTerm(Deref(ARG3)))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record(MkLast, t1, t2, Unsigned(0)));
|
TRef = MkDBRefTerm(record(MkLast, t1, t2, Unsigned(0)));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
case NO_ERROR_IN_DB:
|
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");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -1901,6 +1909,7 @@ p_rcdzp(void)
|
|||||||
if (!IsVarTerm(Deref(ARG3)))
|
if (!IsVarTerm(Deref(ARG3)))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record(MkLast | MkCode, t1, t2, Unsigned(0)));
|
TRef = MkDBRefTerm(record(MkLast | MkCode, t1, t2, Unsigned(0)));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
case NO_ERROR_IN_DB:
|
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");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -1949,6 +1958,7 @@ p_rcdz_at(void)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record_at(MkLast, DBRefOfTerm(t1), t2, Unsigned(0)));
|
TRef = MkDBRefTerm(record_at(MkLast, DBRefOfTerm(t1), t2, Unsigned(0)));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
case NO_ERROR_IN_DB:
|
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");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recordz_at/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -1993,6 +2003,7 @@ p_rcdstatp(void)
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
mk_first = ((IntOfTerm(t3) % 4) == 2);
|
mk_first = ((IntOfTerm(t3) % 4) == 2);
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
if (mk_first)
|
if (mk_first)
|
||||||
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, MkIntTerm(0)));
|
TRef = MkDBRefTerm(record(MkFirst | MkCode, t1, t2, MkIntTerm(0)));
|
||||||
else
|
else
|
||||||
@ -2010,7 +2021,7 @@ p_rcdstatp(void)
|
|||||||
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in record_stat_source/3");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in record_stat_source/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -2037,6 +2048,7 @@ p_drcdap(void)
|
|||||||
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
|
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record(MkFirst | MkCode | WithRef,
|
TRef = MkDBRefTerm(record(MkFirst | MkCode | WithRef,
|
||||||
t1, t2, t4));
|
t1, t2, t4));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
@ -2052,7 +2064,7 @@ p_drcdap(void)
|
|||||||
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -2080,6 +2092,7 @@ p_drcdzp(void)
|
|||||||
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
|
if (IsVarTerm(t4) || !IsIntegerTerm(t4))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
TRef = MkDBRefTerm(record(MkLast | MkCode | WithRef,
|
TRef = MkDBRefTerm(record(MkLast | MkCode | WithRef,
|
||||||
t1, t2, t4));
|
t1, t2, t4));
|
||||||
switch(DBErrorFlag) {
|
switch(DBErrorFlag) {
|
||||||
@ -2095,7 +2108,7 @@ p_drcdzp(void)
|
|||||||
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -2120,6 +2133,7 @@ p_rcdaifnot(void)
|
|||||||
DBRef db_ref;
|
DBRef db_ref;
|
||||||
|
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
if (!IsVarTerm(Deref(ARG3)))
|
if (!IsVarTerm(Deref(ARG3)))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
found_one = NIL;
|
found_one = NIL;
|
||||||
@ -2140,7 +2154,7 @@ p_rcdaifnot(void)
|
|||||||
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -2162,6 +2176,7 @@ p_rcdzifnot(void)
|
|||||||
DBRef db_ref;
|
DBRef db_ref;
|
||||||
|
|
||||||
restart_record:
|
restart_record:
|
||||||
|
Yap_Error_Size = 0;
|
||||||
if (!IsVarTerm(Deref(ARG3)))
|
if (!IsVarTerm(Deref(ARG3)))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
found_one = NIL;
|
found_one = NIL;
|
||||||
@ -2182,7 +2197,7 @@ p_rcdzifnot(void)
|
|||||||
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else
|
} else
|
||||||
@ -2544,7 +2559,7 @@ nth_recorded_log(LogUpdDBProp AtProp, Int Count)
|
|||||||
} else {
|
} else {
|
||||||
if (AtProp->Index == NULL) {
|
if (AtProp->Index == NULL) {
|
||||||
while((AtProp->Index = new_lu_index(AtProp)) == 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);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
READ_UNLOCK(AtProp->DBRWLock);
|
READ_UNLOCK(AtProp->DBRWLock);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2732,7 +2747,7 @@ i_log_upd_recorded(LogUpdDBProp AtProp)
|
|||||||
} else {
|
} else {
|
||||||
if (AtProp->Index == NULL) {
|
if (AtProp->Index == NULL) {
|
||||||
while((AtProp->Index = new_lu_index(AtProp)) == 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);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -4262,6 +4277,7 @@ StoreTermInDB(int arg, int nargs)
|
|||||||
{
|
{
|
||||||
DBRef x;
|
DBRef x;
|
||||||
Term t = Deref(XREGS[arg]);
|
Term t = Deref(XREGS[arg]);
|
||||||
|
Yap_Error_Size = 0;
|
||||||
|
|
||||||
while ((x = CreateDBStruct(t, (DBProp)NIL,
|
while ((x = CreateDBStruct(t, (DBProp)NIL,
|
||||||
InQueue)) == NULL) {
|
InQueue)) == NULL) {
|
||||||
@ -4283,7 +4299,7 @@ StoreTermInDB(int arg, int nargs)
|
|||||||
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
Yap_Error(SYSTEM_ERROR, TermNil, "YAP could not grow trail in recorda/3");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
case OVF_ERROR_IN_DB:
|
case OVF_ERROR_IN_DB:
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, Yap_Error_Size)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
} else {
|
} else {
|
||||||
@ -4311,7 +4327,7 @@ p_init_queue(void)
|
|||||||
Term t;
|
Term t;
|
||||||
|
|
||||||
while ((dbq = (db_queue *)AllocDBSpace(sizeof(db_queue))) == NULL) {
|
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);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
8
C/grow.c
8
C/grow.c
@ -644,12 +644,15 @@ fix_tabling_info(void)
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
int
|
int
|
||||||
Yap_growheap(int fix_code)
|
Yap_growheap(int fix_code, UInt in_size)
|
||||||
{
|
{
|
||||||
unsigned long size = sizeof(CELL) * 16 * 1024L;
|
unsigned long size = sizeof(CELL) * 16 * 1024L;
|
||||||
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
|
int shift_factor = (heap_overflows > 8 ? 8 : heap_overflows);
|
||||||
unsigned long sz = size << shift_factor;
|
unsigned long sz = size << shift_factor;
|
||||||
|
|
||||||
|
if (sz < in_size) {
|
||||||
|
sz = in_size;
|
||||||
|
}
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
if (NOfThreads != 1) {
|
if (NOfThreads != 1) {
|
||||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
|
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)) {
|
while(sz >= sizeof(CELL) * 16 * 1024L && !static_growheap(sz, fix_code)) {
|
||||||
size = size/2;
|
size = size/2;
|
||||||
sz = size << shift_factor;
|
sz = size << shift_factor;
|
||||||
|
if (sz < in_size) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* we must fix an instruction chain */
|
/* we must fix an instruction chain */
|
||||||
if (fix_code) {
|
if (fix_code) {
|
||||||
|
55
C/heapgc.c
55
C/heapgc.c
@ -3050,7 +3050,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
|||||||
}
|
}
|
||||||
if (HeapTop >= Yap_GlobalBase - MinHeapGap) {
|
if (HeapTop >= Yap_GlobalBase - MinHeapGap) {
|
||||||
*--ASP = (CELL)current_env;
|
*--ASP = (CELL)current_env;
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, MinHeapGap)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -3155,10 +3155,10 @@ p_inform_gc(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
|
call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
|
||||||
{
|
{
|
||||||
Int gc_margin = 128;
|
UInt gc_margin = 128;
|
||||||
Term Tgc_margin;
|
Term Tgc_margin;
|
||||||
Int effectiveness = 0;
|
Int effectiveness = 0;
|
||||||
int gc_on = FALSE;
|
int gc_on = FALSE;
|
||||||
@ -3171,39 +3171,34 @@ Yap_gc(Int predarity, CELL *current_env, yamop *nextop)
|
|||||||
#endif
|
#endif
|
||||||
if (Yap_GetValue(AtomGc) != TermNil)
|
if (Yap_GetValue(AtomGc) != TermNil)
|
||||||
gc_on = TRUE;
|
gc_on = TRUE;
|
||||||
if (IsIntTerm(Tgc_margin = Yap_GetValue(AtomGcMargin))) {
|
if (IsIntegerTerm(Tgc_margin = Yap_GetValue(AtomGcMargin)) &&
|
||||||
gc_margin = IntOfTerm(Tgc_margin);
|
gc_margin > 0) {
|
||||||
|
gc_margin = (UInt)IntegerOfTerm(Tgc_margin);
|
||||||
} else {
|
} else {
|
||||||
|
/* only go exponential for the first 8 calls */
|
||||||
if (gc_calls < 8)
|
if (gc_calls < 8)
|
||||||
gc_margin <<= gc_calls;
|
gc_margin <<= gc_calls;
|
||||||
else
|
else {
|
||||||
|
/* next grow linearly */
|
||||||
gc_margin <<= 8;
|
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) {
|
if (gc_on) {
|
||||||
effectiveness = do_gc(predarity, current_env, nextop);
|
effectiveness = do_gc(predarity, current_env, nextop);
|
||||||
}
|
|
||||||
if (effectiveness > 90) {
|
if (effectiveness > 90) {
|
||||||
while (gc_margin < H-H0)
|
while (gc_margin < H-H0)
|
||||||
gc_margin <<= 1;
|
gc_margin <<= 1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
effectiveness = 0;
|
||||||
|
}
|
||||||
/* expand the stack if effectiveness is less than 20 % */
|
/* expand the stack if effectiveness is less than 20 % */
|
||||||
if (ASP - H < gc_margin || !gc_on || effectiveness < 20) {
|
if (ASP - H < gc_margin ||
|
||||||
Int gap = CalculateStackGap();
|
effectiveness < 20) {
|
||||||
if (ASP-H > gc_margin)
|
return (Yap_growstack(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);
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* debug for(save_total=1; save_total<=N; ++save_total)
|
* 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 );
|
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
|
static Int
|
||||||
p_gc(void)
|
p_gc(void)
|
||||||
|
14
C/index.c
14
C/index.c
@ -1031,6 +1031,7 @@ add_info(ClauseDef *clause, UInt regno)
|
|||||||
case _get_x_var:
|
case _get_x_var:
|
||||||
if (regcopy_in(myregs, nofregs, cl->u.xx.xr)) {
|
if (regcopy_in(myregs, nofregs, cl->u.xx.xr)) {
|
||||||
nofregs = add_regcopy(myregs, nofregs, cl->u.xx.xl);
|
nofregs = add_regcopy(myregs, nofregs, cl->u.xx.xl);
|
||||||
|
cl = NEXTOP(cl,xx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _put_x_var:
|
case _put_x_var:
|
||||||
@ -2686,10 +2687,15 @@ compile_index(PredEntry *ap)
|
|||||||
int NClauses = ap->cs.p_code.NOfClauses;
|
int NClauses = ap->cs.p_code.NOfClauses;
|
||||||
ClauseDef *cls = (ClauseDef *)H;
|
ClauseDef *cls = (ClauseDef *)H;
|
||||||
CELL *top = (CELL *) TR;
|
CELL *top = (CELL *) TR;
|
||||||
|
|
||||||
/* only global variable I use directly */
|
/* only global variable I use directly */
|
||||||
labelno = 1;
|
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 */
|
/* grow stack */
|
||||||
longjmp(Yap_CompilerBotch,3);
|
longjmp(Yap_CompilerBotch,3);
|
||||||
}
|
}
|
||||||
@ -2710,10 +2716,10 @@ Yap_PredIsIndexable(PredEntry *ap)
|
|||||||
{
|
{
|
||||||
yamop *indx_out;
|
yamop *indx_out;
|
||||||
|
|
||||||
|
Yap_Error_Size = 0;
|
||||||
if (setjmp(Yap_CompilerBotch) == 3) {
|
if (setjmp(Yap_CompilerBotch) == 3) {
|
||||||
/* just duplicate the stack */
|
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
Yap_gc(ap->ArityOfPE, ENV, CP);
|
Yap_gcl(Yap_Error_Size, ap->ArityOfPE, ENV, CP);
|
||||||
}
|
}
|
||||||
restart_index:
|
restart_index:
|
||||||
Yap_ErrorMessage = NULL;
|
Yap_ErrorMessage = NULL;
|
||||||
@ -2729,7 +2735,7 @@ Yap_PredIsIndexable(PredEntry *ap)
|
|||||||
CurrentPred = ap;
|
CurrentPred = ap;
|
||||||
IPredArity = ap->ArityOfPE;
|
IPredArity = ap->ArityOfPE;
|
||||||
if ((indx_out = Yap_assemble(ASSEMBLING_INDEX)) == NULL) {
|
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);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
1
C/init.c
1
C/init.c
@ -84,6 +84,7 @@ ADDR Yap_HeapBase,
|
|||||||
char *Yap_ErrorMessage; /* used to pass error messages */
|
char *Yap_ErrorMessage; /* used to pass error messages */
|
||||||
Term Yap_Error_Term; /* used to pass error terms */
|
Term Yap_Error_Term; /* used to pass error terms */
|
||||||
yap_error_number Yap_Error_TYPE; /* used to pass the error */
|
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 *****/
|
/********* readline support *****/
|
||||||
#if HAVE_LIBREADLINE
|
#if HAVE_LIBREADLINE
|
||||||
|
@ -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) {
|
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);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -2058,7 +2058,7 @@ p_open_mem_write_stream (void) /* $open_mem_write_stream(-Stream) */
|
|||||||
extern int Yap_page_size;
|
extern int Yap_page_size;
|
||||||
|
|
||||||
while ((nbuf = (char *)Yap_AllocAtomSpace(Yap_page_size*sizeof(char))) == NULL) {
|
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);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -4833,7 +4833,7 @@ p_char_conversion(void)
|
|||||||
return(TRUE);
|
return(TRUE);
|
||||||
CharConversionTable2 = Yap_AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char));
|
CharConversionTable2 = Yap_AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char));
|
||||||
while (CharConversionTable2 == NULL) {
|
while (CharConversionTable2 == NULL) {
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, NUMBER_OF_CHARS*sizeof(char))) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
2
C/save.c
2
C/save.c
@ -650,7 +650,7 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap)
|
|||||||
if (Yap_ErrorMessage)
|
if (Yap_ErrorMessage)
|
||||||
return(FAIL_RESTORE);
|
return(FAIL_RESTORE);
|
||||||
while (Yap_HeapBase != NULL && hp_size > Unsigned(AuxTop) - Unsigned(Yap_HeapBase)) {
|
while (Yap_HeapBase != NULL && hp_size > Unsigned(AuxTop) - Unsigned(Yap_HeapBase)) {
|
||||||
if(!Yap_growheap(FALSE)) {
|
if(!Yap_growheap(FALSE, hp_size)) {
|
||||||
return(FAIL_RESTORE);
|
return(FAIL_RESTORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -853,7 +853,7 @@ p_atom_concat(void)
|
|||||||
sz = strlen(atom_str);
|
sz = strlen(atom_str);
|
||||||
if (cptr+sz >= top-1024) {
|
if (cptr+sz >= top-1024) {
|
||||||
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
|
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, sz+1024)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ CopyTerm(Term inp) {
|
|||||||
t = Deref(ARG1);
|
t = Deref(ARG1);
|
||||||
goto restart_attached;
|
goto restart_attached;
|
||||||
} else { /* handle overflow */
|
} else { /* handle overflow */
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, 0)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ CopyTerm(Term inp) {
|
|||||||
t = Deref(ARG1);
|
t = Deref(ARG1);
|
||||||
goto restart_list;
|
goto restart_list;
|
||||||
} else { /* handle overflow */
|
} else { /* handle overflow */
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, 0)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@ CopyTerm(Term inp) {
|
|||||||
t = Deref(ARG1);
|
t = Deref(ARG1);
|
||||||
goto restart_appl;
|
goto restart_appl;
|
||||||
} else { /* handle overflow */
|
} else { /* handle overflow */
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, 0)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -625,7 +625,7 @@ CopyTermNoDelays(Term inp) {
|
|||||||
t = Deref(ARG1);
|
t = Deref(ARG1);
|
||||||
goto restart_list;
|
goto restart_list;
|
||||||
} else { /* handle overflow */
|
} else { /* handle overflow */
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, 0)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@ -657,7 +657,7 @@ CopyTermNoDelays(Term inp) {
|
|||||||
t = Deref(ARG1);
|
t = Deref(ARG1);
|
||||||
goto restart_appl;
|
goto restart_appl;
|
||||||
} else { /* handle overflow */
|
} else { /* handle overflow */
|
||||||
if (!Yap_growheap(FALSE)) {
|
if (!Yap_growheap(FALSE, 0)) {
|
||||||
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* File: Yap.proto *
|
* File: Yap.proto *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Function declarations for YAP *
|
* 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 */
|
/* prototype file for Yap */
|
||||||
@ -154,7 +154,7 @@ void STD_PROTO(Yap_trust_last,(void));
|
|||||||
/* grow.c */
|
/* grow.c */
|
||||||
Int STD_PROTO(Yap_total_stack_shift_time,(void));
|
Int STD_PROTO(Yap_total_stack_shift_time,(void));
|
||||||
void STD_PROTO(Yap_InitGrowPreds, (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_growstack, (long));
|
||||||
int STD_PROTO(Yap_growtrail, (long));
|
int STD_PROTO(Yap_growtrail, (long));
|
||||||
int STD_PROTO(Yap_growglobal, (CELL **));
|
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));
|
void STD_PROTO(Yap_init_gc,(void));
|
||||||
int STD_PROTO(Yap_is_gc_verbose, (void));
|
int STD_PROTO(Yap_is_gc_verbose, (void));
|
||||||
int STD_PROTO(Yap_gc, (Int, CELL *, yamop *));
|
int STD_PROTO(Yap_gc, (Int, CELL *, yamop *));
|
||||||
|
int STD_PROTO(Yap_gcl, (UInt, Int, CELL *, yamop *));
|
||||||
|
|
||||||
/* init.c */
|
/* init.c */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -90,7 +90,7 @@ TEXI2PDF=texi2pdf
|
|||||||
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
|
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
|
||||||
CWD=$(PWD)
|
CWD=$(PWD)
|
||||||
#
|
#
|
||||||
VERSION=Yap-4.5.0
|
VERSION=Yap-4.5.1
|
||||||
#
|
#
|
||||||
|
|
||||||
TAG_HEADERS= Tags_32bits.h Tags_32Ops.h Tags_32LowTag.h\
|
TAG_HEADERS= Tags_32bits.h Tags_32Ops.h Tags_32LowTag.h\
|
||||||
|
4
README
4
README
@ -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
|
originally developed at the Universidade do Porto by Luis Damas and
|
||||||
Vitor Santos Costa, with contributions from the Edinburgh Prolog
|
Vitor Santos Costa, with contributions from the Edinburgh Prolog
|
||||||
library, the C-Prolog manual authors, Ricardo Rocha, and many
|
library, the C-Prolog manual authors, Ricardo Rocha, and many
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* File: Yap.h.m4 *
|
* File: Yap.h.m4 *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: main header file for YAP *
|
* 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"
|
#include "config.h"
|
||||||
@ -485,6 +485,7 @@ typedef enum {
|
|||||||
extern char *Yap_ErrorMessage; /* used to pass error messages */
|
extern char *Yap_ErrorMessage; /* used to pass error messages */
|
||||||
extern Term Yap_Error_Term; /* used to pass error terms */
|
extern Term Yap_Error_Term; /* used to pass error terms */
|
||||||
extern yap_error_number Yap_Error_TYPE; /* used to pass the error */
|
extern yap_error_number Yap_Error_TYPE; /* used to pass the error */
|
||||||
|
extern UInt Yap_Error_Size; /* used to pass the error */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
YAP_INT_BOUNDED_FLAG = 0,
|
YAP_INT_BOUNDED_FLAG = 0,
|
||||||
|
@ -133,11 +133,14 @@ yap_flag(gc,on) :- !, '$set_value'('$gc',true).
|
|||||||
yap_flag(gc,off) :- !, '$set_value'('$gc',[]).
|
yap_flag(gc,off) :- !, '$set_value'('$gc',[]).
|
||||||
|
|
||||||
yap_flag(gc_margin,N) :-
|
yap_flag(gc_margin,N) :-
|
||||||
var(N) ->
|
( var(N) ->
|
||||||
'$get_value'('$gc_margin',N)
|
'$get_value'('$gc_margin',N)
|
||||||
;
|
;
|
||||||
integer(N) ->
|
integer(N), N >0 ->
|
||||||
'$set_value'('$gc_margin',N).
|
'$set_value'('$gc_margin',N)
|
||||||
|
;
|
||||||
|
'$do_error'(domain_error(flag_value,gc_margin+X),yap_flag(gc_margin,X))
|
||||||
|
).
|
||||||
yap_flag(gc_trace,V) :-
|
yap_flag(gc_trace,V) :-
|
||||||
var(V), !,
|
var(V), !,
|
||||||
'$get_value'('$gc_trace',N1),
|
'$get_value'('$gc_trace',N1),
|
||||||
|
Reference in New Issue
Block a user