[commit: ghc] late-lam-lift: added ticky counters for heap and stack checks (60015db)
Nicolas Frisby
nicolas.frisby at gmail.com
Fri Apr 12 17:02:34 CEST 2013
Repository : http://darcs.haskell.org/ghc.git/
On branch : late-lam-lift
https://github.com/ghc/ghc/commit/60015dbc5cf021338458f5d668f68f6ac5e05b82
>---------------------------------------------------------------
commit 60015dbc5cf021338458f5d668f68f6ac5e05b82
Author: Nicolas Frisby <nicolas.frisby at gmail.com>
Date: Thu Apr 4 22:20:27 2013 +0100
added ticky counters for heap and stack checks
>---------------------------------------------------------------
compiler/codeGen/StgCmmHeap.hs | 3 ++-
compiler/codeGen/StgCmmTicky.hs | 9 +++++++++
includes/Cmm.h | 2 ++
includes/stg/Ticky.h | 3 +++
rts/Linker.c | 2 ++
rts/Ticky.c | 3 +++
6 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/compiler/codeGen/StgCmmHeap.hs b/compiler/codeGen/StgCmmHeap.hs
index 50fcfdc..0a81703 100644
--- a/compiler/codeGen/StgCmmHeap.hs
+++ b/compiler/codeGen/StgCmmHeap.hs
@@ -570,10 +570,11 @@ do_checks mb_stk_hwm checkYield mb_alloc_lit do_gc = do
case mb_stk_hwm of
Nothing -> return ()
- Just stk_hwm -> emit =<< mkCmmIfGoto (sp_oflo stk_hwm) gc_id
+ Just stk_hwm -> tickyStackCheck >> (emit =<< mkCmmIfGoto (sp_oflo stk_hwm) gc_id)
if (isJust mb_alloc_lit)
then do
+ tickyHeapCheck
emitAssign hpReg bump_hp
emit =<< mkCmmIfThen hp_oflo (alloc_n <*> mkBranch gc_id)
else do
diff --git a/compiler/codeGen/StgCmmTicky.hs b/compiler/codeGen/StgCmmTicky.hs
index 09938a6..6427138 100644
--- a/compiler/codeGen/StgCmmTicky.hs
+++ b/compiler/codeGen/StgCmmTicky.hs
@@ -70,9 +70,12 @@ module StgCmmTicky (
tickyDynAlloc,
tickyAllocHeap,
+
tickyAllocPrim,
tickyAllocThunk,
tickyAllocPAP,
+ tickyHeapCheck,
+ tickyStackCheck,
tickyUnknownCall, tickyDirectCall,
@@ -481,6 +484,12 @@ tickyAllocPAP _goods _slop = ifTicky $ do
bumpTickyCounterByE (fsLit "ALLOC_PAP_gds") _goods
bumpTickyCounterByE (fsLit "ALLOC_PAP_slp") _slop
+tickyHeapCheck :: FCode ()
+tickyHeapCheck = ifTicky $ bumpTickyCounter (fsLit "HEAP_CHK_ctr")
+
+tickyStackCheck :: FCode ()
+tickyStackCheck = ifTicky $ bumpTickyCounter (fsLit "STK_CHK_ctr")
+
-- -----------------------------------------------------------------------------
-- Ticky utils
diff --git a/includes/Cmm.h b/includes/Cmm.h
index 7e051c1..89baaa0 100644
--- a/includes/Cmm.h
+++ b/includes/Cmm.h
@@ -373,6 +373,7 @@
CCCS_ALLOC(bytes);
#define HEAP_CHECK(bytes,failure) \
+ TICK_BUMP(HEAP_CHK_ctr); \
Hp = Hp + (bytes); \
if (Hp > HpLim) { HpAlloc = (bytes); failure; } \
TICK_ALLOC_HEAP_NOCTR(bytes);
@@ -476,6 +477,7 @@
}
#define STK_CHK(n, fun) \
+ TICK_BUMP(STK_CHK_ctr); \
if (Sp - (n) < SpLim) { \
GC_PRIM(fun) \
}
diff --git a/includes/stg/Ticky.h b/includes/stg/Ticky.h
index 32a7f20..182c996 100644
--- a/includes/stg/Ticky.h
+++ b/includes/stg/Ticky.h
@@ -111,6 +111,9 @@ EXTERN StgInt UPD_PAP_IN_PLACE_ctr INIT(0);
EXTERN StgInt ALLOC_HEAP_ctr INIT(0);
EXTERN StgInt ALLOC_HEAP_tot INIT(0);
+EXTERN StgInt HEAP_CHK_ctr INIT(0);
+EXTERN StgInt STK_CHK_ctr INIT(0);
+
EXTERN StgInt ALLOC_RTS_ctr INIT(0);
EXTERN StgInt ALLOC_RTS_tot INIT(0);
diff --git a/rts/Linker.c b/rts/Linker.c
index 3f66313..585d1e8 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -958,6 +958,8 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(UPD_PAP_IN_PLACE_ctr) \
SymI_HasProto(ALLOC_HEAP_ctr) \
SymI_HasProto(ALLOC_HEAP_tot) \
+ SymI_HasProto(HEAP_CHK_ctr) \
+ SymI_HasProto(STK_CHK_ctr) \
SymI_HasProto(ALLOC_RTS_ctr) \
SymI_HasProto(ALLOC_RTS_tot) \
SymI_HasProto(ALLOC_FUN_ctr) \
diff --git a/rts/Ticky.c b/rts/Ticky.c
index 243897f..0d33c43 100644
--- a/rts/Ticky.c
+++ b/rts/Ticky.c
@@ -330,6 +330,9 @@ PrintTickyInfo(void)
PR_CTR(ALLOC_HEAP_ctr);
PR_CTR(ALLOC_HEAP_tot);
+ PR_CTR(HEAP_CHK_ctr);
+ PR_CTR(STK_CHK_ctr);
+
PR_CTR(ALLOC_RTS_ctr);
PR_CTR(ALLOC_RTS_tot);
More information about the ghc-commits
mailing list