@@ -73,10 +73,23 @@ import Language.Javascript.JSaddle.Types
7373 Object(..), JSValueReceived(..), JSM(..), Batch(..), JSValueForSend(..), syncPoint, syncAfter, sendCommand)
7474import Language.Javascript.JSaddle.Exception (JSException(..))
7575import Control.DeepSeq (force, deepseq)
76+#if MIN_VERSION_base(4,11,0)
77+import GHC.Stats (getRTSStatsEnabled, getRTSStats, RTSStats(..), gcdetails_live_bytes, gc)
78+#else
7679import GHC.Stats (getGCStatsEnabled, getGCStats, GCStats(..))
80+#endif
7781import Data.Foldable (forM_)
7882#endif
7983
84+#ifndef ghcjs_HOST_OS
85+#if MIN_VERSION_base(4,11,0)
86+currentBytesUsed = gcdetails_live_bytes . gc
87+#else
88+getRTSStatsEnabled = getGCStatsEnabled
89+getRTSStats = getGCStats
90+#endif
91+#endif
92+
8093-- | Enable (or disable) JSaddle logging
8194enableLogging :: Bool -> JSM ()
8295#ifdef ghcjs_HOST_OS
@@ -193,8 +206,8 @@ runJavaScript sendBatch entryPoint = do
193206 logInfo s =
194207 readIORef loggingEnabled >>= \case
195208 True -> do
196− currentBytesUsedStr <- getGCStatsEnabled >>= \case
197− True -> show . currentBytesUsed <$> getGCStats
209+ currentBytesUsedStr <- getRTSStatsEnabled >>= \case
210+ True -> show . currentBytesUsed <$> getRTSStats
198211 False -> return "??"
199212 cbCount <- M.size <$> readTVarIO callbacks
200213 putStrLn . s $ "M " <> currentBytesUsedStr <> " CB " <> show cbCount <> " "