X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsStartup.c;h=bc169ff0eb4ad6fe79bc03d5744909a1b67153c9;hb=8625c675de45bdb8bcfa795572ce7c47687c147c;hp=f0b2170bad391220331e6f26fe537b1d800da25d;hpb=a916885ce70142ae5c05cc9e28230c308821e3d6;p=ghc-hetmet.git diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index f0b2170..bc169ff 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -17,6 +17,7 @@ #include "sm/Storage.h" #include "RtsUtils.h" +#include "Prelude.h" #include "Schedule.h" /* initScheduler */ #include "Stats.h" /* initStats */ #include "STM.h" /* initSTM */ @@ -29,11 +30,11 @@ #include "sm/BlockAlloc.h" #include "Trace.h" #include "Stable.h" -#include "eventlog/EventLog.h" #include "Hash.h" #include "Profiling.h" #include "Timer.h" #include "Globals.h" +void exitLinker( void ); // there is no Linker.h file to include #if defined(RTS_GTK_FRONTPANEL) #include "FrontPanel.h" @@ -68,8 +69,8 @@ static int hs_init_count = 0; /* ----------------------------------------------------------------------------- - Initialise floating point unit on x86 (currently disabled. why?) - (see comment in ghc/compiler/nativeGen/MachInstrs.lhs). + Initialise floating point unit on x86 (currently disabled; See Note + [x86 Floating point precision] in compiler/nativeGen/X86/Instr.hs) -------------------------------------------------------------------------- */ #define X86_INIT_FPU 0 @@ -118,12 +119,6 @@ hs_init(int *argc, char **argv[]) */ stat_startInit(); -#if defined(DEBUG) - /* Start off by initialising the allocator debugging so we can - * use it anywhere */ - initAllocator(); -#endif - /* Set the RTS flags to default values. */ initRtsFlagsDefaults(); @@ -146,9 +141,12 @@ hs_init(int *argc, char **argv[]) #endif /* initTracing must be after setupRtsFlags() */ -#ifdef DEBUG +#ifdef TRACING initTracing(); #endif + /* Dtrace events are always enabled + */ + dtraceEventStartup(); /* initialise scheduler data structures (needs to be done before * initStorage()). @@ -165,15 +163,24 @@ hs_init(int *argc, char **argv[]) * knows about. We don't know whether these turn out to be CAFs * or refer to CAFs, but we have to assume that they might. */ - getStablePtr((StgPtr)base_GHCziTopHandler_runIO_closure); - getStablePtr((StgPtr)base_GHCziTopHandler_runNonIO_closure); + getStablePtr((StgPtr)runIO_closure); + getStablePtr((StgPtr)runNonIO_closure); + + getStablePtr((StgPtr)runFinalizerBatch_closure); + getStablePtr((StgPtr)stackOverflow_closure); getStablePtr((StgPtr)heapOverflow_closure); - getStablePtr((StgPtr)runFinalizerBatch_closure); getStablePtr((StgPtr)unpackCString_closure); getStablePtr((StgPtr)blockedIndefinitelyOnMVar_closure); getStablePtr((StgPtr)nonTermination_closure); getStablePtr((StgPtr)blockedIndefinitelyOnSTM_closure); + getStablePtr((StgPtr)nestedAtomically_closure); + + getStablePtr((StgPtr)runSparks_closure); + getStablePtr((StgPtr)ensureIOManagerIsRunning_closure); +#ifndef mingw32_HOST_OS + getStablePtr((StgPtr)runHandlers_closure); +#endif /* initialise the shared Typeable store */ initGlobalStore(); @@ -190,12 +197,6 @@ hs_init(int *argc, char **argv[]) initProfiling1(); -#ifdef EVENTLOG - if (RtsFlags.EventLogFlags.doEventLogging) { - initEventLogging(); - } -#endif - /* start the virtual timer 'subsystem'. */ initTimer(); startTimer(); @@ -344,6 +345,9 @@ hs_exit_(rtsBool wait_foreign) OnExitHook(); + // Free the full argv storage + freeFullProgArgv(); + #if defined(THREADED_RTS) ioManagerDie(); #endif @@ -362,7 +366,7 @@ hs_exit_(rtsBool wait_foreign) /* stop the ticker */ stopTimer(); - exitTimer(); + exitTimer(wait_foreign); // set the terminal settings back to what they were #if !defined(mingw32_HOST_OS) @@ -388,6 +392,9 @@ hs_exit_(rtsBool wait_foreign) /* free shared Typeable store */ exitGlobalStore(); + /* free linker data */ + exitLinker(); + /* free file locking tables, if necessary */ #if !defined(mingw32_HOST_OS) freeFileLocking(); @@ -421,11 +428,9 @@ hs_exit_(rtsBool wait_foreign) if (prof_file != NULL) fclose(prof_file); #endif -#ifdef EVENTLOG - if (RtsFlags.EventLogFlags.doEventLogging) { - endEventLogging(); - freeEventLogging(); - } +#ifdef TRACING + endTracing(); + freeTracing(); #endif #if defined(TICKY_TICKY) @@ -439,13 +444,11 @@ hs_exit_(rtsBool wait_foreign) /* free hash table storage */ exitHashTable(); - // Finally, free all our storage - freeStorage(); - -#if defined(DEBUG) - /* and shut down the allocator debugging */ - shutdownAllocator(); -#endif + // Finally, free all our storage. However, we only free the heap + // memory if we have waited for foreign calls to complete; + // otherwise a foreign call in progress may still be referencing + // heap memory (e.g. by being passed a ByteArray#). + freeStorage(wait_foreign); }