{-# LINE 1 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} module GHC.Exts.Heap.InfoTable ( module GHC.Exts.Heap.InfoTable.Types , itblSize , peekItbl , pokeItbl ) where import GHC.Exts.Heap.InfoTable.Types {-# LINE 12 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} import GHC.Exts.Heap.Constants import Data.Maybe {-# LINE 15 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} import Foreign ------------------------------------------------------------------------- -- Profiling specific code -- -- The functions that follow all rely on PROFILING. They are duplicated in -- ghc-heap/GHC/Exts/Heap/InfoTableProf.hsc where PROFILING is defined. This -- allows hsc2hs to generate values for both profiling and non-profiling builds. -- | Read an InfoTable from the heap into a haskell type. -- WARNING: This code assumes it is passed a pointer to a "standard" info -- table. If tables_next_to_code is enabled, it will look 1 byte before the -- start for the entry field. peekItbl :: Ptr StgInfoTable -> IO StgInfoTable peekItbl a0 = do {-# LINE 31 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} let ptr = a0 `plusPtr` (negate wORD_SIZE) entry' <- Just <$> ((\hsc_ptr -> peekByteOff hsc_ptr 0)) ptr {-# LINE 33 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} {-# LINE 37 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} ptrs' <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) ptr {-# LINE 38 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} nptrs' <- ((\hsc_ptr -> peekByteOff hsc_ptr 12)) ptr {-# LINE 39 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} tipe' <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) ptr {-# LINE 40 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} {-# LINE 41 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} srtlen' <- ((\hsc_ptr -> peekByteOff hsc_ptr 20)) a0 {-# LINE 42 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} {-# LINE 45 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} return StgInfoTable { entry = entry' , ptrs = ptrs' , nptrs = nptrs' , tipe = toEnum (fromIntegral (tipe' :: HalfWord)) , srtlen = srtlen' , code = Nothing } pokeItbl :: Ptr StgInfoTable -> StgInfoTable -> IO () pokeItbl a0 itbl = do {-# LINE 57 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) a0 (fromJust (entry itbl)) {-# LINE 58 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} {-# LINE 59 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) a0 (ptrs itbl) {-# LINE 60 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} ((\hsc_ptr -> pokeByteOff hsc_ptr 12)) a0 (nptrs itbl) {-# LINE 61 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) a0 (fromEnum (tipe itbl)) {-# LINE 62 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} {-# LINE 63 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} ((\hsc_ptr -> pokeByteOff hsc_ptr 20)) a0 (srtlen itbl) {-# LINE 64 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} {-# LINE 67 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} {-# LINE 74 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-} -- | Size in bytes of a standard InfoTable itblSize :: Int itblSize = ((24)) {-# LINE 78 "libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc" #-}