X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FStorage.c;h=0c9c60e58062538e3ba3535bb3564debffae8aa0;hp=ee860e27a28bf9266e578f977ac1868b9e3376fe;hb=c76c69c5b62f1ca4fa52d75b0dfbd37b7eddbb09;hpb=e3c55aebd4f9ce7a5b4390d4726612865fd207f2 diff --git a/rts/Storage.c b/rts/Storage.c index ee860e2..0c9c60e 100644 --- a/rts/Storage.c +++ b/rts/Storage.c @@ -23,6 +23,7 @@ #include "Schedule.h" #include "RetainerProfile.h" // for counting memory blocks (memInventory) #include "OSMem.h" +#include "Trace.h" #include #include @@ -126,7 +127,7 @@ initStorage( void ) RtsFlags.GcFlags.minAllocAreaSize > RtsFlags.GcFlags.maxHeapSize) { errorBelch("maximum heap size (-M) is smaller than minimum alloc area size (-A)"); - exit(1); + RtsFlags.GcFlags.minAllocAreaSize = RtsFlags.GcFlags.maxHeapSize; } initBlockAllocator(); @@ -272,7 +273,16 @@ exitStorage (void) void freeStorage (void) { + nat g; + + for(g = 0; g < RtsFlags.GcFlags.generations; g++) + stgFree(generations[g].steps); + stgFree(generations); freeAllMBlocks(); +#if defined(THREADED_RTS) + closeMutex(&sm_mutex); + closeMutex(&atomic_modify_mutvar_mutex); +#endif } /* ----------------------------------------------------------------------------- @@ -495,15 +505,15 @@ resizeNursery ( step *stp, nat blocks ) if (nursery_blocks == blocks) return; if (nursery_blocks < blocks) { - IF_DEBUG(gc, debugBelch("Increasing size of nursery to %d blocks\n", - blocks)); + debugTrace(DEBUG_gc, "increasing size of nursery to %d blocks", + blocks); stp->blocks = allocNursery(stp, stp->blocks, blocks-nursery_blocks); } else { bdescr *next_bd; - IF_DEBUG(gc, debugBelch("Decreasing size of nursery to %d blocks\n", - blocks)); + debugTrace(DEBUG_gc, "decreasing size of nursery to %d blocks", + blocks); bd = stp->blocks; while (nursery_blocks > blocks) { @@ -1005,7 +1015,7 @@ void *allocateExec (nat bytes) bdescr *bd; lnat pagesize = getPageSize(); bd = allocGroup(stg_max(1, pagesize / BLOCK_SIZE)); - IF_DEBUG(gc, debugBelch("allocate exec block %p\n", bd->start)); + debugTrace(DEBUG_gc, "allocate exec block %p", bd->start); bd->gen_no = 0; bd->flags = BF_EXEC; bd->link = exec_block; @@ -1046,7 +1056,7 @@ void freeExec (void *addr) // Free the block if it is empty, but not if it is the block at // the head of the queue. if (bd->gen_no == 0 && bd != exec_block) { - IF_DEBUG(gc, debugBelch("free exec block %p\n", bd->start)); + debugTrace(DEBUG_gc, "free exec block %p", bd->start); if (bd->u.back) { bd->u.back->link = bd->link; } else {