Skip to content

Commit

Permalink
Fixed #4457.
Browse files Browse the repository at this point in the history
  • Loading branch information
nad committed Feb 19, 2020
1 parent a91da8f commit f932c53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Agda.cabal
Expand Up @@ -253,6 +253,9 @@ library
if impl(ghc < 8.4)
build-depends: transformers == 0.5.2.0

if impl(ghc >= 8.6)
build-depends: ghc-compact == 0.1.*

-- We don't write upper bounds for Alex nor Happy because the
-- `build-tools` field can not be modified in Hackage. Agda doesn't
-- build with Alex 3.2.0 and segfaults with 3.2.2.
Expand Down
17 changes: 15 additions & 2 deletions src/full/Agda/TypeChecking/Serialise.hs
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}

-- Andreas, Makoto, Francesco 2014-10-15 AIM XX:
-- -O2 does not have any noticable effect on runtime
Expand Down Expand Up @@ -45,6 +46,10 @@ import Data.Function

import qualified Codec.Compression.GZip as G

#if __GLASGOW_HASKELL__ >= 806
import GHC.Compact as C
#endif

import qualified Agda.TypeChecking.Monad.Benchmark as Bench

import Agda.TypeChecking.Serialise.Base
Expand Down Expand Up @@ -179,8 +184,16 @@ decode s = do
Just mf -> stModuleToSource `setTCLens` mf

case r of
Right x -> return (Just x)
Left err -> do
Right x ->
#if __GLASGOW_HASKELL__ < 806
return (Just x)
#else
-- "Compact" the interfaces (without breaking sharing) to reduce
-- the amount of memory that is traversed by the garbage
-- collector.
liftIO (Just . C.getCompact <$> C.compactWithSharing x)
#endif
Left err -> do
reportSLn "import.iface" 5 $ "Error when decoding interface file"
-- Andreas, 2014-06-11 deactivated debug printing
-- in order to get rid of dependency of Serialize on TCM.Pretty
Expand Down

0 comments on commit f932c53

Please sign in to comment.