Skip to content

Commit

Permalink
added ticky counters for heap and stack checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Frisby committed Apr 4, 2013
1 parent b84da61 commit 60015db
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/codeGen/StgCmmHeap.hs
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions compiler/codeGen/StgCmmTicky.hs
Expand Up @@ -70,9 +70,12 @@ module StgCmmTicky (

tickyDynAlloc,
tickyAllocHeap,

tickyAllocPrim,
tickyAllocThunk,
tickyAllocPAP,
tickyHeapCheck,
tickyStackCheck,

tickyUnknownCall, tickyDirectCall,

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions includes/Cmm.h
Expand Up @@ -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);
Expand Down Expand Up @@ -476,6 +477,7 @@
}

#define STK_CHK(n, fun) \
TICK_BUMP(STK_CHK_ctr); \
if (Sp - (n) < SpLim) { \
GC_PRIM(fun) \
}
Expand Down
3 changes: 3 additions & 0 deletions includes/stg/Ticky.h
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions rts/Linker.c
Expand Up @@ -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) \
Expand Down
3 changes: 3 additions & 0 deletions rts/Ticky.c
Expand Up @@ -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);

Expand Down

0 comments on commit 60015db

Please sign in to comment.