/* ---------------------------------------------------------------------------- * * (c) The GHC Team, 1998-2009 * * Constants * * 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). * * To understand the structure of the RTS headers, see the wiki: * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes * * -------------------------------------------------------------------------- */ #ifndef RTS_CONSTANTS_H #define RTS_CONSTANTS_H /* ----------------------------------------------------------------------------- Minimum closure sizes 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_PAYLOAD_SIZE 1 /* ----------------------------------------------------------------------------- Constants to do with specialised closure types. -------------------------------------------------------------------------- */ /* 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 /* Vector-apply thunks. These thunks just push their free variables * on the stack and enter the first one. They're a bit like PAPs, but * don't have a dynamic size. We've pre-compiled a few to save * space. */ #define MAX_SPEC_AP_SIZE 7 /* Specialised FUN/THUNK/CONSTR closure types */ #define MAX_SPEC_THUNK_SIZE 2 #define MAX_SPEC_FUN_SIZE 2 #define MAX_SPEC_CONSTR_SIZE 2 /* 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) #define MAX_CHARLIKE 255 #define MIN_CHARLIKE 0 /* Each byte in the card table for an StgMutaArrPtrs covers * (1<msg_cap */ #define BlockedOnMsgThrowTo 12 /* The thread is not on any run queues, but can be woken up by tryWakeupThread() */ #define ThreadMigrating 13 /* * 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 /* * Flags for the tso->flags field. */ /* * TSO_LOCKED is set when a TSO is locked to a particular Capability. */ #define TSO_LOCKED 2 /* * TSO_BLOCKEX: the TSO is blocking exceptions * * TSO_INTERRUPTIBLE: the TSO can be interrupted if it blocks * interruptibly (eg. with BlockedOnMVar). * * TSO_STOPPED_ON_BREAKPOINT: the thread is currently stopped in a breakpoint */ #define TSO_BLOCKEX 4 #define TSO_INTERRUPTIBLE 8 #define TSO_STOPPED_ON_BREAKPOINT 16 /* * TSO_LINK_DIRTY is set when a TSO's link field is modified */ #define TSO_LINK_DIRTY 32 /* * Used by the sanity checker to check whether TSOs are on the correct * mutable list. */ #define TSO_MARKED 64 /* * Used to communicate between stackSqueeze() and * threadStackOverflow() that a thread's stack was squeezed and the * stack may not need to be expanded. */ #define TSO_SQUEEZED 128 /* ----------------------------------------------------------------------------- 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 /* * The number of times we spin in a spin lock before yielding (see * #3758). To tune this value, use the benchmark in #3758: run the * server with -N2 and the client both on a dual-core. Also make sure * that the chosen value doesn't slow down any of the parallel * benchmarks in nofib/parallel. */ #define SPIN_COUNT 1000 #endif /* RTS_CONSTANTS_H */