fix reference counters when copying try-trust chains

fixes on memory allocation


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@912 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-10-30 22:52:46 +00:00
parent 4f97e338ab
commit 009452e075
4 changed files with 30 additions and 5 deletions

View File

@ -1197,13 +1197,15 @@ Yap_absmi(int inp)
FAIL();
}
}
setregs();
if (!Yap_IUnify(ARG2, t)) {
setregs();
FAIL();
}
if (!Yap_IUnify(ARG3, MkDBRefTerm((DBRef)cl))) {
setregs();
FAIL();
}
setregs();
#if defined(YAPOR) || defined(THREADS)
@ -1237,12 +1239,16 @@ Yap_absmi(int inp)
{
LogUpdClause *cl = ClauseCodeToLogUpdClause(PREG);
saveregs();
if (!Yap_IUnify(ARG2, cl->ClSource->Entry)) {
setregs();
FAIL();
}
if (!Yap_IUnify(ARG3, MkDBRefTerm((DBRef)cl))) {
setregs();
FAIL();
}
setregs();
/* say that an environment is using this clause */
/* we have our own copy for the clause */

View File

@ -12,7 +12,7 @@
* Last rev: *
* mods: *
* comments: allocating space *
* version:$Id: alloc.c,v 1.38 2003-10-30 11:31:05 vsc Exp $ *
* version:$Id: alloc.c,v 1.39 2003-10-30 22:52:46 vsc Exp $ *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
@ -1113,16 +1113,22 @@ Yap_InitMemory(int Trail, int Heap, int Stack)
int
Yap_ExtendWorkSpace(Int s)
{
#if USE_MMAP
return ExtendWorkSpace(s, MAP_FIXED);
#else
return ExtendWorkSpace(s);
#endif
}
UInt
Yap_ExtendWorkSpaceThroughHole(UInt s)
{
#if USE_MMAP
MALLOC_T WorkSpaceTop0 = WorkSpaceTop;
if (ExtendWorkSpace(s, 0))
return WorkSpaceTop-WorkSpaceTop0;
#endif
return -1;
}

View File

@ -4609,6 +4609,7 @@ cp_lu_trychain(yamop *codep, yamop *ocodep, yamop *ostart, int flag, PredEntry *
{
int count_reds = ap->PredFlags & CountPredFlag;
int profiled = ap->PredFlags & ProfiledPredFlag;
int compact_mode = (codep == ocodep);
while (ocodep != NULL &&
ocodep < ostart->u.Ill.l2) {
@ -4624,7 +4625,8 @@ cp_lu_trychain(yamop *codep, yamop *ocodep, yamop *ostart, int flag, PredEntry *
if (i == 0) {
if (op != _try_clause) {
LogUpdClause *tgl = ClauseCodeToLogUpdClause(ocodep->u.ld.d);
tgl->ClRefCount--;
if (compact_mode)
tgl->ClRefCount--;
}
codep->opc = Yap_opcode(_try_clause);
codep = copy_ld(codep, ocodep, ap, ocodep->u.ld.d, FALSE);
@ -4632,6 +4634,9 @@ cp_lu_trychain(yamop *codep, yamop *ocodep, yamop *ostart, int flag, PredEntry *
if (op == _try_clause) {
LogUpdClause *tgl = ClauseCodeToLogUpdClause(ocodep->u.ld.d);
tgl->ClRefCount++;
} else if (!compact_mode) {
LogUpdClause *tgl = ClauseCodeToLogUpdClause(ocodep->u.ld.d);
tgl->ClRefCount++;
}
codep = gen_lui_retry(codep, ocodep, profiled, count_reds, ap);
}
@ -4640,17 +4645,21 @@ cp_lu_trychain(yamop *codep, yamop *ocodep, yamop *ostart, int flag, PredEntry *
break;
case _trust:
if (i < ncls-1) goto do_retry;
if (!compact_mode) {
LogUpdClause *tgl = ClauseCodeToLogUpdClause(ocodep->u.ld.d);
tgl->ClRefCount++;
}
codep = gen_lui_trust(codep, ocodep, profiled, count_reds, ap, ocodep->u.ld.d, TRUE, nblk);
ocodep = NULL;
break;
case _retry_killed:
case _trust_killed:
{
if (compact_mode) {
LogUpdClause *tgl = ClauseCodeToLogUpdClause(ocodep->u.ld.d);
tgl->ClRefCount--;
ocodep = NEXTOP(ocodep, ld);
}
ocodep = NEXTOP(ocodep, ld);
break;
case _trust_logical_pred:
ocodep = NEXTOP(ocodep, l);

View File

@ -114,6 +114,10 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
vsc_count++;
#ifdef COMMENTED
if (vsc_count < 5646100000LL)
return;
if (vsc_count == 5646100441LL)
vsc_xstop = TRUE;
if (vsc_count < 2923351500LL) {
return;
}