on master help sign in
Fixes for GHC 8.4
commitbf278d3779c06933b75094a60a6fc9ff4a682140 authorHamish Mackenzie <Hamish.K.Mackenzie@googlemail.com> dateWed 13 Jun 2018, 22:44 (8 years ago) parent284cccf
2 files changed+17−3
jsaddle/src-ghc/Data/JSString/Internal/Type.hs+2−1 jsaddle/src/Language/Javascript/JSaddle/Run.hs+15−2
jsaddle/src-ghc/Data/JSString/Internal/Type.hs+2−1
@@ -38,10 +38,11 @@ import Data.Aeson (ToJSON(..), FromJSON(..))
3838import Data.Data (Data)
3939-- import Data.Text.Internal.Unsafe.Char (ord)
4040import Data.Typeable (Typeable)
41+import Data.Semigroup (Semigroup)
4142import GHC.Exts (Char(..), ord#, andI#, (/=#), isTrue#)
4243
4344-- | A wrapper around a JavaScript string
44−newtype JSString = JSString Text deriving(Show, Read, IsString, Monoid, Ord, Eq, Data, ToJSON, FromJSON, Typeable)
45+newtype JSString = JSString Text deriving(Show, Read, IsString, Semigroup, Monoid, Ord, Eq, Data, ToJSON, FromJSON, Typeable)
4546
4647instance NFData JSString where rnf !_ = ()
4748
jsaddle/src/Language/Javascript/JSaddle/Run.hs+15−2
@@ -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 <> " "