summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2017-11-15 20:49:54 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2017-11-15 22:57:02 +0200
commit75a4a5d4b373a512fbebf8bc79f1d2da1ac394b7 (patch)
tree0b1cb7876cef8469cfccb85830118e56677c919a
parent12028239b597e17fb3f3734c6b494e127be58e0c (diff)
downloadhaskell-75a4a5d4b373a512fbebf8bc79f1d2da1ac394b7.tar.gz
Reduce compile time memory usage by splitting HsInstances
On my machine, compiling with GHC 8.2.1, Compililing HsInstances.hs takes around 3.2G (via top, rss) compiling using the generated ghc-stage1 uses 5.9G
-rw-r--r--compiler/hsSyn/HsExpr.hs-boot8
-rw-r--r--compiler/hsSyn/HsInstances.hs18
-rw-r--r--compiler/hsSyn/HsInstances.hs-boot20
-rw-r--r--compiler/hsSyn/HsInstances2.hs11
-rw-r--r--compiler/hsSyn/HsInstances2.hs-boot31
-rw-r--r--compiler/hsSyn/HsPat.hs-boot1
-rw-r--r--compiler/hsSyn/HsSyn.hs1
7 files changed, 65 insertions, 25 deletions
diff --git a/compiler/hsSyn/HsExpr.hs-boot b/compiler/hsSyn/HsExpr.hs-boot
index 03a18a3bc7..b14915110c 100644
--- a/compiler/hsSyn/HsExpr.hs-boot
+++ b/compiler/hsSyn/HsExpr.hs-boot
@@ -14,7 +14,6 @@ import Outputable ( SDoc, Outputable )
import {-# SOURCE #-} HsPat ( LPat )
import BasicTypes ( SpliceExplicitFlag(..))
import HsExtension ( OutputableBndrId, SourceTextX, GhcPass )
-import Data.Data hiding ( Fixity )
type role HsExpr nominal
type role HsCmd nominal
@@ -29,13 +28,6 @@ data MatchGroup (a :: *) (body :: *)
data GRHSs (a :: *) (body :: *)
data SyntaxExpr (i :: *)
--- instance (DataIdLR p p) => Data (HsSplice p)
--- instance (DataIdLR p p) => Data (HsExpr p)
--- instance (DataIdLR p p) => Data (HsCmd p)
--- instance (Data body,DataIdLR p p) => Data (MatchGroup p body)
--- instance (Data body,DataIdLR p p) => Data (GRHSs p body)
--- instance (DataIdLR p p) => Data (SyntaxExpr p)
-
instance (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> Outputable (HsExpr (GhcPass p))
instance (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
diff --git a/compiler/hsSyn/HsInstances.hs b/compiler/hsSyn/HsInstances.hs
index fc871f14f0..169199edbb 100644
--- a/compiler/hsSyn/HsInstances.hs
+++ b/compiler/hsSyn/HsInstances.hs
@@ -4,7 +4,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
-{-# GHC_OPTIONS -fno-warn-orphans #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
module HsInstances where
-- This module defines the Data instances for the hsSyn AST.
@@ -14,16 +14,16 @@ module HsInstances where
-- UndecidableInstances ?
-import GhcPrelude
+import {-# SOURCE #-} HsInstances2 ()
import Data.Data hiding ( Fixity )
import HsExtension
import HsBinds
import HsDecls
-import HsExpr
-import HsLit
+-- import HsExpr
+-- import HsLit
import HsTypes
-import HsPat
+-- import HsPat
-- Data derivations from HsBinds ---------------------------------------
@@ -55,8 +55,9 @@ deriving instance (DataIdLR p p) => Data (HsDerivingClause p)
deriving instance (DataIdLR p p) => Data (ConDecl p)
deriving instance DataIdLR p p => Data (TyFamInstDecl p)
deriving instance DataIdLR p p => Data (DataFamInstDecl p)
+deriving instance (DataIdLR p p) => Data (FamEqn p (HsTyPats p) (HsDataDefn p))
+deriving instance (DataIdLR p p) => Data (FamEqn p (HsTyPats p) (LHsType p))
deriving instance (DataIdLR p p) => Data (FamEqn p (LHsQTyVars p) (LHsType p))
-deriving instance (DataIdLR p p) => Data (FamEqn p (HsTyPats p) (HsDataDefn p))
deriving instance (DataIdLR p p) => Data (ClsInstDecl p)
deriving instance (DataIdLR p p) => Data (InstDecl p)
deriving instance (DataIdLR p p) => Data (DerivDecl p)
@@ -70,10 +71,9 @@ deriving instance (DataId p) => Data (WarnDecls p)
deriving instance (DataId p) => Data (WarnDecl p)
deriving instance (DataIdLR p p) => Data (AnnDecl p)
deriving instance (DataId p) => Data (RoleAnnotDecl p)
-deriving instance (DataIdLR p p) => Data (FamEqn p (HsTyPats p) (LHsType p))
-- Data derivations from HsExpr ----------------------------------------
-
+{-
deriving instance (DataIdLR p p) => Data (SyntaxExpr p)
deriving instance (DataIdLR p p) => Data (HsExpr p)
deriving instance (DataIdLR p p) => Data (HsTupArg p)
@@ -128,5 +128,5 @@ deriving instance DataId p => Data (AmbiguousFieldOcc p)
deriving instance (DataIdLR p p) => Data (Pat p)
deriving instance (DataIdLR p p) => Data (HsRecFields p (LPat p))
deriving instance (DataIdLR p p) => Data (HsRecFields p (LHsExpr p))
-
+-}
-- ---------------------------------------------------------------------
diff --git a/compiler/hsSyn/HsInstances.hs-boot b/compiler/hsSyn/HsInstances.hs-boot
new file mode 100644
index 0000000000..3dda7e84d6
--- /dev/null
+++ b/compiler/hsSyn/HsInstances.hs-boot
@@ -0,0 +1,20 @@
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module HsInstances where
+
+import Data.Data hiding ( Fixity )
+import HsExtension ( DataIdLR )
+import HsBinds
+import HsDecls
+import HsTypes
+
+instance (DataIdLR p p) => Data (VectDecl p)
+instance (DataIdLR pL pR) => Data (HsLocalBindsLR pL pR)
+instance (DataIdLR p p) => Data (HsDecl p)
+instance (DataIdLR p p) => Data (HsGroup p)
+instance (DataIdLR pL pL) => Data (NHsValBindsLR pL)
+instance (DataIdLR p p) => Data (FamEqn p (HsTyPats p) (HsDataDefn p))
+instance (DataIdLR p p) => Data (FamEqn p (HsTyPats p) (LHsType p))
diff --git a/compiler/hsSyn/HsInstances2.hs b/compiler/hsSyn/HsInstances2.hs
index 1e5ee72d9f..2250387be8 100644
--- a/compiler/hsSyn/HsInstances2.hs
+++ b/compiler/hsSyn/HsInstances2.hs
@@ -4,8 +4,8 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
-{-# GHC_OPTIONS -fno-warn-orphans #-}
-module HsInstances where
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module HsInstances2 where
-- This module defines the Data instances for the hsSyn AST.
@@ -14,12 +14,11 @@ module HsInstances where
-- UndecidableInstances ?
-import GhcPrelude
import Data.Data hiding ( Fixity )
-import {-#
+import {-# SOURCE #-} HsInstances ()
import HsExtension
-import HsBinds
+-- import HsBinds
import HsDecls
import HsExpr
import HsLit
@@ -72,7 +71,7 @@ deriving instance (DataId p) => Data (WarnDecl p)
deriving instance (DataIdLR p p) => Data (AnnDecl p)
deriving instance (DataId p) => Data (RoleAnnotDecl p)
deriving instance (DataIdLR p p) => Data (FamEqn p (HsTyPats p) (LHsType p))
-
+-}
-- Data derivations from HsExpr ----------------------------------------
deriving instance (DataIdLR p p) => Data (SyntaxExpr p)
diff --git a/compiler/hsSyn/HsInstances2.hs-boot b/compiler/hsSyn/HsInstances2.hs-boot
new file mode 100644
index 0000000000..16ac7eefd9
--- /dev/null
+++ b/compiler/hsSyn/HsInstances2.hs-boot
@@ -0,0 +1,31 @@
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module HsInstances2 where
+
+
+import Data.Data hiding ( Fixity )
+import HsExtension ( DataIdLR )
+import HsDecls
+import HsExpr
+import HsTypes
+import HsPat
+
+instance (DataIdLR p p) => Data (HsExpr p)
+instance (DataIdLR p p) => Data (HsTyVarBndr p)
+instance (DataIdLR p p) => Data (HsType p)
+instance (DataIdLR p p) => Data (LHsQTyVars p)
+instance (DataIdLR p p) => Data (HsImplicitBndrs p (LHsType p))
+instance (DataIdLR p p) => Data (HsImplicitBndrs p (FamEqn p (HsTyPats p) (HsDataDefn p)))
+instance (DataIdLR p p) => Data (HsImplicitBndrs p (FamEqn p (HsTyPats p) (LHsType p)))
+instance (DataIdLR p p) => Data (HsWildCardBndrs p (LHsSigType p))
+instance (DataIdLR p p) => Data (ConDeclField p)
+
+instance (DataIdLR p p) => Data (HsSplice p)
+instance (DataIdLR p p) => Data (MatchGroup p (LHsExpr p))
+
+instance (DataIdLR p p) => Data (Pat p)
+
+instance (DataIdLR p p) => Data (GRHSs p (LHsExpr p))
diff --git a/compiler/hsSyn/HsPat.hs-boot b/compiler/hsSyn/HsPat.hs-boot
index dfd535996c..203209dba1 100644
--- a/compiler/hsSyn/HsPat.hs-boot
+++ b/compiler/hsSyn/HsPat.hs-boot
@@ -9,7 +9,6 @@
module HsPat where
import SrcLoc( Located )
-import Data.Data hiding (Fixity)
import Outputable
import HsExtension ( SourceTextX, OutputableBndrId, GhcPass )
diff --git a/compiler/hsSyn/HsSyn.hs b/compiler/hsSyn/HsSyn.hs
index 83147b6609..54ba278414 100644
--- a/compiler/hsSyn/HsSyn.hs
+++ b/compiler/hsSyn/HsSyn.hs
@@ -32,7 +32,6 @@ module HsSyn (
Fixity,
HsModule(..),
- HsInstances
) where
-- friends: