From 9b572d541d1d356d7836408ffa98a7b300d02174 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 19 Aug 2022 10:42:34 -0400 Subject: Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. --- libraries/base/GHC/InfoProv.hsc | 29 +++++++++++++++++++---------- libraries/base/GHC/Stack/CloneStack.hs | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'libraries') diff --git a/libraries/base/GHC/InfoProv.hsc b/libraries/base/GHC/InfoProv.hsc index 4f23322a60..86e2ae8a14 100644 --- a/libraries/base/GHC/InfoProv.hsc +++ b/libraries/base/GHC/InfoProv.hsc @@ -20,6 +20,7 @@ module GHC.InfoProv ( InfoProv(..) + , ipLoc , ipeProv , whereFrom -- * Internals @@ -42,10 +43,15 @@ data InfoProv = InfoProv { ipTyDesc :: String, ipLabel :: String, ipMod :: String, - ipLoc :: String + ipSrcFile :: String, + ipSrcSpan :: String } deriving (Eq, Show) + data InfoProvEnt +ipLoc :: InfoProv -> String +ipLoc ipe = ipSrcFile ipe ++ ":" ++ ipSrcSpan ipe + getIPE :: a -> IO (Ptr InfoProvEnt) getIPE obj = IO $ \s -> case whereFrom## obj s of @@ -54,13 +60,14 @@ getIPE obj = IO $ \s -> ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv ipeProv p = (#ptr InfoProvEnt, prov) p -peekIpName, peekIpDesc, peekIpLabel, peekIpModule, peekIpSrcLoc, peekIpTyDesc :: Ptr InfoProv -> IO CString -peekIpName p = (# peek InfoProv, table_name) p -peekIpDesc p = (# peek InfoProv, closure_desc) p -peekIpLabel p = (# peek InfoProv, label) p -peekIpModule p = (# peek InfoProv, module) p -peekIpSrcLoc p = (# peek InfoProv, srcloc) p -peekIpTyDesc p = (# peek InfoProv, ty_desc) p +peekIpName, peekIpDesc, peekIpLabel, peekIpModule, peekIpSrcFile, peekIpSrcSpan, peekIpTyDesc :: Ptr InfoProv -> IO CString +peekIpName p = (# peek InfoProv, table_name) p +peekIpDesc p = (# peek InfoProv, closure_desc) p +peekIpLabel p = (# peek InfoProv, label) p +peekIpModule p = (# peek InfoProv, module) p +peekIpSrcFile p = (# peek InfoProv, src_file) p +peekIpSrcSpan p = (# peek InfoProv, src_span) p +peekIpTyDesc p = (# peek InfoProv, ty_desc) p peekInfoProv :: Ptr InfoProv -> IO InfoProv peekInfoProv infop = do @@ -69,14 +76,16 @@ peekInfoProv infop = do tyDesc <- peekCString utf8 =<< peekIpTyDesc infop label <- peekCString utf8 =<< peekIpLabel infop mod <- peekCString utf8 =<< peekIpModule infop - loc <- peekCString utf8 =<< peekIpSrcLoc infop + file <- peekCString utf8 =<< peekIpSrcFile infop + span <- peekCString utf8 =<< peekIpSrcSpan infop return InfoProv { ipName = name, ipDesc = desc, ipTyDesc = tyDesc, ipLabel = label, ipMod = mod, - ipLoc = loc + ipSrcFile = file, + ipSrcSpan = span } -- | Get information about where a value originated from. diff --git a/libraries/base/GHC/Stack/CloneStack.hs b/libraries/base/GHC/Stack/CloneStack.hs index bc2919218a..3515cb9e33 100644 --- a/libraries/base/GHC/Stack/CloneStack.hs +++ b/libraries/base/GHC/Stack/CloneStack.hs @@ -28,7 +28,7 @@ import Foreign import GHC.Conc.Sync import GHC.Exts (Int (I#), RealWorld, StackSnapshot#, ThreadId#, Array#, sizeofArray#, indexArray#, State#, StablePtr#) import GHC.IO (IO (..)) -import GHC.InfoProv (InfoProv (..), InfoProvEnt, ipeProv, peekInfoProv) +import GHC.InfoProv (InfoProv (..), InfoProvEnt, ipLoc, ipeProv, peekInfoProv) import GHC.Stable -- | A frozen snapshot of the state of an execution stack. -- cgit v1.2.1