X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fprofiling%2FCostCentre.lhs;h=3616ccbe30dd3e796fe46261ab8dbbc200af5561;hb=e195ea859d2d4227c478a3b5e1e9ac20b086b0c7;hp=ed40a5e1d13e56cce456f173f2363bb174581e62;hpb=4a4bc50d9a1e6bdb4662005188a957a50f20aee1;p=ghc-hetmet.git diff --git a/ghc/compiler/profiling/CostCentre.lhs b/ghc/compiler/profiling/CostCentre.lhs index ed40a5e..3616ccb 100644 --- a/ghc/compiler/profiling/CostCentre.lhs +++ b/ghc/compiler/profiling/CostCentre.lhs @@ -11,18 +11,20 @@ module CostCentre ( CostCentreStack, CollectedCCs, noCCS, subsumedCCS, currentCCS, overheadCCS, dontCareCCS, - noCostCentre, + noCostCentre, noCCAttached, noCCSAttached, isCurrentCCS, isSubsumedCCS, currentOrSubsumedCCS, - isDerivedFromCurrentCCS, + isDerivedFromCurrentCCS, maybeSingletonCCS, + decomposeCCS, mkUserCC, mkAutoCC, mkAllCafsCC, mkSingletonCCS, dupifyCC, pushCCOnCCS, - isCafCCS, + isCafCCS, isCafCC, isSccCountCostCentre, sccAbleCostCentre, ccFromThisModule, - pprCostCentreDecl, pprCostCentreStackDecl, pprCostCentreCore, + pprCostCentreCore, + costCentreUserName, cmpCostCentre -- used for removing dups in a list ) where @@ -33,11 +35,8 @@ import Var ( Id ) import Name ( UserFS, EncodedFS, encodeFS, decode, getOccName, occNameFS ) -import Module ( Module, ModuleName, moduleName, - moduleNameUserString - ) +import Module ( Module ) import Outputable -import CStrings ( pprStringInCStyle ) import FastTypes import FastString import Util ( thenCmp ) @@ -112,13 +111,13 @@ data CostCentre | NormalCC { cc_name :: CcName, -- Name of the cost centre itself - cc_mod :: ModuleName, -- Name of module defining this CC. + cc_mod :: Module, -- Name of module defining this CC. cc_is_dupd :: IsDupdCC, -- see below cc_is_caf :: IsCafCC -- see below } | AllCafsCC { - cc_mod :: ModuleName -- Name of module defining this CC. + cc_mod :: Module -- Name of module defining this CC. } type CcName = EncodedFS @@ -193,6 +192,9 @@ isDerivedFromCurrentCCS _ = False currentOrSubsumedCCS SubsumedCCS = True currentOrSubsumedCCS CurrentCCS = True currentOrSubsumedCCS _ = False + +maybeSingletonCCS (PushCC cc NoCCS) = Just cc +maybeSingletonCCS _ = Nothing \end{code} Building cost centres @@ -200,17 +202,17 @@ Building cost centres \begin{code} mkUserCC :: UserFS -> Module -> CostCentre mkUserCC cc_name mod - = NormalCC { cc_name = encodeFS cc_name, cc_mod = moduleName mod, + = NormalCC { cc_name = encodeFS cc_name, cc_mod = mod, cc_is_dupd = OriginalCC, cc_is_caf = NotCafCC {-might be changed-} } mkAutoCC :: Id -> Module -> IsCafCC -> CostCentre mkAutoCC id mod is_caf - = NormalCC { cc_name = occNameFS (getOccName id), cc_mod = moduleName mod, + = NormalCC { cc_name = occNameFS (getOccName id), cc_mod = mod, cc_is_dupd = OriginalCC, cc_is_caf = is_caf } -mkAllCafsCC m = AllCafsCC { cc_mod = moduleName m } +mkAllCafsCC m = AllCafsCC { cc_mod = m } @@ -222,10 +224,7 @@ pushCCOnCCS = PushCC dupifyCC cc = cc {cc_is_dupd = DupdCC} -isEmptyCC, isCafCC, isDupdCC :: CostCentre -> Bool - -isEmptyCC (NoCostCentre) = True -isEmptyCC _ = False +isCafCC, isDupdCC :: CostCentre -> Bool isCafCC (AllCafsCC {}) = True isCafCC (NormalCC {cc_is_caf = CafCC}) = True @@ -254,7 +253,7 @@ sccAbleCostCentre cc | isCafCC cc = False | otherwise = True ccFromThisModule :: CostCentre -> Module -> Bool -ccFromThisModule cc m = cc_mod cc == moduleName m +ccFromThisModule cc m = cc_mod cc == m \end{code} \begin{code} @@ -288,6 +287,11 @@ cmp_caf NotCafCC CafCC = LT cmp_caf NotCafCC NotCafCC = EQ cmp_caf CafCC CafCC = EQ cmp_caf CafCC NotCafCC = GT + +decomposeCCS :: CostCentreStack -> ([CostCentre],CostCentreStack) +decomposeCCS (PushCC cc ccs) = (cc:more, ccs') + where (more,ccs') = decomposeCCS ccs +decomposeCCS ccs = ([],ccs) \end{code} ----------------------------------------------------------------------------- @@ -310,20 +314,8 @@ instance Outputable CostCentreStack where ppr SubsumedCCS = ptext SLIT("CCS_SUBSUMED") ppr (PushCC cc NoCCS) = ppr cc <> ptext SLIT("_ccs") ppr (PushCC cc ccs) = ptext SLIT("PushCostCentre") <> - parens (ppr ccs <> comma <> ppr cc) - --- print the static declaration for a singleton CCS. -pprCostCentreStackDecl :: CostCentreStack -> SDoc -pprCostCentreStackDecl ccs@(PushCC cc NoCCS) - = hcat [ ptext SLIT("CCS_DECLARE"), char '(', - ppr ccs, comma, -- better be codeStyle - ppCostCentreLbl cc, comma, - empty, -- Now always externally visible - text ");" - ] - -pprCostCentreStackDecl ccs - = pprPanic "pprCostCentreStackDecl: " (ppr ccs) + parens (ppr ccs <> comma <> + parens(ptext SLIT("void *")) <> ppr cc) \end{code} ----------------------------------------------------------------------------- @@ -380,32 +372,3 @@ costCentreUserName (AllCafsCC {}) = "CAF" costCentreUserName cc@(NormalCC {cc_name = name, cc_is_caf = is_caf}) = case is_caf of { CafCC -> "CAF:"; _ -> "" } ++ decode (unpackFS name) \end{code} - -Cost Centre Declarations - -\begin{code} -#ifdef DEBUG -pprCostCentreDecl is_local (NoCostCentre) - = panic "pprCostCentreDecl: no cost centre!" -#endif -pprCostCentreDecl is_local cc - = if is_local then - hcat [ - ptext SLIT("CC_DECLARE"),char '(', - cc_ident, comma, - pprStringInCStyle (costCentreUserName cc), comma, - pprStringInCStyle (moduleNameUserString mod_name), comma, - is_subsumed, comma, - empty, -- Now always externally visible - text ");"] - else - hcat [ ptext SLIT("CC_EXTERN"),char '(', cc_ident, text ");" ] - where - cc_ident = ppCostCentreLbl cc - mod_name = cc_mod cc - is_subsumed = ccSubsumed cc - -ccSubsumed :: CostCentre -> SDoc -- subsumed value -ccSubsumed cc | isCafCC cc = ptext SLIT("CC_IS_CAF") - | otherwise = ptext SLIT("CC_IS_BORING") -\end{code}