summaryrefslogtreecommitdiff
path: root/compiler/profiling
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-07-27 15:43:13 +0100
committerIan Lynagh <ian@well-typed.com>2013-07-27 15:43:13 +0100
commitfb520bb6fe266f5581e2ce78e4c4f02619f0392b (patch)
tree14f8127083b294f00fd10c3635d72f439d99ac59 /compiler/profiling
parent0fa7cc9770545f7e382381f1d83f57b7bb05645d (diff)
downloadhaskell-fb520bb6fe266f5581e2ce78e4c4f02619f0392b.tar.gz
De-orphan a load of Binary instances
Diffstat (limited to 'compiler/profiling')
-rw-r--r--compiler/profiling/CostCentre.lhs39
1 files changed, 39 insertions, 0 deletions
diff --git a/compiler/profiling/CostCentre.lhs b/compiler/profiling/CostCentre.lhs
index 8d9c269305..7e6959baaa 100644
--- a/compiler/profiling/CostCentre.lhs
+++ b/compiler/profiling/CostCentre.lhs
@@ -29,6 +29,7 @@ module CostCentre (
cmpCostCentre -- used for removing dups in a list
) where
+import Binary
import Var
import Name
import Module
@@ -294,4 +295,42 @@ costCentreUserNameFS (NormalCC {cc_name = name, cc_is_caf = is_caf})
costCentreSrcSpan :: CostCentre -> SrcSpan
costCentreSrcSpan = cc_loc
+
+instance Binary IsCafCC where
+ put_ bh CafCC = do
+ putByte bh 0
+ put_ bh NotCafCC = do
+ putByte bh 1
+ get bh = do
+ h <- getByte bh
+ case h of
+ 0 -> do return CafCC
+ _ -> do return NotCafCC
+
+instance Binary CostCentre where
+ put_ bh (NormalCC aa ab ac _ad ae) = do
+ putByte bh 0
+ put_ bh aa
+ put_ bh ab
+ put_ bh ac
+ put_ bh ae
+ put_ bh (AllCafsCC ae _af) = do
+ putByte bh 1
+ put_ bh ae
+ get bh = do
+ h <- getByte bh
+ case h of
+ 0 -> do aa <- get bh
+ ab <- get bh
+ ac <- get bh
+ ae <- get bh
+ return (NormalCC aa ab ac noSrcSpan ae)
+ _ -> do ae <- get bh
+ return (AllCafsCC ae noSrcSpan)
+
+ -- We ignore the SrcSpans in CostCentres when we serialise them,
+ -- and set the SrcSpans to noSrcSpan when deserialising. This is
+ -- ok, because we only need the SrcSpan when declaring the
+ -- CostCentre in the original module, it is not used by importing
+ -- modules.
\end{code}