call gc if we set dead mega clauses.

This commit is contained in:
Vítor Santos Costa 2012-04-23 23:28:41 +01:00
parent 5b443bdc46
commit c3eb3db4ed

View File

@ -2654,6 +2654,7 @@ p_purge_clauses( USES_REGS1 )
PredEntry *pred;
Term t = Deref(ARG1);
Term mod = Deref(ARG2);
MegaClause *before = DeadMegaClauses;
Yap_PutValue(AtomAbol, MkAtomTerm(AtomNil));
if (IsVarTerm(t))
@ -2677,7 +2678,15 @@ p_purge_clauses( USES_REGS1 )
}
purge_clauses(pred);
UNLOCKPE(34,pred);
return (TRUE);
/* try to use the garbage collector to recover the mega clause,
in case the objs pointing to it are dead themselves */
if (DeadMegaClauses != before) {
if (!Yap_gc(2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return FALSE;
}
}
return TRUE;
}
/******************************************************************