X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FRtsFlags.c;h=f24912fe46777204542aa97fffd178161f443680;hb=2322bc9a89a9d8a6132a6818ccff6f665d7ed7f1;hp=85c31db112fb663b15d11f1eb8b3c3f4b8aca9e4;hpb=153b9cb9b11e05c4edb1b6bc0a7b972660e41f70;p=ghc-hetmet.git diff --git a/ghc/rts/RtsFlags.c b/ghc/rts/RtsFlags.c index 85c31db..f24912f 100644 --- a/ghc/rts/RtsFlags.c +++ b/ghc/rts/RtsFlags.c @@ -152,7 +152,7 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.maxStkSize = (8 * 1024 * 1024) / sizeof(W_); RtsFlags.GcFlags.initialStkSize = 1024 / sizeof(W_); - RtsFlags.GcFlags.minAllocAreaSize = (256 * 1024) / BLOCK_SIZE; + RtsFlags.GcFlags.minAllocAreaSize = (512 * 1024) / BLOCK_SIZE; RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; RtsFlags.GcFlags.maxHeapSize = 0; /* off by default */ RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */ @@ -173,6 +173,7 @@ void initRtsFlagsDefaults(void) #ifdef RTS_GTK_FRONTPANEL RtsFlags.GcFlags.frontpanel = rtsFalse; #endif + RtsFlags.GcFlags.idleGCDelayTicks = 300 / TICK_MILLISECS; /* ticks */ #ifdef DEBUG RtsFlags.DebugFlags.scheduler = rtsFalse; @@ -189,6 +190,7 @@ void initRtsFlagsDefaults(void) RtsFlags.DebugFlags.gran = rtsFalse; RtsFlags.DebugFlags.par = rtsFalse; RtsFlags.DebugFlags.linker = rtsFalse; + RtsFlags.DebugFlags.squeeze = rtsFalse; #endif #if defined(PROFILING) || defined(PAR) @@ -215,7 +217,7 @@ void initRtsFlagsDefaults(void) RtsFlags.ConcFlags.ctxtSwitchTime = CS_MIN_MILLISECS; /* In milliseconds */ -#ifdef SMP +#ifdef THREADED_RTS RtsFlags.ParFlags.nNodes = 1; #endif @@ -242,9 +244,9 @@ void initRtsFlagsDefaults(void) RtsFlags.ParFlags.fishDelay = FISH_DELAY; #endif -#if defined(PAR) || defined(SMP) +#if defined(PAR) || defined(THREADED_RTS) RtsFlags.ParFlags.maxLocalSparks = 4096; -#endif /* PAR || SMP */ +#endif /* PAR || THREADED_RTS */ #if defined(GRAN) /* ToDo: check defaults for GranSim and GUM */ @@ -346,6 +348,9 @@ usage_text[] = { " -c Auto-enable compaction of the oldest generation when live data is", " at least % of the maximum heap size set with -M (default: 30%)", " -c Enable compaction for all major collections", +#if defined(THREADED_RTS) +" -I Perform full GC after idle time (default: 0.3, 0 == off)", +#endif "", " -t One-line GC statistics (default file: .stat)", " -s Summary GC statistics (with -Sstderr going to stderr)", @@ -427,12 +432,13 @@ usage_text[] = { " -DP DEBUG: par", " -Dl DEBUG: linker", " -Dm DEBUG: stm", +" -Dz DEBUG: stack squezing", "", -#endif // DEBUG -#if defined(SMP) +#endif /* DEBUG */ +#if defined(THREADED_RTS) " -N Use OS threads (default: 1)", #endif -#if defined(SMP) || defined(PAR) +#if defined(THREADED_RTS) || defined(PAR) " -e Size of spark pools (default 100)", #endif #if defined(PAR) @@ -442,7 +448,7 @@ usage_text[] = { " -qd Turn on PVM-ish debugging", " -qO Disable output for performance measurement", #endif -#if defined(SMP) || defined(PAR) +#if defined(THREADED_RTS) || defined(PAR) " -e Maximum number of outstanding local sparks (default: 4096)", #endif #if defined(PAR) @@ -499,21 +505,8 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]) rtsBool error = rtsFalse; I_ mode; I_ arg, total_arg; - char *last_slash; - - /* Remove directory from argv[0] -- default files in current directory */ - if ((last_slash = (char *) strrchr(argv[0], -#if !defined(mingw32_HOST_OS) - '/') -#else - '\\') -#endif - ) != NULL) { - prog_name = last_slash+1; - } else { - prog_name = argv[0]; - } + setProgName (argv); total_arg = *argc; arg = 1; @@ -618,14 +611,6 @@ errorBelch("not built for: -prof"); \ error = rtsTrue; #endif -#ifdef SMP -# define SMP_BUILD_ONLY(x) x -#else -# define SMP_BUILD_ONLY(x) \ -errorBelch("not built for: -smp"); \ -error = rtsTrue; -#endif - #ifdef PAR # define PAR_BUILD_ONLY(x) x #else @@ -634,10 +619,18 @@ errorBelch("not built for: -parallel"); \ error = rtsTrue; #endif -#if defined(SMP) || defined(PAR) -# define PAR_OR_SMP_BUILD_ONLY(x) x +#ifdef THREADED_RTS +# define THREADED_BUILD_ONLY(x) x #else -# define PAR_OR_SMP_BUILD_ONLY(x) \ +# define THREADED_BUILD_ONLY(x) \ +errorBelch("not built for: -smp"); \ +error = rtsTrue; +#endif + +#if defined(THREADED_RTS) || defined(PAR) +# define PAR_OR_THREADED_BUILD_ONLY(x) x +#else +# define PAR_OR_THREADED_BUILD_ONLY(x) \ errorBelch("not built for: -parallel or -smp"); \ error = rtsTrue; #endif @@ -735,6 +728,9 @@ error = rtsTrue; case 'm': RtsFlags.DebugFlags.stm = rtsTrue; break; + case 'z': + RtsFlags.DebugFlags.squeeze = rtsTrue; + break; default: bad_option( rts_argv[arg] ); } @@ -806,6 +802,23 @@ error = rtsTrue; break; #endif + case 'I': /* idle GC delay */ + if (rts_argv[arg][2] == '\0') { + /* use default */ + } else { + I_ cst; /* tmp */ + + /* Convert to ticks */ + cst = (I_) ((atof(rts_argv[arg]+2) * 1000)); + if (cst > 0 && cst < TICK_MILLISECS) { + cst = TICK_MILLISECS; + } else { + cst = cst / TICK_MILLISECS; + } + RtsFlags.GcFlags.idleGCDelayTicks = cst; + } + break; + case 'S': RtsFlags.GcFlags.giveStats = VERBOSE_GC_STATS; goto stats; @@ -986,7 +999,7 @@ error = rtsTrue; error = rtsTrue; } ) -#endif // PROFILING +#endif /* PROFILING */ break; #if defined(PROFILING) @@ -1024,9 +1037,9 @@ error = rtsTrue; } break; -#ifdef SMP +#ifdef THREADED_RTS case 'N': - SMP_BUILD_ONLY( + THREADED_BUILD_ONLY( if (rts_argv[arg][2] != '\0') { RtsFlags.ParFlags.nNodes = strtol(rts_argv[arg]+2, (char **) NULL, 10); @@ -1039,7 +1052,7 @@ error = rtsTrue; #endif /* =========== PARALLEL =========================== */ case 'e': - PAR_OR_SMP_BUILD_ONLY( + PAR_OR_THREADED_BUILD_ONLY( if (rts_argv[arg][2] != '\0') { RtsFlags.ParFlags.maxLocalSparks = strtol(rts_argv[arg]+2, (char **) NULL, 10); @@ -2191,3 +2204,53 @@ bad_option(const char *s) errorBelch("bad RTS option: %s", s); stg_exit(EXIT_FAILURE); } + +/* ----------------------------------------------------------------------------- + Getting/Setting the program's arguments. + + These are used by System.Environment, and parts of the RTS. + -------------------------------------------------------------------------- */ + +void +setProgName(char *argv[]) +{ + /* Remove directory from argv[0] -- default files in current directory */ +#if !defined(mingw32_HOST_OS) + char *last_slash; + if ( (last_slash = (char *) strrchr(argv[0], '/')) != NULL ) { + prog_name = last_slash+1; + } else { + prog_name = argv[0]; + } +#else + char* last_slash = argv[0] + (strlen(argv[0]) - 1); + while ( last_slash > argv[0] ) { + if ( *last_slash == '/' || *last_slash == '\\' ) { + prog_name = last_slash+1; + return; + } + last_slash--; + } + prog_name = argv[0]; +#endif +} + +void +getProgArgv(int *argc, char **argv[]) +{ + if (argc) { *argc = prog_argc; } + if (argv) { *argv = prog_argv; } +} + +void +setProgArgv(int argc, char *argv[]) +{ + /* Usually this is done by startupHaskell, so we don't need to call this. + However, sometimes Hugs wants to change the arguments which Haskell + getArgs >>= ... will be fed. So you can do that by calling here + _after_ calling startupHaskell. + */ + prog_argc = argc; + prog_argv = argv; + setProgName(prog_argv); +}