X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FBlock.h;h=d7599c5931de7a5d17eab0cec867f70e61bbe95e;hb=ca440e06a6cb5661f10ff879c676ba22a56c4ca7;hp=379b1e347576875f7b007fbe6b7642f5292cd2b7;hpb=0bffc410964e1688ad80d277d53400659e697ab5;p=ghc-hetmet.git diff --git a/ghc/includes/Block.h b/ghc/includes/Block.h index 379b1e3..d7599c5 100644 --- a/ghc/includes/Block.h +++ b/ghc/includes/Block.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Block.h,v 1.11 2002/12/11 15:36:37 simonmar Exp $ + * $Id: Block.h,v 1.17 2004/08/13 13:09:09 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -32,6 +32,11 @@ #define MBLOCK_ROUND_UP(p) ((void *)(((W_)(p)+MBLOCK_SIZE-1) & ~MBLOCK_MASK)) #define MBLOCK_ROUND_DOWN(p) ((void *)((W_)(p) & ~MBLOCK_MASK )) +/* The largest size an object can be before we give it a block of its + * own and treat it as an immovable object during GC, expressed as a + * fraction of BLOCK_SIZE. + */ +#define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10)) /* ----------------------------------------------------------------------------- * Block descriptor. This structure *must* be the right length, so we @@ -42,12 +47,13 @@ * on a 32-bit machine. */ -typedef struct _bdescr { +#ifndef CMINUSMINUS +typedef struct bdescr_ { StgPtr start; /* start addr of memory */ StgPtr free; /* first free byte of memory */ - struct _bdescr *link; /* used for chaining blocks together */ + struct bdescr_ *link; /* used for chaining blocks together */ union { - struct _bdescr *back; /* used (occasionally) for doubly-linked lists*/ + struct bdescr_ *back; /* used (occasionally) for doubly-linked lists*/ StgWord *bitmap; } u; unsigned int gen_no; /* generation */ @@ -60,6 +66,7 @@ typedef struct _bdescr { StgWord32 _padding[0]; #endif } bdescr; +#endif #if SIZEOF_VOID_P == 8 #define BDESCR_SIZE 0x40 @@ -71,12 +78,26 @@ typedef struct _bdescr { #define BDESCR_SHIFT 5 #endif +/* Block contains objects evacuated during this GC */ #define BF_EVACUATED 1 +/* Block is a large object */ #define BF_LARGE 2 +/* Block is pinned */ +#define BF_PINNED 4 +/* Block is part of a compacted generation */ +#define BF_COMPACTED 8 /* Finding the block descriptor for a given block -------------------------- */ -static inline bdescr *Bdescr(StgPtr p) +#ifdef CMINUSMINUS + +#define Bdescr(p) \ + ((((p) & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) \ + | ((p) & ~MBLOCK_MASK)) + +#else + +INLINE_HEADER bdescr *Bdescr(StgPtr p) { return (bdescr *) ((((W_)p & MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) @@ -84,12 +105,14 @@ static inline bdescr *Bdescr(StgPtr p) ); } +#endif + /* Useful Macros ------------------------------------------------------------ */ /* Offset of first real data block in a megablock */ #define FIRST_BLOCK_OFF \ - ((W_)BLOCK_ROUND_UP(MBLOCK_SIZE / BLOCK_SIZE * BDESCR_SIZE)) + ((W_)BLOCK_ROUND_UP(BDESCR_SIZE * (MBLOCK_SIZE / BLOCK_SIZE))) /* First data block in a given megablock */ @@ -118,4 +141,20 @@ static inline bdescr *Bdescr(StgPtr p) #define BLOCKS_TO_MBLOCKS(n) \ (1 + (W_)MBLOCK_ROUND_UP((n-BLOCKS_PER_MBLOCK) * BLOCK_SIZE) / MBLOCK_SIZE) + +/* Double-linked block lists: --------------------------------------------- */ + +#ifndef CMINUSMINUS +INLINE_HEADER void +dbl_link_onto(bdescr *bd, bdescr **list) +{ + bd->link = *list; + bd->u.back = NULL; + if (*list) { + (*list)->u.back = bd; /* double-link the list */ + } + *list = bd; +} +#endif + #endif /* BLOCK_H */