@@ -73,10 +73,23 @@ import Language.Javascript.JSaddle.Types
73 Object(..), JSValueReceived(..), JSM(..), Batch(..), JSValueForSend(..), syncPoint, syncAfter, sendCommand)
73 Object(..), JSValueReceived(..), JSM(..), Batch(..), JSValueForSend(..), syncPoint, syncAfter, sendCommand)
74import Language.Javascript.JSaddle.Exception (JSException(..))
74import Language.Javascript.JSaddle.Exception (JSException(..))
75import Control.DeepSeq (force, deepseq)
75import Control.DeepSeq (force, deepseq)
76+#if MIN_VERSION_base(4,11,0)
77+import GHC.Stats (getRTSStatsEnabled, getRTSStats, RTSStats(..), gcdetails_live_bytes, gc)
76import GHC.Stats (getGCStatsEnabled, getGCStats, GCStats(..))
79import GHC.Stats (getGCStatsEnabled, getGCStats, GCStats(..))
77import Data.Foldable (forM_)
81import Data.Foldable (forM_)
85+#if MIN_VERSION_base(4,11,0)
86+currentBytesUsed = gcdetails_live_bytes . gc
88+getRTSStatsEnabled = getGCStatsEnabled
89+getRTSStats = getGCStats
80-- | Enable (or disable) JSaddle logging
93-- | Enable (or disable) JSaddle logging
81enableLogging :: Bool -> JSM ()
94enableLogging :: Bool -> JSM ()
82#ifdef ghcjs_HOST_OS
95#ifdef ghcjs_HOST_OS
@@ -193,8 +206,8 @@ runJavaScript sendBatch entryPoint = do
193 logInfo s =
206 logInfo s =
194 readIORef loggingEnabled >>= \case
207 readIORef loggingEnabled >>= \case
195 True -> do
208 True -> do
196− currentBytesUsedStr <- getGCStatsEnabled >>= \case
209+ currentBytesUsedStr <- getRTSStatsEnabled >>= \case
197− True -> show . currentBytesUsed <$> getGCStats
210+ True -> show . currentBytesUsed <$> getRTSStats
198 False -> return "??"
211 False -> return "??"
199 cbCount <- M.size <$> readTVarIO callbacks
212 cbCount <- M.size <$> readTVarIO callbacks
200 putStrLn . s $ "M " <> currentBytesUsedStr <> " CB " <> show cbCount <> " "
213 putStrLn . s $ "M " <> currentBytesUsedStr <> " CB " <> show cbCount <> " "