X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FConstants.h;h=4f3c35b7448fe814facc595cc6bc31f47ec45212;hb=0372ac231bd18e993a2533f784805046876d5527;hp=fbb3dbf4ea31609255d8865abb7ea7e0bb8ad7cc;hpb=723545930025a24708a8a0923435c95cc7f058c9;p=ghc-hetmet.git diff --git a/ghc/includes/Constants.h b/ghc/includes/Constants.h index fbb3dbf..4f3c35b 100644 --- a/ghc/includes/Constants.h +++ b/ghc/includes/Constants.h @@ -1,11 +1,16 @@ /* ---------------------------------------------------------------------------- - * $Id: Constants.h,v 1.4 1999/01/26 16:16:20 simonm Exp $ + * + * (c) The GHC Team, 1998-2002 * * Constants * - * NOTE: this information is used by both the compiler and the RTS, - * and *must* be kept up-to-date with respect to the rest of the - * world. + * NOTE: this information is used by both the compiler and the RTS. + * Some of it is tweakable, and some of it must be kept up to date + * with various other parts of the system. + * + * Constants which are derived automatically from other definitions in + * the system (eg. structure sizes) are generated into the file + * DerivedConstants.h by a C program (mkDerivedConstantsHdr). * * -------------------------------------------------------------------------- */ @@ -13,69 +18,22 @@ #define CONSTANTS_H /* ----------------------------------------------------------------------------- - Header Sizes - - NOTE: keep these in line with the real definitions in Closures.h - -------------------------------------------------------------------------- */ - -#define STD_HDR_SIZE 1 -#define PROF_HDR_SIZE 1 -#define GRAN_HDR_SIZE 1 -#define TICKY_HDR_SIZE 0 - -#define ARR_HDR_SIZE 1 - -/* ----------------------------------------------------------------------------- - Info Table sizes - - The native code generator needs to know these things, and can't use - the C sizeof() function. - - NOTE: keep these in line with the real definitions in InfoTables.h - - NOTE: the PROF, and GRAN values are *wrong* (ToDo) - -------------------------------------------------------------------------- */ - -#define STD_ITBL_SIZE 3 -#define PROF_ITBL_SIZE 1 -#define GRAN_ITBL_SIZE 1 -#define TICKY_ITBL_SIZE 0 - -/* ----------------------------------------------------------------------------- Minimum closure sizes - Here We define the minimum size for updatable closures. This must be at - least 2, to allow for cons cells and linked indirections. All updates - will be performed on closures of this size. For non-updatable closures - the minimum size is 1 to allow for a forwarding pointer. - - Linked indirections are UPD_OLDGEN things: see Closures.h - - o MIN_UPD_SIZE doesn't apply to stack closures, static closures - or non-updateable objects like PAPs or CONSTRs - o MIN_UPD_SIZE is big enough to contain any of the following: - o EVACUATED - o BLACKHOLE - o BLOCKING QUEUE - o IND, IND_PERM, IND_OLDGEN and IND_OLDGEN_PERM - (it need not be big enough for IND_STATIC - but it is) - o MIN_NONUPD_SIZE doesn't apply to stack closures, static closures - or updateable objects like APs, THUNKS or THUNK_SELECTORs - o MIN_NONUPD_SIZE is big enough to contain any of the following: - o EVACUATED + This is the minimum number of words in the payload of a + heap-allocated closure, so that the closure has enough room to be + overwritten with a forwarding pointer during garbage collection. -------------------------------------------------------------------------- */ -#define MIN_UPD_SIZE 2 -#define MIN_NONUPD_SIZE 1 +#define MIN_PAYLOAD_SIZE 1 /* ----------------------------------------------------------------------------- Constants to do with specialised closure types. -------------------------------------------------------------------------- */ -/* We have some pre-compiled selector thunks defined in - * StgSelectors.hc in the runtime system. This constant defines the - * highest selectee index that we can replace with a reference to the - * pre-compiled code. +/* We have some pre-compiled selector thunks defined in rts/StgStdThunks.hc. + * This constant defines the highest selectee index that we can replace with a + * reference to the pre-compiled code. */ #define MAX_SPEC_SELECTEE_SIZE 15 @@ -86,7 +44,7 @@ * space. */ -#define MAX_SPEC_AP_SIZE 8 +#define MAX_SPEC_AP_SIZE 7 /* Specialised FUN/THUNK/CONSTR closure types */ @@ -94,33 +52,16 @@ #define MAX_SPEC_FUN_SIZE 2 #define MAX_SPEC_CONSTR_SIZE 2 -/* ----------------------------------------------------------------------------- - Update Frame Layout - -------------------------------------------------------------------------- */ - -#define NOSCC_UF_SIZE 3 -#define SCC_UF_SIZE 4 - -#if defined(PROFILING) -#define UF_SIZE SCC_UF_SIZE -#else -#define UF_SIZE NOSCC_UF_SIZE -#endif - -#define UF_RET 0 -#define UF_SU 1 -#define UF_UPDATEE 2 -#define UF_CCS 3 - -/* ----------------------------------------------------------------------------- - SEQ frame size - -------------------------------------------------------------------------- */ +/* Range of built-in table of static small int-like and char-like closures. + * + * NB. This corresponds with the number of actual INTLIKE/CHARLIKE + * closures defined in rts/StgMiscClosures.cmm. + */ +#define MAX_INTLIKE 16 +#define MIN_INTLIKE (-16) -#if defined(PROFILING) -#define SEQ_FRAME_SIZE 3 -#else -#define SEQ_FRAME_SIZE 2 -#endif +#define MAX_CHARLIKE 255 +#define MIN_CHARLIKE 0 /* ----------------------------------------------------------------------------- STG Registers. @@ -132,39 +73,18 @@ #define MAX_VANILLA_REG 8 #define MAX_FLOAT_REG 4 #define MAX_DOUBLE_REG 2 -/* register is only used for returning (unboxed) 64-bit vals */ #define MAX_LONG_REG 1 -/*---- The size of an StgDouble, in StgWords. */ - -#if SIZEOF_VOID_P == SIZEOF_DOUBLE -#define DOUBLE_SIZE 1 -#else -#define DOUBLE_SIZE 2 -#endif - -/*---- The size of Stg{Int,Word}64e, in StgWords. */ -#if SIZEOF_VOID_P == 8 -#define WORD64_SIZE 1 -#define INT64_SIZE 1 -#else -#define WORD64_SIZE 2 -#define INT64_SIZE 2 -#endif - -/*---- Maximum number of constructors in a data type for direct-returns. */ +/* ----------------------------------------------------------------------------- + * Maximum number of constructors in a data type for direct-returns. + * + * NB. There are various places that assume the value of this + * constant, such as the polymorphic return frames for updates + * (stg_upd_frame_info) and catch frames (stg_catch_frame_info). + * -------------------------------------------------------------------------- */ #define MAX_VECTORED_RTN 8 -/*---- Range of built-in table of static small int-like closures. */ - -#define MAX_INTLIKE (16) -#define MIN_INTLIKE (-16) - -/*---- Minimum number of words left in heap after GC to carry on */ - -#define HEAP_HWM_WORDS 1024 - /* ----------------------------------------------------------------------------- Semi-Tagging constants @@ -184,18 +104,11 @@ #define INFO_FIRST_TAG 0 /* ----------------------------------------------------------------------------- - Context switch timing constants. - -------------------------------------------------------------------------- */ - -#define CS_MAX_FREQUENCY 100 /* context switches per second */ -#define CS_MIN_MILLISECS (1000/CS_MAX_FREQUENCY)/* milliseconds per slice */ - -/* ----------------------------------------------------------------------------- How much C stack to reserve for local temporaries when in the STG - world. Used in StgRun.S and StgCRun.c. + world. Used in StgCRun.c. -------------------------------------------------------------------------- */ -#define RESERVED_C_STACK_BYTES (512 * SIZEOF_LONG) +#define RESERVED_C_STACK_BYTES (2048 * SIZEOF_LONG) /* ----------------------------------------------------------------------------- How much Haskell stack space to reserve for the saving of registers @@ -203,28 +116,143 @@ This must be large enough to accomodate the largest stack frame pushed in one of the heap check fragments in HeapStackCheck.hc - (ie. currently the generic heap checks - 19 words). + (ie. currently the generic heap checks - 3 words for StgRetDyn, + 18 words for the saved registers, see StgMacros.h). + + In the event of an unboxed tuple or let-no-escape stack/heap check + failure, there will be other words on the stack which are covered + by the RET_DYN frame. These will have been accounted for by stack + checks however, so we don't need to allow for them here. -------------------------------------------------------------------------- */ -#define RESERVED_STACK_WORDS 19 +#define RESERVED_STACK_WORDS 21 /* ----------------------------------------------------------------------------- Storage manager constants -------------------------------------------------------------------------- */ -/* The size of a block */ -#define BLOCK_SIZE 0x2000 -#define BLOCK_SHIFT 13 +/* The size of a block (2^BLOCK_SHIFT bytes) */ +#define BLOCK_SHIFT 12 -/* The size of a megablock */ -#define MBLOCK_SIZE 0x100000 +/* The size of a megablock (2^MBLOCK_SHIFT bytes) */ #define MBLOCK_SHIFT 20 -/* 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. +/* ----------------------------------------------------------------------------- + Bitmap/size fields (used in info tables) + -------------------------------------------------------------------------- */ + +/* In a 32-bit bitmap field, we use 5 bits for the size, and 27 bits + * for the bitmap. If the bitmap requires more than 27 bits, then we + * store it in a separate array, and leave a pointer in the bitmap + * field. On a 64-bit machine, the sizes are extended accordingly. */ -#define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10)) +#if SIZEOF_VOID_P == 4 +#define BITMAP_SIZE_MASK 0x1f +#define BITMAP_BITS_SHIFT 5 +#elif SIZEOF_VOID_P == 8 +#define BITMAP_SIZE_MASK 0x3f +#define BITMAP_BITS_SHIFT 6 +#else +#error unknown SIZEOF_VOID_P +#endif -#endif /* CONSTANTS_H */ +/* ----------------------------------------------------------------------------- + Lag/Drag/Void constants + -------------------------------------------------------------------------- */ + +/* + An LDV word is divided into 3 parts: state bits (LDV_STATE_MASK), creation + time bits (LDV_CREATE_MASK), and last use time bits (LDV_LAST_MASK). + */ +#if SIZEOF_VOID_P == 8 +#define LDV_SHIFT 30 +#define LDV_STATE_MASK 0x1000000000000000 +#define LDV_CREATE_MASK 0x0FFFFFFFC0000000 +#define LDV_LAST_MASK 0x000000003FFFFFFF +#define LDV_STATE_CREATE 0x0000000000000000 +#define LDV_STATE_USE 0x1000000000000000 +#else +#define LDV_SHIFT 15 +#define LDV_STATE_MASK 0x40000000 +#define LDV_CREATE_MASK 0x3FFF8000 +#define LDV_LAST_MASK 0x00007FFF +#define LDV_STATE_CREATE 0x00000000 +#define LDV_STATE_USE 0x40000000 +#endif /* SIZEOF_VOID_P */ +/* ----------------------------------------------------------------------------- + TSO related constants + -------------------------------------------------------------------------- */ + +/* + * Constants for the what_next field of a TSO, which indicates how it + * is to be run. + */ +#define ThreadRunGHC 1 /* return to address on top of stack */ +#define ThreadInterpret 2 /* interpret this thread */ +#define ThreadKilled 3 /* thread has died, don't run it */ +#define ThreadRelocated 4 /* thread has moved, link points to new locn */ +#define ThreadComplete 5 /* thread has finished */ + +/* + * Constants for the why_blocked field of a TSO + */ +#define NotBlocked 0 +#define BlockedOnMVar 1 +#define BlockedOnBlackHole 2 +#define BlockedOnException 3 +#define BlockedOnRead 4 +#define BlockedOnWrite 5 +#define BlockedOnDelay 6 +#define BlockedOnSTM 7 + +/* Win32 only: */ +#define BlockedOnDoProc 8 + +/* Only relevant for PAR: */ + /* blocked on a remote closure represented by a Global Address: */ +#define BlockedOnGA 9 + /* same as above but without sending a Fetch message */ +#define BlockedOnGA_NoSend 10 +/* Only relevant for THREADED_RTS: */ +#define BlockedOnCCall 11 +#define BlockedOnCCall_NoUnblockExc 12 + /* same as above but don't unblock async exceptions in resumeThread() */ + +/* + * These constants are returned to the scheduler by a thread that has + * stopped for one reason or another. See typedef StgThreadReturnCode + * in TSO.h. + */ +#define HeapOverflow 1 /* might also be StackOverflow */ +#define StackOverflow 2 +#define ThreadYielding 3 +#define ThreadBlocked 4 +#define ThreadFinished 5 + +/* ----------------------------------------------------------------------------- + RET_DYN stack frames + -------------------------------------------------------------------------- */ + +/* VERY MAGIC CONSTANTS! + * must agree with code in HeapStackCheck.c, stg_gen_chk, and + * RESERVED_STACK_WORDS in Constants.h. + */ +#define RET_DYN_BITMAP_SIZE 8 +#define RET_DYN_NONPTR_REGS_SIZE 10 + +/* Sanity check that RESERVED_STACK_WORDS is reasonable. We can't + * just derive RESERVED_STACK_WORDS because it's used in Haskell code + * too. + */ +#if RESERVED_STACK_WORDS != (3 + RET_DYN_BITMAP_SIZE + RET_DYN_NONPTR_REGS_SIZE) +#error RESERVED_STACK_WORDS may be wrong! +#endif + +/* ----------------------------------------------------------------------------- + How often our context-switch timer ticks + -------------------------------------------------------------------------- */ + +#define TICK_FREQUENCY 50 /* ticks per second */ + +#endif /* CONSTANTS_H */