diff --git a/C/dlmalloc.c b/C/dlmalloc.c index 9a3315dd0..629809eda 100755 --- a/C/dlmalloc.c +++ b/C/dlmalloc.c @@ -194,7 +194,7 @@ yapsbrk(long size) { ADDR newHeapTop = HeapTop, oldHeapTop = HeapTop; newHeapTop = HeapTop+size; - if (Yap_NOfMemoryHoles && newHeapTop > Yap_MemoryHoles[0].start) { + while (Yap_NOfMemoryHoles && newHeapTop > Yap_MemoryHoles[0].start) { UInt i; HeapTop = oldHeapTop = Yap_MemoryHoles[0].end; diff --git a/C/errors.c b/C/errors.c index 284129c85..d663efa6c 100644 --- a/C/errors.c +++ b/C/errors.c @@ -377,6 +377,8 @@ Yap_Error(yap_error_number type, Term where, char *format,...) int psize = YAP_BUF_SIZE; Yap_Error_TYPE = YAP_NO_ERROR; + if (where == 0L) + where = TermNil; #if DEBUG_STRICT if (Yap_heap_regs && !(Yap_PrologMode & BootMode)) fprintf(stderr,"***** Processing Error %d (%lx,%x) %s***\n", type, (unsigned long int)ActiveSignals,Yap_PrologMode,format); diff --git a/C/grow.c b/C/grow.c index 3570c4d92..4b0212504 100644 --- a/C/grow.c +++ b/C/grow.c @@ -631,6 +631,8 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o CurrentDelayTop = (CELL *)DelayTop(); /* adjust to a multiple of 256) */ + if (size < YAP_ALLOC_SIZE) + size = YAP_ALLOC_SIZE; size = AdjustPageSize(size); Yap_ErrorMessage = NULL; if (!Yap_ExtendWorkSpace(size)) { @@ -734,6 +736,8 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit) if (size < ((char *)H0-omax)/8) size = ((char *)H0-omax)/8; if (do_grow) { + if (size < YAP_ALLOC_SIZE) + size = YAP_ALLOC_SIZE; size = AdjustPageSize(size); } /* adjust to a multiple of 256) */ @@ -1073,8 +1077,11 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running"); return FALSE; #endif - if (SizeOfOverflow > sz) + if (SizeOfOverflow > sz) { + if (size < YAP_ALLOC_SIZE) + size = YAP_ALLOC_SIZE; sz = AdjustPageSize(SizeOfOverflow); + } while(sz >= sizeof(CELL) * 16 * 1024L && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep)) { size = size/2; sz = size << shift_factor; @@ -1397,6 +1404,8 @@ growstack(long size) int gc_verbose; /* adjust to a multiple of 256) */ + if (size < YAP_ALLOC_SIZE) + size = YAP_ALLOC_SIZE; size = AdjustPageSize(size); Yap_ErrorMessage = NULL; start_growth_time = Yap_cputime(); @@ -1477,8 +1486,8 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr if (!size) size = ((ADDR)TR-Yap_TrailBase); size *= 2; - if (size < 64*1024) - size = 64*1024; + if (size < YAP_ALLOC_SIZE) + size = YAP_ALLOC_SIZE; if (size > 2048*1024) size = 2048*1024; /* adjust to a multiple of 256) */ diff --git a/C/heapgc.c b/C/heapgc.c index 7a638d922..0f1b18765 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -3867,8 +3867,10 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop) /* expand the stack if effectiveness is less than 20 % */ if (ASP - H < gc_margin/sizeof(CELL) || effectiveness < 20) { + UInt sz; + LeaveGCMode(); - return Yap_growstack(gc_margin-((ASP-H)*sizeof(CELL))); + return Yap_growstack(gc_margin); } /* * debug for(save_total=1; save_total<=N; ++save_total) diff --git a/C/index.c b/C/index.c index f503bed7e..e373e1a04 100644 --- a/C/index.c +++ b/C/index.c @@ -11,8 +11,12 @@ * File: index.c * * comments: Indexing a Prolog predicate * * * -* Last rev: $Date: 2008-01-23 17:57:46 $,$Author: vsc $ * +* Last rev: $Date: 2008-01-24 00:11:59 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.193 2008/01/23 17:57:46 vsc +* valgrind it! +* enable atom garbage collection. +* * Revision 1.192 2007/11/26 23:43:08 vsc * fixes to support threads and assert correctly, even if inefficiently. * @@ -4767,7 +4771,10 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots) if ((setjres = setjmp(cint.CompilerBotch)) == 3) { restore_machine_regs(); recover_from_failed_susp_on_cls(&cint, 0); - Yap_gcl(Yap_Error_Size, ap->ArityOfPE+NSlots, ENV, CP); + if (!Yap_gcl(Yap_Error_Size, ap->ArityOfPE+NSlots, ENV, CP)) { + Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); + return FAILCODE; + } } else if (setjres == 2) { restore_machine_regs(); Yap_Error_Size = recover_from_failed_susp_on_cls(&cint, Yap_Error_Size); diff --git a/changes-5.1.html b/changes-5.1.html index 0008530c8..1351cf901 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -17,6 +17,7 @@