on master help sign in
Fix optimisation on 8.4.1 (#43)

The generated join points got in the way of inlining. Controlling the inlining phase more carefully helps here

commitb64215133b21fabed4f2e9380f5286cc98046c51 authorCsongor Kiss <kiss.csongor.kiss@gmail.com> dateThu 5 Apr 2018, 23:50 (9 years ago) parent52b543d
6 files changed+23−9
src/Data/Generics/Sum/Constructors.hs+2−2 src/Data/Generics/Sum/Internal/Constructors.hs+5−5 src/Data/Generics/Sum/Internal/Subtype.hs+8−1 src/Data/Generics/Sum/Internal/Typed.hs+5 src/Data/Generics/Sum/Subtype.hs+1 src/Data/Generics/Sum/Typed.hs+2−1
src/Data/Generics/Sum/Constructors.hs+2−2
@@ -112,7 +112,7 @@ instance
112112 , GAsConstructor' ctor (Rep s) a
113113 ) => AsConstructor' ctor s a where
114114 _Ctor' eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
115− {-# INLINE _Ctor' #-}
115+ {-# INLINE[2] _Ctor' #-}
116116
117117instance
118118 ( Generic s
@@ -136,7 +136,7 @@ instance
136136 ) => AsConstructor ctor s t a b where
137137
138138 _Ctor eta = prismRavel (prismPRavel (repIso . _GCtor @ctor)) eta
139− {-# INLINE _Ctor #-}
139+ {-# INLINE[2] _Ctor #-}
140140
141141-- See Note [Uncluttering type signatures]
142142instance {-# OVERLAPPING #-} AsConstructor ctor (Void1 a) (Void1 b) a b where
src/Data/Generics/Sum/Internal/Constructors.hs+5−5
@@ -54,24 +54,24 @@ instance
5454 ) => GAsConstructor ctor (M1 C ('MetaCons ctor fixity fields) f) (M1 C ('MetaCons ctor fixity fields) g) a b where
5555
5656 _GCtor = prism (M1 . view (fromIso (glist @Type)) . tupleToList) (Right . listToTuple . view (glist @Type) . unM1)
57− {-# INLINE _GCtor #-}
57+ {-# INLINE[0] _GCtor #-}
5858
5959
6060instance GSumAsConstructor ctor (HasCtorP ctor l) l r l' r' a b => GAsConstructor ctor (l :+: r) (l' :+: r') a b where
6161 _GCtor = _GSumCtor @ctor @(HasCtorP ctor l)
62− {-# INLINE _GCtor #-}
62+ {-# INLINE[0] _GCtor #-}
6363
6464instance GAsConstructor ctor f f' a b => GAsConstructor ctor (M1 D meta f) (M1 D meta f') a b where
6565 _GCtor = mIso . _GCtor @ctor
66− {-# INLINE _GCtor #-}
66+ {-# INLINE[0] _GCtor #-}
6767
6868class GSumAsConstructor (ctor :: Symbol) (contains :: Bool) l r l' r' a b | ctor l r -> a, ctor l' r' -> b where
6969 _GSumCtor :: Prism ((l :+: r) x) ((l' :+: r') x) a b
7070
7171instance GAsConstructor ctor l l' a b => GSumAsConstructor ctor 'True l r l' r a b where
7272 _GSumCtor = left . _GCtor @ctor
73− {-# INLINE _GSumCtor #-}
73+ {-# INLINE[0] _GSumCtor #-}
7474
7575instance GAsConstructor ctor r r' a b => GSumAsConstructor ctor 'False l r l r' a b where
7676 _GSumCtor = right . _GCtor @ctor
77− {-# INLINE _GSumCtor #-}
77+ {-# INLINE[0] _GSumCtor #-}
src/Data/Generics/Sum/Internal/Subtype.hs+8−1
@@ -57,15 +57,18 @@ class GSplash (sub :: Type -> Type) (sup :: Type -> Type) where
5757instance (GSplash a sup, GSplash b sup) => GSplash (a :+: b) sup where
5858 _GSplash (L1 rep) = _GSplash rep
5959 _GSplash (R1 rep) = _GSplash rep
60+ {-# INLINE[0] _GSplash #-}
6061
6162instance
6263 ( GIsList () subf subf as as
6364 , GAsType supf as
6465 ) => GSplash (C1 meta subf) supf where
6566 _GSplash p = build ((_GTyped . fromIso (glist @()) . fromIso mIso)) p
67+ {-# INLINE[0] _GSplash #-}
6668
6769instance GSplash sub sup => GSplash (D1 c sub) sup where
6870 _GSplash (M1 m) = _GSplash m
71+ {-# INLINE[0] _GSplash #-}
6972
7073--------------------------------------------------------------------------------
7174
@@ -79,6 +82,7 @@ instance
7982 _GDowncast (M1 m) = case _GDowncastC @(HasPartialTypeP as sub) m of
8083 Left _ -> Left (M1 m)
8184 Right r -> Right r
85+ {-# INLINE[0] _GDowncast #-}
8286
8387instance (GDowncast sub l, GDowncast sub r) => GDowncast sub (l :+: r) where
8488 _GDowncast (L1 x) = case _GDowncast x of
@@ -87,22 +91,25 @@ instance (GDowncast sub l, GDowncast sub r) => GDowncast sub (l :+: r) where
8791 _GDowncast (R1 x) = case _GDowncast x of
8892 Left _ -> Left (R1 x)
8993 Right r -> Right r
94+ {-# INLINE[0] _GDowncast #-}
9095
9196instance GDowncast sub sup => GDowncast sub (D1 m sup) where
9297 _GDowncast (M1 m) = case _GDowncast m of
9398 Left _ -> Left (M1 m)
9499 Right r -> Right r
100+ {-# INLINE[0] _GDowncast #-}
95101
96102class GDowncastC (contains :: Bool) sub sup where
97103 _GDowncastC :: sup x -> Either (sup x) (sub x)
98104
99105instance GDowncastC 'False sub sup where
100106 _GDowncastC sup = Left sup
107+ {-# INLINE[0] _GDowncastC #-}
101108
102109instance
103110 ( GAsType sub subl
104111 , GIsList () sup sup subl subl
105112 ) => GDowncastC 'True sub sup where
106113 _GDowncastC sup = Right (build (_GTyped . fromIso (glist @())) sup)
107− {-# INLINE _GDowncastC #-}
114+ {-# INLINE[0] _GDowncastC #-}
108115
src/Data/Generics/Sum/Internal/Typed.hs+5
@@ -50,18 +50,23 @@ instance
5050 ( GIsList () f f as as
5151 ) => GAsType (M1 C meta f) as where
5252 _GTyped = mIso . glist @()
53+ {-# INLINE[0] _GTyped #-}
5354
5455instance GSumAsType (HasPartialTypeP a l) l r a => GAsType (l :+: r) a where
5556 _GTyped = _GSumTyped @(HasPartialTypeP a l)
57+ {-# INLINE[0] _GTyped #-}
5658
5759instance GAsType f a => GAsType (M1 D meta f) a where
5860 _GTyped = mIso . _GTyped
61+ {-# INLINE[0] _GTyped #-}
5962
6063class GSumAsType (contains :: Bool) l r (a :: [((), Type)]) where
6164 _GSumTyped :: Prism ((l :+: r) x) ((l :+: r) x) (List a) (List a)
6265
6366instance GAsType l a => GSumAsType 'True l r a where
6467 _GSumTyped = left . _GTyped
68+ {-# INLINE[0] _GSumTyped #-}
6569
6670instance GAsType r a => GSumAsType 'False l r a where
6771 _GSumTyped = right . _GTyped
72+ {-# INLINE[0] _GSumTyped #-}
src/Data/Generics/Sum/Subtype.hs+1
@@ -90,6 +90,7 @@ class AsSubtype sub sup where
9090 -- Nothing
9191 _Sub :: Prism' sup sub
9292 _Sub = prism injectSub (\i -> maybe (Left i) Right (projectSub i))
93+ {-# INLINE[2] _Sub #-}
9394
9495 -- |Injects a subtype into a supertype (upcast).
9596 injectSub :: sub -> sup
src/Data/Generics/Sum/Typed.hs+2−1
@@ -89,6 +89,7 @@ class AsType a s where
8989 -- ...
9090 _Typed :: Prism' s a
9191 _Typed = prism injectTyped (\i -> maybe (Left i) Right (projectTyped i))
92+ {-# INLINE[2] _Typed #-}
9293
9394 -- |Inject by type.
9495 injectTyped :: a -> s
@@ -111,7 +112,7 @@ instance
111112 ) => AsType a s where
112113
113114 _Typed eta = prismRavel (prismPRavel (repIso . _GTyped @_ @as . tupled)) eta
114− {-# INLINE _Typed #-}
115+ {-# INLINE[2] _Typed #-}
115116
116117-- See Note [Uncluttering type signatures]
117118instance {-# OVERLAPPING #-} AsType a Void where