From cb34dbdc886e2eeea80f42daa488366765ff5ec0 Mon Sep 17 00:00:00 2001 From: vsc Date: Wed, 18 Oct 2006 13:47:32 +0000 Subject: [PATCH] index.c implementation of trust_logical was decrementing the wrong cp_tr git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1706 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/absmi.c | 15 ++++++++++----- C/index.c | 9 ++++++--- C/tracer.c | 7 +++++++ pl/boot.yap | 15 +++++++-------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index c77c4d97c..a8560995b 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -10,8 +10,13 @@ * * * File: absmi.c * * comments: Portable abstract machine interpreter * -* Last rev: $Date: 2006-10-11 14:53:57 $,$Author: vsc $ * +* Last rev: $Date: 2006-10-18 13:47:31 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.208 2006/10/11 14:53:57 vsc +* fix memory leak +* fix overflow handling +* VS: ---------------------------------------------------------------------- +* * Revision 1.207 2006/10/10 20:21:42 vsc * fix new indexing code to actually recover space * fix predicate info to work for LUs @@ -962,7 +967,7 @@ Yap_absmi(int inp) LOCK(cl->ClLock); DEC_CLREF_COUNT(cl); /* clear the entry from the trail */ - TR = --(B->cp_tr); + TR = B->cp_tr-1; /* actually get rid of the code */ if (cl->ClRefCount == 0 && (cl->ClFlags & (ErasedMask|DirtyMask))) { UNLOCK(cl->ClLock); @@ -1276,7 +1281,7 @@ Yap_absmi(int inp) LOCK(cl->ClLock); DEC_CLREF_COUNT(cl); /* clear the entry from the trail */ - TR = --(B->cp_tr); + TR = B->cp_tr-1; /* actually get rid of the code */ if (cl->ClRefCount == 0 && (cl->ClFlags & (ErasedMask|DirtyMask))) { UNLOCK(cl->ClLock); @@ -1305,7 +1310,7 @@ Yap_absmi(int inp) if (TrailTerm(B->cp_tr-1) == CLREF_TO_TRENTRY(cl) && B->cp_tr != B->cp_b->cp_tr) { cl->ClFlags &= ~InUseMask; - TR = --B->cp_tr; + TR = B->cp_tr-1; /* next, recover space for the indexing code if it was erased */ if (cl->ClFlags & (ErasedMask|DirtyMask)) { if (PREG != FAILCODE) { @@ -8076,7 +8081,7 @@ Yap_absmi(int inp) LOCK(cl->ClLock); DEC_CLREF_COUNT(cl); /* clear the entry from the trail */ - TR = --(B->cp_tr); + TR = B->cp_tr-1; /* actually get rid of the code */ if (cl->ClRefCount == 0 && (cl->ClFlags & (ErasedMask|DirtyMask))) { UNLOCK(cl->ClLock); diff --git a/C/index.c b/C/index.c index 53c34e4af..fb031dc73 100644 --- a/C/index.c +++ b/C/index.c @@ -11,8 +11,11 @@ * File: index.c * * comments: Indexing a Prolog predicate * * * -* Last rev: $Date: 2006-10-16 17:12:48 $,$Author: vsc $ * +* Last rev: $Date: 2006-10-18 13:47:31 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.172 2006/10/16 17:12:48 vsc +* fixes for threaded version. +* * Revision 1.171 2006/10/11 14:53:57 vsc * fix memory leak * fix overflow handling @@ -7848,6 +7851,8 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y UInt timestamp = ((CELL *)(B+1))[5]; LogUpdIndex *cl = ipc->u.lld.t.block; + /* clear the entry from the trail */ + TR = B->cp_tr-1; #ifdef CUT_C { while (POP_CHOICE_POINT(B->cp_b)) @@ -7870,8 +7875,6 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y #if defined(YAPOR) || defined(THREADS) LOCK(cl->ClLock); DEC_CLREF_COUNT(cl); - /* clear the entry from the trail */ - TR = --(B->cp_tr); /* actually get rid of the code */ if (cl->ClRefCount == 0 && cl->ClFlags & (ErasedMask|DirtyMask)) { UNLOCK(cl->ClLock); diff --git a/C/tracer.c b/C/tracer.c index 0c2c9c9bf..f2a70a169 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -161,6 +161,13 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) LOCK(Yap_heap_regs->low_level_trace_lock); sc = Yap_heap_regs; vsc_count++; + if (B->cp_tr < B->cp_b->cp_tr || TR < B->cp_tr) + fprintf(stderr,"Here we go %lld\n", vsc_count); + if (vsc_count < 13600) + { + UNLOCK(Yap_heap_regs->low_level_trace_lock); + return; + } #ifdef COMMENTED if (worker_id != 04 || worker_id != 03) return; // if (vsc_count == 218280) diff --git a/pl/boot.yap b/pl/boot.yap index 321b6a3a2..37614a840 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -940,14 +940,14 @@ bootstrap(F) :- '$dir_separator'(D), atom_codes(A,[D]), '$system_library_directories'(Dir), - '$extend_path'(Dir,A,File,NFile), + '$extend_path'(Dir, A, File, NFile, Goal), '$search_in_path'(NFile, NewFile), !. '$find_in_path'(S,NewFile, _) :- S =.. [Name,File], !, '$dir_separator'(D), atom_codes(A,[D]), ( user:file_search_path(Name, Dir), '$do_not_creep' ; '$do_not_creep', fail), - '$extend_path'(Dir,A,File,NFile), + '$extend_path'(Dir, A, File, NFile, Goal), '$search_in_path'(NFile, NewFile), !. '$find_in_path'(File,NewFile,_) :- atom(File), !, '$search_in_path'(File,NewFile),!. @@ -961,15 +961,14 @@ bootstrap(F) :- atom_concat([Path,File],New), '$exists'(New,'$csult'). -'$extend_path'(Dir,A,File,NFile) :- +'$extend_path'(Dir, A, File, NFile, _) :- atom(Dir), !, atom_concat([Dir,A,File],NFile). -'$extend_path'(Name,A,File,NFile) :- +'$extend_path'(Name, A, File, NFile, Goal) :- nonvar(Name), - Name =.. [Dir1,Dir2], - ( user:file_search_path(Dir1, Dir), '$do_not_creep' ; '$do_not_creep', fail), - '$extend_path'(Dir2,A,File,EFile), - atom_concat([Dir,A,EFile],NFile). + Name =.. [_,_], + '$find_in_path'(Name, Path, Goal), + '$extend_path'(Path, A, File, NFile, Goal). % term expansion %