summaryrefslogtreecommitdiff
path: root/rts/Profiling.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2015-11-07 09:39:05 +0000
committerSimon Marlow <marlowsd@gmail.com>2015-11-07 09:39:05 +0000
commitce1f1607ed7f8fedd2f63c8610cafefd59baaf32 (patch)
tree718641160c3d93a2ca974deec1e228cb09e1a97e /rts/Profiling.c
parenta58eeb7febd67c93dab82de7049ef1dcdecd34e9 (diff)
downloadhaskell-ce1f1607ed7f8fedd2f63c8610cafefd59baaf32.tar.gz
Make GHCi & TH work when the compiler is built with -prof
Summary: Amazingly, there were zero changes to the byte code generator and very few changes to the interpreter - mainly because we've used good abstractions that hide the differences between profiling and non-profiling. So that bit was pleasantly straightforward, but there were a pile of other wibbles to get the whole test suite through. Note that a compiler built with -prof is now like one built with -dynamic, in that to use TH you have to build the code the same way. For dynamic, we automatically enable -dynamic-too when TH is required, but we don't have anything equivalent for profiling, so you have to explicitly use -prof when building code that uses TH with a profiled compiler. For this reason Cabal won't work with TH. We don't expect to ship a profiled compiler, so I think that's OK. Test Plan: validate with GhcProfiled=YES in validate.mk Reviewers: goldfire, bgamari, rwbarton, austin, hvr, erikd, ezyang Reviewed By: ezyang Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1407 GHC Trac Issues: #4837, #545
Diffstat (limited to 'rts/Profiling.c')
-rw-r--r--rts/Profiling.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/rts/Profiling.c b/rts/Profiling.c
index 23a48993fd..982b9461a0 100644
--- a/rts/Profiling.c
+++ b/rts/Profiling.c
@@ -142,8 +142,7 @@ static void initProfilingLogFile ( void );
Initialise the profiling environment
-------------------------------------------------------------------------- */
-void
-initProfiling1 (void)
+void initProfiling (void)
{
// initialise our arena
prof_arena = newArena();
@@ -159,18 +158,6 @@ initProfiling1 (void)
#ifdef THREADED_RTS
initMutex(&ccs_mutex);
#endif
-}
-
-void
-freeProfiling (void)
-{
- arenaFree(prof_arena);
-}
-
-void
-initProfiling2 (void)
-{
- CostCentreStack *ccs, *next;
/* Set up the log file, and dump the header and cost centre
* information into it.
@@ -205,14 +192,7 @@ initProfiling2 (void)
CCS_MAIN->root = CCS_MAIN;
ccsSetSelected(CCS_MAIN);
- // make CCS_MAIN the parent of all the pre-defined CCSs.
- for (ccs = CCS_LIST; ccs != NULL; ) {
- next = ccs->prevStack;
- ccs->prevStack = NULL;
- actualPush_(CCS_MAIN,ccs->cc,ccs);
- ccs->root = ccs;
- ccs = next;
- }
+ initProfiling2();
if (RtsFlags.CcFlags.doCostCentres) {
initTimeProfiling();
@@ -223,6 +203,29 @@ initProfiling2 (void)
}
}
+//
+// Should be called after loading any new Haskell code.
+//
+void initProfiling2 (void)
+{
+ CostCentreStack *ccs, *next;
+
+ // make CCS_MAIN the parent of all the pre-defined CCSs.
+ for (ccs = CCS_LIST; ccs != NULL; ) {
+ next = ccs->prevStack;
+ ccs->prevStack = NULL;
+ actualPush_(CCS_MAIN,ccs->cc,ccs);
+ ccs->root = ccs;
+ ccs = next;
+ }
+ CCS_LIST = NULL;
+}
+
+void
+freeProfiling (void)
+{
+ arenaFree(prof_arena);
+}
static void
initProfilingLogFile(void)