X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FBlock.h;h=3d7a5c8a8668343c20c3651cd8e9b21c500a92df;hb=bb7ffa1642e2110e26e1243c42a8a24adafa985d;hp=7721765147b46b3c6b65884ac35db58b7de75c00;hpb=b4b8d87643ab42385fb9a36641be0f575b5b9d98;p=ghc-hetmet.git diff --git a/includes/Block.h b/includes/Block.h index 7721765..3d7a5c8 100644 --- a/includes/Block.h +++ b/includes/Block.h @@ -54,6 +54,7 @@ typedef struct bdescr_ { union { struct bdescr_ *back; /* used (occasionally) for doubly-linked lists*/ StgWord *bitmap; + StgPtr scan; /* scan pointer for copying GC */ } u; unsigned int gen_no; /* generation */ struct step_ *step; /* step */ @@ -83,12 +84,15 @@ typedef struct bdescr_ { #define BF_LARGE 2 /* Block is pinned */ #define BF_PINNED 4 -/* Block is part of a compacted generation */ -#define BF_COMPACTED 8 +/* Block is to be marked, not copied */ +#define BF_MARKED 8 /* Block is free, and on the free list (TODO: is this used?) */ #define BF_FREE 16 /* Block is executable */ #define BF_EXEC 32 +/* Block contains only a small amount of live data */ +#define BF_FRAGMENTED 64 + /* Finding the block descriptor for a given block -------------------------- */ @@ -227,21 +231,30 @@ void freeChain(bdescr *p); void freeGroup_lock(bdescr *p); void freeChain_lock(bdescr *p); -/* Round a value to megablocks --------------------------------------------- */ +bdescr * splitBlockGroup (bdescr *bd, nat blocks); -#define WORDS_PER_MBLOCK (BLOCKS_PER_MBLOCK * BLOCK_SIZE_W) +/* Round a value to megablocks --------------------------------------------- */ +// We want to allocate an object around a given size, round it up or +// down to the nearest size that will fit in an mblock group. INLINE_HEADER StgWord round_to_mblocks(StgWord words) { - if (words > WORDS_PER_MBLOCK) { - if ((words % WORDS_PER_MBLOCK) < (WORDS_PER_MBLOCK / 2)) { - words = (words / WORDS_PER_MBLOCK) * WORDS_PER_MBLOCK; - } else { - words = ((words / WORDS_PER_MBLOCK) + 1) * WORDS_PER_MBLOCK; + if (words > BLOCKS_PER_MBLOCK * BLOCK_SIZE_W) { + // first, ignore the gap at the beginning of the first mblock by + // adding it to the total words. Then we can pretend we're + // dealing in a uniform unit of megablocks. + words += FIRST_BLOCK_OFF/sizeof(W_); + + if ((words % MBLOCK_SIZE_W) < (MBLOCK_SIZE_W / 2)) { + words = (words / MBLOCK_SIZE_W) * MBLOCK_SIZE_W; + } else { + words = ((words / MBLOCK_SIZE_W) + 1) * MBLOCK_SIZE_W; + } + + words -= FIRST_BLOCK_OFF/sizeof(W_); } - } - return words; + return words; } #endif /* !CMINUSMINUS */