fix bad consult stack expansion

This commit is contained in:
Vitor Santos Costa 2016-05-14 11:27:53 +01:00
parent c0db3d4e18
commit d86f0d1942
1 changed files with 9 additions and 6 deletions

View File

@ -1347,9 +1347,9 @@ static void expand_consult(void) {
/* next, set up pointers correctly */
new_cs += (LOCAL_ConsultSp - LOCAL_ConsultLow);
/* put LOCAL_ConsultBase at same offset as before move */
LOCAL_ConsultBase = LOCAL_ConsultBase + (new_cs - LOCAL_ConsultSp);
/* new consult pointer */
LOCAL_ConsultSp = new_cs;
LOCAL_ConsultBase = new_cl + ((LOCAL_ConsultBase - LOCAL_ConsultLow)+InitialConsultCapacity);
/* new consult pointer */
LOCAL_ConsultSp = new_cl + ((LOCAL_ConsultSp - LOCAL_ConsultLow)+InitialConsultCapacity);
/* new end of memory */
LOCAL_ConsultLow = new_cl;
}
@ -1389,9 +1389,9 @@ static int not_was_reconsulted(PredEntry *p, Term t, int mode) {
//%s\n",NameOfFunctor(p->FunctorOfPred)->StrOfAE,p->src.OwnerFile->StrOfAE);
}
if (mode) {
if (LOCAL_ConsultSp == LOCAL_ConsultLow + 1) {
expand_consult();
}
if (LOCAL_ConsultSp <= LOCAL_ConsultLow + 6) {
expand_consult();
}
--LOCAL_ConsultSp;
LOCAL_ConsultSp->p = p0;
if (LOCAL_ConsultBase[1].mode &&
@ -2001,6 +2001,9 @@ static void init_consult(int mode, const unsigned char *file) {
if (!LOCAL_ConsultSp) {
InitConsultStack();
}
if (LOCAL_ConsultSp >= LOCAL_ConsultLow + 6) {
expand_consult();
}
LOCAL_ConsultSp--;
LOCAL_ConsultSp->filename = file;
LOCAL_ConsultSp--;