From b7a44d3808b3eb3ba69ecd92042ae3bd5aa69289 Mon Sep 17 00:00:00 2001 From: vsc Date: Wed, 5 Jan 2005 04:32:18 +0000 Subject: [PATCH] hole handling in dlmalloc should not make HeapTop always skip over the hole. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1223 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/dbase.c | 5 ++++- C/dlmalloc.c | 2 +- C/heapgc.c | 6 +++--- pl/setof.yap | 11 +++++------ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/C/dbase.c b/C/dbase.c index 5a833fec8..d285d6c95 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -4808,6 +4808,7 @@ static Int p_enqueue(void) { Term Father = Deref(ARG1); + Term t; QueueEntry *x; db_queue *father_key; @@ -4825,9 +4826,11 @@ p_enqueue(void) return FALSE; } } + t = Deref(ARG1); x->DBT = StoreTermInDB(Deref(ARG2), 2); - if (x->DBT == NULL) + if (x->DBT == NULL) { return FALSE; + } x->next = NULL; WRITE_LOCK(father_key->QRWLock); if (father_key->LastInQueue != NULL) diff --git a/C/dlmalloc.c b/C/dlmalloc.c index 77c67b685..8f24023bf 100755 --- a/C/dlmalloc.c +++ b/C/dlmalloc.c @@ -175,7 +175,7 @@ yapsbrk(long size) LOCK(HeapUsedLock); newHeapTop = HeapTop+size; if (Yap_hole_start && newHeapTop > Yap_hole_start) { - oldHeapTop = Yap_hole_end; + HeapTop = oldHeapTop = Yap_hole_end; newHeapTop = oldHeapTop+size; Yap_hole_start = Yap_hole_end = NULL; } diff --git a/C/heapgc.c b/C/heapgc.c index 60beb30aa..e4fe2eb8b 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -3418,18 +3418,18 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) { UInt alloc_sz = (CELL *)Yap_TrailTop-(CELL*)Yap_GlobalBase; bp = Yap_PreAllocCodeSpace(); - if (bp+alloc_sz > (char *)AuxSp) { + while (bp+alloc_sz > (char *)AuxSp) { /* not enough space */ *--ASP = (CELL)current_env; bp = (char *)Yap_ExpandPreAllocCodeSpace(alloc_sz, NULL); + if (!bp) + return 0; current_env = (CELL *)*ASP; ASP++; #if COROUTINING max = (CELL *)Yap_ReadTimedVar(DelayedVars); #endif } - if (!bp) - return 0; memset((void *)bp, 0, alloc_sz); } #endif /* GC_NO_TAGS */ diff --git a/pl/setof.yap b/pl/setof.yap index 5a5a0c121..e01de99e1 100644 --- a/pl/setof.yap +++ b/pl/setof.yap @@ -69,12 +69,11 @@ findall(Template, Generator, Answers, SoFar) :- % by getting all answers '$collect_for_findall'(Ref, SoFar, Out) :- - ( '$db_dequeue'(Ref, Term) -> - Out = [Term|Answers], - '$collect_for_findall'(Ref, SoFar, Answers) - ; - Out = SoFar - ). + '$db_dequeue'(Ref, Term), !, + Out = [Term|Answers], + '$collect_for_findall'(Ref, SoFar, Answers). +'$collect_for_findall'(Ref, SoFar, SoFar) :- + Out = SoFar. % findall_with_key is very similar to findall, but uses the SICStus % algorithm to guarantee that variables will have the same names.