X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsStartup.c;h=6ed837ab6c291236472e7bf2c3eeeeaaf8d1738b;hb=d8334d807812e40f67770ffc37608c0ce66f96b2;hp=edb8088b0a91eb6ed572e1beb4f64b7a04480e5a;hpb=c56106fe9863edb27815e31b19be1f3f2516bc91;p=ghc-hetmet.git diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index edb8088..6ed837a 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -34,6 +34,7 @@ #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" @@ -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(); @@ -149,6 +144,9 @@ hs_init(int *argc, char **argv[]) #ifdef TRACING initTracing(); #endif + /* Dtrace events are always enabled + */ + dtraceEventStartup(); /* initialise scheduler data structures (needs to be done before * initStorage()). @@ -167,13 +165,22 @@ hs_init(int *argc, char **argv[]) */ 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(); @@ -338,6 +345,9 @@ hs_exit_(rtsBool wait_foreign) OnExitHook(); + // Free the full argv storage + freeFullProgArgv(); + #if defined(THREADED_RTS) ioManagerDie(); #endif @@ -356,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) @@ -382,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(); @@ -431,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); }