From 642b498728df618494e9b9a4ff03cfc222103745 Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 5 Oct 2007 18:24:30 +0000 Subject: [PATCH] fix garbage collector and fix LeaveGoal git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1945 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/c_interface.c | 7 +++++-- C/exec.c | 4 ++-- C/heapgc.c | 15 ++++++++++++--- changes-5.1.html | 4 ++++ docs/yap.tex | 9 ++++----- library/system/sys.c | 7 +++++-- pl/utils.yap | 2 +- pl/yio.yap | 2 ++ 8 files changed, 35 insertions(+), 15 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index 8054939b8..6321259b2 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -10,8 +10,11 @@ * File: c_interface.c * * comments: c_interface primitives definition * * * -* Last rev: $Date: 2007-09-04 10:34:54 $,$Author: vsc $ * +* Last rev: $Date: 2007-10-05 18:24:30 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.96 2007/09/04 10:34:54 vsc +* Improve SWI interface emulation. +* * Revision 1.95 2007/06/04 12:28:01 vsc * interface speedups * bad error message in X is foo>>2. @@ -1273,7 +1276,7 @@ YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi) choiceptr myB; myB = (choiceptr)(LCL0-dgi->b); - if (B > myB) { + if (B >= myB) { return FALSE; } #ifdef YAPOR diff --git a/C/exec.c b/C/exec.c index c58510631..d469391df 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1989,14 +1989,14 @@ Yap_InitYaamRegs(void) /* for slots to work */ Yap_StartSlots(); GlobalArena = TermNil; -#if COROUTINING h0var = MkVarTerm(); +#if COROUTINING DelayedVars = Yap_NewTimedVar(h0var); WokenGoals = Yap_NewTimedVar(TermNil); AttsMutableList = Yap_NewTimedVar(h0var); GlobalDelayArena = TermNil; #endif - GcGeneration = Yap_NewTimedVar(MkIntTerm(0)); + GcGeneration = Yap_NewTimedVar(h0var); GcCurrentPhase = 0L; GcPhase = Yap_NewTimedVar(MkIntTerm(GcCurrentPhase)); #if defined(YAPOR) || defined(THREADS) diff --git a/C/heapgc.c b/C/heapgc.c index 7556d6df7..5e397c318 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -3065,6 +3065,8 @@ compact_heap(void) , &depfr #endif ); + if (GcCalls==355) + fprintf(stderr,"Start=%p,%p %d\n",H-1,H0,H-H0); for (current = H - 1; current >= start_from; current--) { if (MARKED_PTR(current)) { CELL ccell = UNMARK_CELL(*current); @@ -3491,6 +3493,10 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max) total_marked += total_oldies; } } else { + if (GcCalls==355) { + fprintf(stderr,"Start=%p,%pn %ld, %ld\n",H0,HGEN, total_oldies, total_marked); + + } if (HGEN != H0) { CurrentH0 = H0; H0 = HGEN; @@ -3682,7 +3688,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) iptop = (CELL_PTR *)H; #endif /* get the number of active registers */ - HGEN = H0+IntegerOfTerm(Yap_ReadTimedVar(GcGeneration)); + HGEN = VarOfTerm(Yap_ReadTimedVar(GcGeneration)); gc_phase = (UInt)IntegerOfTerm(Yap_ReadTimedVar(GcPhase)); /* old HGEN are not very reliable, but still may have data to recover */ @@ -3738,7 +3744,10 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) pop_registers(predarity, nextop); TR = new_TR; /* fprintf(Yap_stderr,"NEW HGEN %ld (%ld)\n", H-H0, HGEN-H0);*/ - Yap_UpdateTimedVar(GcGeneration, MkIntegerTerm(H-H0)); + { + Term t = MkVarTerm(); + Yap_UpdateTimedVar(GcGeneration, t); + } Yap_UpdateTimedVar(GcPhase, MkIntegerTerm(GcCurrentPhase)); c_time = Yap_cputime(); if (gc_verbose) { @@ -3830,7 +3839,7 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop) if (gc_margin < gc_lim) gc_margin = gc_lim; GcCalls++; - HGEN = H0+IntegerOfTerm(Yap_ReadTimedVar(GcGeneration)); + HGEN = VarOfTerm(Yap_ReadTimedVar(GcGeneration)); if (gc_on && !(Yap_PrologMode & InErrorMode) && /* make sure there is a point in collecting the heap */ (ASP-H0)*sizeof(CELL) > gc_lim && diff --git a/changes-5.1.html b/changes-5.1.html index ee1a0a692..5d4b24d4f 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -17,6 +17,10 @@

Yap-5.1.3: