From 23e9f546fe5ce4052c5e1eb2f24a540c0d8b3102 Mon Sep 17 00:00:00 2001 From: vsc Date: Mon, 16 Oct 2006 17:12:48 +0000 Subject: [PATCH] fixes for threaded version. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1705 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/cdmgr.c | 13 +++++++++---- C/grow.c | 6 +++++- C/index.c | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/C/cdmgr.c b/C/cdmgr.c index b64126eba..d174b1fdb 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -11,8 +11,12 @@ * File: cdmgr.c * * comments: Code manager * * * -* Last rev: $Date: 2006-10-11 17:24:36 $,$Author: vsc $ * +* Last rev: $Date: 2006-10-16 17:12:48 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.195 2006/10/11 17:24:36 vsc +* make sure we only follow pointers *before* we removed the respective code block, +* ie don't kill the child before checking pointers from parent! +* * Revision 1.194 2006/10/11 15:08:03 vsc * fix bb entries * comment development code for timestamp overflow. @@ -887,7 +891,7 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code while (ipc) { op_numbers op = Yap_op_from_opcode(ipc->opc); - /* printf("op: %d %p->%p\n", op, ipc, end); */ + /* fprintf(stderr,"op: %d %p->%p\n", op, ipc, end);*/ switch(op) { case _Ystop: /* end of clause, for now */ @@ -957,9 +961,10 @@ cleanup_dangling_indices(yamop *ipc, yamop *beg, yamop *end, yamop *suspend_code #endif decrease_ref_counter(ipc->u.lld.d->ClCode, beg, end, suspend_code); Yap_FreeCodeSpace((ADDR)ipc); + end = ipc; return; case _enter_lu_pred: - if (ipc->u.Ill.I->ClFlags & InUseMask) + if (ipc->u.Ill.I->ClFlags & InUseMask || ipc->u.Ill.I->ClRefCount) return; #ifdef DEBUG Yap_DirtyCps+=ipc->u.Ill.s; @@ -1144,6 +1149,7 @@ kill_off_lu_block(LogUpdIndex *c, LogUpdIndex *parent, PredEntry *ap) static void kill_first_log_iblock(LogUpdIndex *c, LogUpdIndex *parent, PredEntry *ap) { + decrease_log_indices(c, (yamop *)&(ap->cs.p_code.ExpandCode)); /* parent is always locked, now I lock myself */ if (parent != NULL) { /* remove myself from parent */ @@ -1168,7 +1174,6 @@ kill_first_log_iblock(LogUpdIndex *c, LogUpdIndex *parent, PredEntry *ap) RemoveMainIndex(ap); } } - decrease_log_indices(c, (yamop *)&(ap->cs.p_code.ExpandCode)); /* make sure that a child cannot remove us */ kill_children(c, ap); /* check if we are still the main index */ diff --git a/C/grow.c b/C/grow.c index d1dcb53fd..eb6c89e20 100644 --- a/C/grow.c +++ b/C/grow.c @@ -199,7 +199,7 @@ MoveExpandedGlobal(void) * cpcellsd(To,From,NOfCells) - copy the cells downwards - in * absmi.asm */ - cpcellsd((CELL *)(Yap_GlobalBase+(GDiff-DelayDiff)), (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase); + cpcellsd((CELL *)(Yap_GlobalBase+(GDiff-DelayDiff)), (CELL *)Yap_GlobalBase, OldH - (CELL *)OldGlobalBase); } static void @@ -209,7 +209,11 @@ MoveGlobalWithHole(void) * cpcellsd(To,From,NOfCells) - copy the cells downwards - in * absmi.asm */ +#if USE_SYSTEM_MALLOC + cpcellsd((CELL *)((char *)Yap_GlobalBase+(GDiff0-DelayDiff)), (CELL *)Yap_GlobalBase, OldH - (CELL *)OldGlobalBase); +#else cpcellsd((CELL *)((char *)OldGlobalBase+GDiff0), (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase); +#endif } static void diff --git a/C/index.c b/C/index.c index f4f3c4b5d..53c34e4af 100644 --- a/C/index.c +++ b/C/index.c @@ -11,8 +11,13 @@ * File: index.c * * comments: Indexing a Prolog predicate * * * -* Last rev: $Date: 2006-10-11 14:53:57 $,$Author: vsc $ * +* Last rev: $Date: 2006-10-16 17:12:48 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.171 2006/10/11 14:53:57 vsc +* fix memory leak +* fix overflow handling +* VS: ---------------------------------------------------------------------- +* * Revision 1.170 2006/10/10 14:08:16 vsc * small fixes on threaded implementation. * @@ -6236,6 +6241,10 @@ kill_clause(yamop *ipc, yamop *bg, yamop *lt, path_stack_entry *sp0, PredEntry * blk = (LogUpdIndex *)(sp->u.cle.block); start = blk->ClCode; op0 = Yap_op_from_opcode(start->opc); + while (op0 == _lock_lu) { + start = NEXTOP(start, p); + op0 = Yap_op_from_opcode(start->opc); + } while (op0 == _jump_if_nonvar) { start = NEXTOP(start, xll); op0 = Yap_op_from_opcode(start->opc); @@ -8373,6 +8382,10 @@ Yap_CleanUpIndex(LogUpdIndex *blk) op_numbers op = Yap_op_from_opcode(start->opc); blk->ClFlags &= ~DirtyMask; + while (op == _lock_lu) { + start = NEXTOP(start, p); + op = Yap_op_from_opcode(start->opc); + } while (op == _jump_if_nonvar) { start = NEXTOP(start, xll); op = Yap_op_from_opcode(start->opc);