From 6d8c59277580e659fbd0ed93b39f7fac0159805d Mon Sep 17 00:00:00 2001 From: vsc Date: Tue, 29 Oct 2002 17:23:32 +0000 Subject: [PATCH] fix garbage collection for delays (report from Bart Demoen). git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@663 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/corout.c | 22 +++++++++++++++++++++- C/heapgc.c | 7 +++++-- H/Yapproto.h | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/C/corout.c b/C/corout.c index 353e8e98d..00603f1ab 100644 --- a/C/corout.c +++ b/C/corout.c @@ -403,7 +403,7 @@ mark_sus_record(sus_record *sg) #ifdef MULTI_ASSIGNMENT_VARIABLES total_marked++; if (!IsAtomTerm((CELL)(sg->NS))) - mark_suspended_goal((CELL *)(sg->NS)); + mark_sus_record(sg->NS); MARK(((CELL *)&(sg->NS))); #endif } @@ -417,6 +417,26 @@ static void mark_suspended_goal(CELL *orig) } +void +mark_all_suspended_goals(void) +{ + sus_record *sg = GetSVarList(); + if (sg == NULL) + return; + /* okay, we are on top of the list of variables. Let's burn rubber! + */ + while (sg != (sus_record *)TermNil) { + CELL tmp; + mark_sus_record(sg); + tmp = (CELL)(sg->NS); + if (MARKED(tmp)) + sg = (sus_record *)UNMARK_CELL(tmp); + else + sg = (sus_record *)tmp; + } +} + + /* This routine does most of the work. It is called after diff --git a/C/heapgc.c b/C/heapgc.c index 94fc60e37..ffec2162d 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -2890,6 +2890,9 @@ marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max) cont_top = (cont *)db_vec; /* These two must be marked first so that our trail optimisation won't lose values */ +#ifdef COROUTINING + mark_all_suspended_goals(); +#endif mark_regs(old_TR); /* active registers & trail */ #ifdef COROUTINING mark_delays(max); @@ -2967,7 +2970,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) int gc_verbose = is_gc_verbose(); tr_fr_ptr old_TR; Int m_time, c_time, time_start, gc_time; -#ifdef COROUTINING +#if COROUTINING CELL *max = (CELL *)ReadTimedVar(DelayedVars); #else CELL *max = NULL; @@ -2976,7 +2979,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) int gc_trace = FALSE; #if COROUTINING - if (H0 - (CELL *)ReadTimedVar(DelayedVars) < 1024+(2*NUM_OF_ATTS)) { + if (H0 - max < 1024+(2*NUM_OF_ATTS)) { if (!growglobal(¤t_env)) { Error(SYSTEM_ERROR, TermNil, ErrorMessage); return FALSE; diff --git a/H/Yapproto.h b/H/Yapproto.h index 1d8c890b5..d7d1cf36c 100644 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -10,7 +10,7 @@ * File: Yap.proto * * mods: * * comments: Function declarations for YAP * -* version: $Id: Yapproto.h,v 1.25 2002-10-21 22:14:28 vsc Exp $ * +* version: $Id: Yapproto.h,v 1.26 2002-10-29 17:23:32 vsc Exp $ * *************************************************************************/ /* prototype file for Yap */ @@ -143,6 +143,7 @@ void STD_PROTO(InitCoroutPreds,(void)); #ifdef COROUTINING Term STD_PROTO(ListOfWokenGoals,(void)); void STD_PROTO(WakeUp,(CELL *)); +void STD_PROTO(mark_all_suspended_goals,(void)); #endif /* dbase.c */