Mercurial > repos > rhope
diff runtime/fixed_alloc.c @ 105:43cc42df26cc
Various compiler improvements
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 24 Aug 2010 23:22:17 -0400 |
parents | e73a93fb5de1 |
children | 72c648bca43b |
line wrap: on
line diff
--- a/runtime/fixed_alloc.c Wed Aug 11 03:13:28 2010 -0400 +++ b/runtime/fixed_alloc.c Tue Aug 24 23:22:17 2010 -0400 @@ -1,4 +1,5 @@ #include "fixed_alloc.h" +#include "object.h" #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -24,8 +25,9 @@ { int i,count,freeobjs; mem_block * cur; - printf("Free blocks: %d\n", manager->freecount); - printf("Full Blocks: %d\n", manager->fullcount); + //printf("Free blocks: %d\n", manager->freecount); + if (manager->fullcount) + printf("Full Blocks: %d\n", manager->fullcount); for (i = 0; i < (MAX_SIZE-MIN_SIZE)/STRIDE; i++) { count = 0; @@ -37,11 +39,47 @@ freeobjs += ((int)cur->numfree); cur = cur->next; } - printf("Bucket %d(size: %d) has %d blocks in use with %d total free slots\n", i, i*STRIDE+MIN_SIZE,count, freeobjs); + if (freeobjs) + printf("Bucket %d(size: %d) has %d blocks in use with %d free slots out of %d\n", i, i*STRIDE+MIN_SIZE,count, freeobjs, max_free[i]*count); } fflush(stdout); } +void print_live_object_types(mem_manager * manager) +{ + object * obj; + mem_block * cur; + int32_t i,j,bitslots,bit,*counts = malloc(sizeof(int32_t)*max_registered_type); + memset(counts, 0, sizeof(int32_t)*max_registered_type); + for (i = 0; i < (MAX_SIZE-MIN_SIZE)/STRIDE; i++) + { + cur = manager->inuse[i]; + while(cur) + { + bitslots = max_free[i]/8; + if(max_free[i]&7) + ++bitslots; + for(j = 0; j < bitslots; ++j) + if(cur->bitmap[j] != 0xFF) + { + for (bit = 0; bit < 8; ++bit) + { + if (!(cur->bitmap[j] & (1 << bit))) + { + obj = (object *)(((char *)cur)+BLOCK_SIZE-(((j*8+bit)+1)*(i*STRIDE+MIN_SIZE))); + counts[obj->bprint->type_id]++; + } + } + } + cur = cur->next; + } + } + for (i = 0; i < max_registered_type; ++i) + if(counts[i]) + printf("%d live objects of type %d\n", counts[i], i); + fflush(stdout); +} + void * falloc(size_t size, mem_manager * manager) { uint16_t i,bit;